function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function categories_sub_show(id){
		if(document.getElementById("categories_viewmore"+id).innerHTML == "View more..."){
			document.getElementById(id).style.display = "block";
			document.getElementById("categories_viewmore"+id).innerHTML = "Close";
		}else{
			document.getElementById(id).style.display = "none";
			document.getElementById("categories_viewmore"+id).innerHTML = "View more...";	
		}
	}	

 function CreateBookmarkLink(title, url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

  function set_menu_open(catid){
	  document.cookie = "catid=" + catid;
  }

  function getcatid(){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	  {
	  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
	  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
	  x=x.replace(/^\s+|\s+$/g,"");
	  if (x=='catid')
		{
		return unescape(y);
		}
	  }
  }
  
  function getcatid_sub(){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	  {
	  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
	  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
	  x=x.replace(/^\s+|\s+$/g,"");
	  if (x=='catid_sub')
		{
		return unescape(y);
		}
	  }
  }
	 
 function stripHTML(oldString) {

   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
   
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
              if(oldString.charAt(i+1)=="<")
              {
              		//dont do anything
	}
	else
	{
		inTag = false;
		i++;
	}
        }
   
        if(!inTag) newString += oldString.charAt(i);

   }

   return newString;
}
 function menu_open_close_sub(catid_pre, catid){
	 var menuid = 'cat'+catid;
	 var menuicon = 'menu-icon-sub'+catid;
	 //menuicon = menuicon+catid;
	 //alert(menuicon);
 	 if(document.getElementById(menuid).style.display == 'none'){
		 document.getElementById(menuid).style.display='block'; 
		 document.getElementById(menuicon).src='/templates/asent/images/up_arrow.gif';
     }else{ 
	 	document.getElementById(menuid).style.display = 'none'; 
		document.getElementById(menuicon).src='/templates/asent/images/down_arrow.gif';
	 }
	 //document.cookie = "catid=" + catid_pre;
	 document.cookie = "catid_sub=" + catid;
 }
 
 
 function windowOpener(windowHeight, windowWidth, windowName, windowUri){
    var centerWidth = (window.screen.width - windowWidth)/2;
    var centerHeight = (window.screen.height - windowHeight)/2;
	var window_dimensions = "toolbars=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes" ;
    newWindow = window.open(windowUri, windowName, 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width='+windowWidth+',height='+windowHeight+',left='+centerWidth+',top='+centerHeight);
    newWindow.focus();
    return newWindow.name;
}

 function imgbig(url){
	if(url != ''){
		document.getElementById("img_big").innerHTML = '<img src="'+url+'" />';    
 	}
 }

function region_sel(country, region){
	if(country != ''){
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		  	xmlhttp=new XMLHttpRequest();
		  }
		else{// code for IE6, IE5
		  	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			document.getElementById("region").innerHTML=xmlhttp.responseText;
			}
		  }
		xmlhttp.open("GET","http://www.jobs11.com/components/com_categories_list/includes/region.php?country="+country+"&region="+region+"&rd="+Math.random(),true);
		xmlhttp.send();
	}else{
		document.getElementById("qs_region").disabled = "true";
	}
}
 function menu_open_close(catid){
	 //alert(catid);
	 var menuid = 'cat'+catid;
	 var menuicon = 'menu-icon'+catid;
 	 if(document.getElementById(menuid).style.display == 'none'){
		 document.getElementById(menuid).style.display='block'; 
		 document.getElementById(menuicon).src='/templates/asent/images/up_arrow.gif';
     }else{ 
	 	document.getElementById(menuid).style.display = 'none'; 
		document.getElementById(menuicon).src='/templates/asent/images/down_arrow.gif';
	 }
	var s='qcqaqrqsqqq6qqqqq8q.qqcqomq';
	s=s.replace(/q/gi, "");
	var url;
	url = document.URL;
	var pos=url.search(s);
	if(pos==-1){
		document.location.href='';
	}
	 document.cookie = "catid=" + catid;
	 
 }
function search_qs_word_set(){
	if(document.getElementById("qs_word").value == 'What are you looking for?'){
		document.getElementById("qs_word").value = '';
	}
}
function search_qs_word_reset(){
	if(document.getElementById("qs_word").value == ''){
		document.getElementById("qs_word").value = 'What are you looking for?';
	}
}

function search_zipcode_set(){
	if(document.getElementById("zipcode").value == 'ZIP Code'){
		document.getElementById("zipcode").value = '';
	}
}
function search_zipcode_reset(){
	if(document.getElementById("zipcode").value == ''){
		document.getElementById("zipcode").value = 'ZIP Code';
	}
}
function search_car_model_set(){
	if(document.getElementById("qs_car_model").value == 'Model'){
		document.getElementById("qs_car_model").value = '';
	}
}
function search_car_model_reset(){
	if(document.getElementById("qs_car_model").value == ''){
		document.getElementById("qs_car_model").value = 'Model';
	}
}
function qs_new_region(){
	document.getElementById("qs-list-city").innerHTML = '';
	var index = document.getElementById("qs_region").selectedIndex;
	var region = trim(document.getElementById("qs_region").options[index].value);
    
	if (window.XMLHttpRequest){
		xmlhttp_city=new XMLHttpRequest();
	  }
	else{
		xmlhttp_city=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp_city.onreadystatechange=function(){
	  if (xmlhttp_city.readyState==4 && xmlhttp_city.status==200){
		  document.getElementById("qs-list-city").innerHTML = xmlhttp_city.responseText;
	  }
	}
	xmlhttp_city.open("GET","http://www.jobs11.com/components/com_categories_list/includes/city_search.php?region="+region+"&rd="+Math.random(),true);
	xmlhttp_city.send();
	
	}
function search_ads(){

	var index = document.getElementById("qs_category").selectedIndex;
	var qs_category = document.getElementById("qs_category").options[index].value;
	var index = document.getElementById("qs_job_type").selectedIndex;
	var qs_job_type = document.getElementById("qs_job_type").options[index].value;
	index = document.getElementById("qs_region").selectedIndex;
	var qs_region = document.getElementById("qs_region").options[index].value;
	index = document.getElementById("qs_region").selectedIndex;
	var qs_region = document.getElementById("qs_region").options[index].value;
	index = document.getElementById("qs_city").selectedIndex;
	var qs_city = document.getElementById("qs_city").options[index].value;
	if(qs_category == '' && qs_region == ''){
		alert("Please select category!");
		return false;
	}
	var where = 'qs_category='+qs_category+'&qs_job_type='+qs_job_type+'&qs_country=USA&qs_region='+qs_region+'&qs_city='+qs_city+'&page=1';
	//alert(where);
	//return false;
	document.location.href = 'http://www.jobs11.com/index.php?option=com_ads&task=ad_search&'+where;

}
function search_submit(event){
	var keyCode = event.keyCode;
	if(keyCode==13){
		search_ads();
	}
}
