//---------------------------- IMAGE SWAP -------------------------------//

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//---------------------------- Confirm Delete -------------------------------//
function confirmDelete()
{
var agree=confirm("Are you sure you want to Delete this record?");
if (agree)
	return true ;
else
	return false ;
}


//---------------------------- Toggles -------------------------------------//

//-------------- Advanced Search Options ------------

function toggle_search_option(list)
    {
	 	var listElementStyle=document.getElementById(list).style;
    	if (listElementStyle.display=="none")
	    {
	      listElementStyle.display="block";
		  //document.getElementById('search_option').innerHTML="Basic Search";
		  document.yq_main_srch.yq_SearchType.value="Advanced";
		  document.yq_main_srch.yq_vSearchtxt.disabled=true;
		  document.yq_main_srch.search_type[0].checked=true;
		  document.yq_main_srch.search_type[1].checked=false;
	    }
		else
	    {
	       listElementStyle.display="none";
		   document.yq_main_srch.yq_SearchType.value="Basic";
		   document.yq_main_srch.yq_vSearchtxt.disabled=false;
		   document.yq_main_srch.search_type[0].checked=false;
		   document.yq_main_srch.search_type[1].checked=true;
		}
    }

//============= classified
function toggle_search_option_class(boxtt)
    {

	 	var listElementStyle=document.getElementById(boxtt).style;
    	if (listElementStyle.display=="none")
	    {
		
	      listElementStyle.display="block";
		  //document.getElementById('search_option').innerHTML="Basic Search";
		  document.yq_main_srch_class.yq_SearchTypes.value="Advanced";
		  document.yq_main_srch_class.yq_vSearchtxts.disabled=true;
		  document.yq_main_srch_class.search_types[0].checked=true;
		  document.yq_main_srch_class.search_types[1].checked=false;
	    }
		else
	    {
	       listElementStyle.display="none";
		   document.yq_main_srch_class.yq_SearchTypes.value="Basic";
		   document.yq_main_srch_class.yq_vSearchtxts.disabled=false;
		   document.yq_main_srch_class.search_types[0].checked=false;
		   document.yq_main_srch_class.search_types[1].checked=true;
		}
    }
 function changetemplates(filen)
   {
	 document.yq_main_srch_class.action=filen;
	 document.yq_main_srch_class.text_search_value_refresh.value="Yes";
     document.yq_main_srch_class.submit();
   }


//========== End of classified=====

//-------------- SMS Contact Options ------
function toggle_sms_option_group(signup_options)
{
var listElementStyle=document.getElementById(signup_options).style;
if (listElementStyle.display=="none")
{
listElementStyle.display="block";
}
else
{
listElementStyle.display="none";
}
}




function toggle_rss_options(rss_preferences)
    {
	 	var listElementStyle=document.getElementById(rss_preferences).style;
    	if (listElementStyle.display=="none")
	    {
		  //document.getElementById('rss_preference_tag').innerHTML="Close Rss Preferences";
	      listElementStyle.display="block";
		}
		else
	    {
		   //document.getElementById('rss_preference_tag').innerHTML="Rss Preferences";
	       listElementStyle.display="none";
		}
    }

function toggle_ticket_options(ticket_details)
    {
	 	var listElementStyle=document.getElementById(ticket_details).style;
    	if (listElementStyle.display=="none")
	    {listElementStyle.display="block";}
		else
	    {listElementStyle.display="none";}
    }


//-------------- Sign Up ---------------

function toggle_signup(list,list1)
    {
	 	var listElementStyle=document.getElementById(list).style;
		var listElementStyle1=document.getElementById(list1).style;
    	if (listElementStyle.display=="none")
	    {
	      listElementStyle.display="block";
		  listElementStyle1.display="None";
		}
	else
	    {
	       listElementStyle.display="none";
		   listElementStyle1.display="Block";
   	    }
    }

//-------------- Sign Up Options ------
function toggle_signup_option(signup_options)
    {
	 	var listElementStyle=document.getElementById(signup_options).style;
    	if (listElementStyle.display=="none")
	    {
	      listElementStyle.display="block";
		}
	else
	    {
	       listElementStyle.display="none";
   	    }
    }
//-------------- tell a friend ------------


function toggle_savetohistory(sth)
    {
	 	var listElementStyle=document.getElementById(sth).style;
    	if (listElementStyle.display=="none")
	    {
	      listElementStyle.display="block";
		}
	else
	    {
	       listElementStyle.display="none";
   	    }
    }


//--------------------------------------- Tooltip -------------------------------------------------------


function showLogger()
	{
		win = window.open("logger.php", "logger", ",top=0,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no");
				win.focus();
	}


function changetemplate(filen)
   {
	 document.yq_main_srch.action=filen;
	 document.yq_main_srch.text_search_value_refresh.value="Yes";
     document.yq_main_srch.submit();
   }
 function changerelatedlinks(filen)
   {
	 document.related_links_change.action=filen;
	 document.related_links_change.related_link_post.value="Yes";
     document.related_links_change.submit();
   }

//--------------------------------------- Page Print -------------------------------------------------------

function yq_page_print()
{window.print();}

//--------------------------------------- Tell a friend ----------------------------------------------------

var initialsubj="Hi. Take a look at this. This is interesting!!!"
var initialmsg="Hello:\n You may want to check out this site: "+window.location
var good;

function checkEmailAddress(field) {
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid address.');
field.focus();
field.select();
good = false;
   }
}
u = window.location;
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.email);
if (good) {

//window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+document.title+" "+u;
window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+initialmsg
   }
}

//--------------------------------------- End of Tell a friend ----------------------------------------------



//---------------------------------------------- Save to History --------------------------------------------

var loadedobjects_sth="";
var rootdomain_sth="http://"+window.location.hostname;
function yq_save_to_history(url_sth, record_holder_id_sth){
var record_request_sth = false;
if (window.XMLHttpRequest) // if Mozilla, Safari etc
record_request_sth = new XMLHttpRequest();
else if (window.ActiveXObject){ // if IE
try {
record_request_sth = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e_sth){
try{
record_request_sth = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e_sth){}
}
}
else
return false
record_request_sth.onreadystatechange=function(){
load_record_sth(record_request_sth, record_holder_id_sth);
}
record_request_sth.open('GET', url_sth, true);
record_request_sth.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); 
record_request_sth.setRequestHeader("Cache-Control", "no-cache"); 
record_request_sth.send(null);
}

function load_record_sth(record_request_sth, record_holder_id_sth){
if (record_request_sth.readyState == 4 && (record_request_sth.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(record_holder_id_sth).innerHTML=record_request_sth.responseText;
}
//---------------------------------------------- End of Save to History ----------------------------------


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);



//---------------------------------------- IMAGE SCROLLER -------------------------------------------//

