function usaphone(){
	var phone=$("txtPhone").value;
	var validvalue=false;
	var numbers=new Array('1','2','3','4','5','6','7','8','9','0');
	var phonearray=phone.split("");
	var m=0
	for(i=0;i<=numbers.length;i++){
		if(phonearray[phonearray.length-1]==numbers[i]){
			m=m+1;

		}
	}
		if(m==0 || phonearray.length==13){
			var newvalue=""
			for(i=0;i<phonearray.length-1;i++){
				newvalue=newvalue+phonearray[i];
			}
			$("txtPhone").value=newvalue;
		}
}
function ajaxFunction(jind,jmls)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      var xmlDoc=xmlHttp.responseXML.documentElement;
			document.getElementById("rcCharge" + jind).innerHTML = xmlDoc.getElementsByTagName("pricemsg")[0].childNodes[0].nodeValue;
			document.getElementById("rcMessage" + jind).innerHTML = xmlDoc.getElementsByTagName("msg")[0].childNodes[0].nodeValue;
			// document.getElementById("rcCharge" + jind).innerHTML=xmlHttp.responseText;
			document.getElementById("rcCharge" + jind).style.display = 'block';
			document.getElementById("rcMessage" + jind).style.display = 'block';
			document.getElementById("rcLoading" + jind).style.display = 'none';
      
			var tourStat = xmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue;
			
			if (tourStat == 'Success')
				{
				document.getElementById("rcDistBtn" + jind).style.display = 'block';
				document.getElementById("rcDist" + jind).disabled = false;
				if (xmlDoc.getElementsByTagName("price")[0].childNodes[0].nodeValue == 0)
					{
					document.getElementByID("rcDist" + jind).checked = 'checked';
					}
				}
			}
    }
  xmlHttp.open("GET","/testcode/picturepath.asp?MLSID=" + jmls,true);
  xmlHttp.send(null);
  }
 function finaldistFunction(jind,jmls)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      var xmlDoc=xmlHttp.responseXML.documentElement;
			document.getElementById("rcCharge" + jind).innerHTML = xmlDoc.getElementsByTagName("pricemsg")[0].childNodes[0].nodeValue;
			document.getElementById("rcMessage" + jind).innerHTML = xmlDoc.getElementsByTagName("msg")[0].childNodes[0].nodeValue;
			// document.getElementById("rcCharge" + jind).innerHTML=xmlHttp.responseText;
			document.getElementById("rcCharge" + jind).style.display = 'block';
			document.getElementById("rcMessage" + jind).style.display = 'block';
			document.getElementById("rcLoading" + jind).style.display = 'none';
      
			var tourStat = xmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue;
			
			if (tourStat == 'Success')
				{
				document.getElementById("rcDistBtn" + jind).style.display = 'none';
				document.getElementById("rcDist" + jind).disabled = true;
				if (xmlDoc.getElementsByTagName("price")[0].childNodes[0].nodeValue == 0)
					{
					document.getElementByID("rcDist" + jind).checked = 'checked';
					}
				}
			}
    }
  xmlHttp.open("GET","/testcode/Distributepp.asp?MLSID=" + jmls,true);
  xmlHttp.send(null);
  }
  function gbFunction(jind,jtid)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
			document.getElementById("gbIcon" + jind).style.display = 'none';
      }
    }
  xmlHttp.open("GET","/mytours/togglegb.asp?tID=" + jtid,true);
  xmlHttp.send(null);
  }
  function copy(text2copy) {
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
	alert('The selected link has been copied to your clipboard.')
}
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_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_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];}
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}
//
function opener(m,p,s){
	window.location.href = "/home/?_m="+m+"&_p="+p+"&s="+s;
}
function snaptourbox(){
	var state=$("statesbox").value;
	opener('pages','showcase',state);
}
function copytext(id){
	window.clipboardData.setData('text',$(id).value);
}
function agentemailsend(id){
	new Ajax.Updater('mailsend',"../mail/generateEmail.asp", 
	{
		method:'POST',
		parameters:{
			tID:id,
			Name:$F('Name'),
			ToEmail:$F('ToEmail'),
			Body:$F('Body')		
		},
	onComplete:function(){
		new Effect.Highlight('mailsend');
		setTimeout("redirect('../home/default.asp?_m=mytours&_p=home&s=mysnaptours')",4000);
		},
	asynchronous:true,
	evalScripts:true
	});
}
function redirect(url){
	window.location.href=url
}
function statsemailsend(id){
	new Ajax.Updater('mailsend',"../mail/generatestatsEmail.asp", 
	{
		method:'POST',
		parameters:{
			tID:id,
			Name:$F('Name'),
			ToEmail:$F('ToEmail')	
		},
	onComplete:function(){
			new Effect.Highlight('mailsend');
			setTimeout("redirect('../home/default.asp?_m=mytours&_p=home&s=mysnaptours')",4000);
	},
	asynchronous:true,
	evalScripts:true
	});
}
function changebg(id){
	var stil=$(id).style;
	if(stil.backgroundColor!="#191919"){
		stil.backgroundColor="#191919";
	}else{
		stil.backgroundColor="#2e2e2e";
	}
}