var xmlHttp;
var filepath = "http://itransmit.sapplica.com/ajax.php?"
var filepath2 = "http://itransmit.sapplica.com/accesskey.php?"
var filepath3 = "http://itransmit.sapplica.com/includes/ajax_reg.php?" // added by rakesh
/*
var filepath = "http://174.143.232.143/itransmit/ajax.php?"
var filepath2 = "http://174.143.232.143/itransmit/accesskey.php?"
var filepath3 = "http://174.143.232.143/itransmit/includes/ajax_reg.php?" // added by rakesh
*/
//XMLhttp variable will hold the XMLHttpRequest object
function GetXmlHttpObject(handler)
{ 
		var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
		objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp
}
/* Function for stateChanged functionality */
function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{	
		//png();
		document.getElementById("4").innerHTML=xmlHttp.responseText;
		//alert(xmlHttp.responseText);

	} 
} 

/*This function is ment for paging
1.filepath is-destination url where the action should perform
2.slimit-it indicates the startlimit
3.elimit-it indicates the endlimit that is how many records has to be displayed
*/
function checkpaging(slimit, elimit, currentpage)
	{
		var objdiv = 0;
		var searchobj = filepath.search('###');
		filepath = filepath;
		if (searchobj != -1)
		{
			objdiv = searchobj;
		}
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	

		var url	= filepath+"slimit="+slimit+"&elimit="+elimit+"&paging=yes&currentpage="+currentpage
		//alert(url)
		if (objdiv == 0)
		{
			xmlHttp.onreadystatechange=stateChanged 
		}
		else {
			xmlHttp.onreadystatechange=stateChange 
		}
			
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
}
function checkpaging1(slimit, elimit, currentpage)
	{
		var objdiv = 0;
		var searchobj = filepath.search('###');
		filepath = filepath;
		//alert(filepath)
		if (searchobj != -1)
		{
			objdiv = searchobj;
		}
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	

		var url	= filepath+"slimit="+slimit+"&elimit="+elimit+"&paging=yes&currentpage="+currentpage
		//alert(url)
		if (objdiv == 0)
		{
			xmlHttp.onreadystatechange=stateChanged 
		}
		else {
			xmlHttp.onreadystatechange=stateChange 
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
}
function recordsmanipulation(id,type1,slimit,elimit,path,currentpage)
{		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		if(type1=="delete"){
			var result = confirm("Are you sure you really want to Archieve this Record?")
		}
		if(result==true)
		{
			if(path==" "){
				path = " "
			}
			path = "&path="+path+"&currentpage="+currentpage;
			var url	= filepath+"id="+id+"&flag="+type1+"&slimit="+slimit+"&elimit="+elimit+path
			//alert(url);
			xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		else
		{
		return false;
		}

}

function navigate(phno,bid,cas) {
	
	if(cas=='tkey')
	{
		var key = document.getElementById('tkey').value;
	}
	else if(document.getElementById('access'))
	{
		//alert(document.getElementById('access').value);
		var key = document.getElementById('access').value;
	}
	if(cas=='pass')
	{
		//alert(document.getElementById('emailf').value);
		if(document.getElementById('emailf').value=='' || document.getElementById('emailf').value ==' ')
		{
//		 alert("Please enter email address");
		 document.getElementById('err').style.display = "block";
		document.getElementById('err').innerHTML = "Please enter a email address";

		 //document.getElementById('email').focus;
		 return;
		}
		else
		{
			if(validate_email(document.getElementById('emailf').value))
			{
			var email = document.getElementById('emailf').value;
			}
			else
			{
//			alert("Please enter a valid email address");
			document.getElementById('err').style.display = "block";
			document.getElementById('err').innerHTML = "Please enter a valid email address";

			return;
			}
		}
		
		var secq = document.getElementById('secqf').value;
		
		if(document.getElementById('secanswer').value=='')
		{
//		alert("Please enter security answer");
		document.getElementById('err').style.display = "block";
		document.getElementById('err').innerHTML = "Please enter security answer";

		document.getElementById('secanswer').focus();
		return;
		}
		else
		{
		var seca = document.getElementById('secanswer').value;
		}
		document.getElementById('loader').style.display="block";
		document.getElementById('access_pass').disabled=true;

	}
	else if(cas=='support')
	{
		if(document.getElementById('fname').value=='')
		{
//		alert('Please Enter Your Name');
		document.getElementById('errsupport').style.display = "block";
		document.getElementById('errsupport').innerHTML = 'Please Enter Your Name';

		document.getElementById('fname').focus();
		return;
		}
		else
		{
		var fname = document.getElementById('fname').value;
		}
		if(document.getElementById('femail').value=='')
		{
//			alert("Please enter your email address");
			document.getElementById('errsupport').style.display = "block";
			document.getElementById('errsupport').innerHTML = 'Please enter your email address';

			return;
		}
		else
		{
			if(validate_email(document.getElementById('femail').value))
			{
			var femail = document.getElementById('femail').value;
			}
			else
			{
//			alert("Please enter a valid email address");
			document.getElementById('errsupport').style.display = "block";
			document.getElementById('errsupport').innerHTML = 'Please enter a valid email address';

			return;
			}
		}
		if(document.getElementById('subject').value=='')
		{
//		alert('Please Enter Subject');
		document.getElementById('errsupport').style.display = "block";
		document.getElementById('errsupport').innerHTML = 'Please Enter Subject';

		document.getElementById('subject').focus();
		return;
		}
		else
		{
		var subject = document.getElementById('subject').value;
		}
		if(document.getElementById('comments').value=='')
		{
//		alert('Please Enter Comments');
		document.getElementById('errsupport').style.display = "block";
		document.getElementById('errsupport').innerHTML = 'Please Enter Comments';

		document.getElementById('comments').focus();
		return;
		}
		else
		{
		var comments = document.getElementById('comments').value;
		}
		
		document.getElementById('loader').style.display="block";
		document.getElementById('access_s').disabled=true;
	}
	else if(cas=='seca')
	{
		if(document.getElementById('emailf').value!='')
		{
			var em = document.getElementById('emailf').value;
			if(!validate_email(em))
			{
//				alert("Please enter valid email address");
				document.getElementById('err').style.display = "block";
				document.getElementById('err').innerHTML = "Please enter valid email address";

				document.getElementById('emailf').focus();
				return;
			}
		}
		else
		{
		return false;
		}
	}
	else if(cas=='tr')
	{
		if(key=='')
		{
			document.getElementById('errtr').style.display = "block";
			document.getElementById('errtr').innerHTML = "Please enter access key";
			document.getElementById('access').focus();
			return;
		}
	} 


	if(cas=='pass')
	{
	var url = filepath+"action=pass&email="+email+"&secq="+secq+"&seca="+seca;
	}
	else if(cas=='support')
	{
	var url = filepath+"action=support&email="+femail+"&name="+fname+"&subject="+subject+"&comments="+comments;
	}
	else if(cas=='seca')
	{
	var url = filepath+"action=seca&email="+em;
	}
	else
	{
	var url = filepath+"action=access&phno="+phno+"&bid="+bid+"&key="+key+"&cas="+cas;
	}
	//alert(url);
		 if(window.XMLHttpRequest) {
                req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
		//alert(req);
        req.open("GET", url, true);
		req.onreadystatechange = statuschangeAccesskey;
        req.send(null);
}
function validate_email(email)
{
	if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}
function statuschangeAccesskey() {   
		obj = document.getElementById("moreInfo");
		//var bid = document.getElementById(bid).value;
		if(document.getElementById('user_info_hidden')!=null)
		{
	    var phno = document.getElementById('user_info_hidden').value.split('#')[1];
		}
		
		if(req.readyState == 4) {
                if(req.status == 200) {
					   response = eval('('+req.responseText+')');
					   //alert(response.status[0].status.cas);
					   if(response.status[0].status.cas=='pass')
						{
						   if(response.status[0].status.res=='success')
							{
							alert(response.status[0].status.message);
							document.getElementById('moreInfo').style.display="none";
						   	document.getElementById('GrayOut').style.display="none";
							}
							else
							{
//							alert("Wrong Information");
//							document.getElementById('err').innerHTML = "Wrong Information";
							document.getElementById('err').innerHTML = "Wrong Information. Please try again.";
							document.getElementById('err').style.display = "block";
							document.getElementById('loader').style.display="none";
							document.getElementById('access_pass').disabled=false;
							}
					   }
					   else if(response.status[0].status.cas=='support')
						{
							 if(response.status[0].status.res=='success')
							{
							alert(response.status[0].status.message);
							document.getElementById('moreInfo').style.display="none";
						   	document.getElementById('GrayOut').style.display="none";
							}
							else
							{
							alert("Unable to sent mail");
							}
					   }
					   else if(response.status[0].status.cas=='seca')
						{
						if(response.status[0].status.res=='wrong')
						{
//						alert(response.status[0].status.message)
						document.getElementById('err').style.display = "block";
						document.getElementById('err').innerHTML = response.status[0].status.message;

						document.getElementById('secqf').value = '';
						}
						else
						{
						document.getElementById('err').style.display = "none";
						document.getElementById('secqf').value = response.status[0].status.message;
						document.getElementById('secanswer').focus();
						}
					   }

					else
					{
					    var stat = response.status[0].status.res;
						var bid = response.status[0].status.bid;
						var starttr = response.status[0].status.start;
						var endtr = response.status[0].status.end;
						var cas = response.status[0].status.cas;
					   if(stat == 'wrong')
						{
//					   alert("Wrong Access Key. Please Try Again");
					   document.getElementById('errtr').style.display = "block";
					   document.getElementById('errtr').innerHTML = "Wrong access key. Please try again";

					   }
					   if(stat == 'success')
						{
							if(cas == 'tr')
							{
							document.getElementById('link_'+bid).style.display = "block";
							document.getElementById('uname_'+bid).style.display = "none";
							document.getElementById('unlock_'+bid).style.display = "block";
							document.getElementById('lock_'+bid).style.display = "none";
							document.getElementById('viewlink_'+bid).style.display = "block";
							document.getElementById('view_'+bid).style.display = "none";

								//Browser specific
								if(navigator.appName == 'Microsoft Internet Explorer')
								{
									var nam = 'MSIE 6.0';
									if(typeof(navigator.appVersion.split(';')[1]) == typeof(nam))
									{
										if(document.getElementById('days'))
											document.getElementById('days').disabled = false;
										if(document.getElementById('uid'))
											document.getElementById('uid').disabled = false;
									}
								}
							}
							if(document.getElementById(bid)!=null)
							{
							//document.getElementById(bid).innerHTML  = '<tr id="'+response.status[0].status.bid+'"><td width="25%" align="left" valign="top" class="campaign_arrow"><a href="?q=user_track.php&uid='+response.status[0].status.phno+'&bid='+response.status[0].status.bid+'"><span class="user_arrowtext">'+response.status[0].status.user+'</span></a></td><td width="5%" align="left">&nbsp;&nbsp;<img src="images/unlock.png" width="22" heigth="22"/></td><td width="42%" align="center"><span class="innermenutextblacknormal"><b>Start:</b>'+starttr+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>End:</b>'+endtr+'</span></td></tr>';
							}
							else
							{
							document.getElementById('lock_'+bid).style.display = "none";
							document.getElementById('unlock_'+bid).style.display = "block";
							window.location.href = "http://itransmit.sapplica.com/?tkey="+response.status[0].status.tkey+"&flag=off";
//							window.location.href = "http://174.143.232.143/itransmit/?tkey="+response.status[0].status.tkey+"&flag=off";
							document.getElementById('unlock_'+bid).style.display = "block";

							}
						
							document.getElementById('moreInfo').style.display="none";
						   	document.getElementById('GrayOut').style.display="none";

					   }
                }}
				else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}
function alertSizew() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function alertSizeh() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}


function getaccessKey(phno,bid,cas)
{
		//alert(cas)
		if(cas=='tr')
		{
			if(navigator.appName == 'Microsoft Internet Explorer')
			{
			var nam = 'MSIE 6.0';
			//alert(typeof(navigator.appVersion.split(';')[1])
			//alert(document.getElementById('days'))
			if(typeof(navigator.appVersion.split(';')[1]) == typeof(nam))
			{
			document.getElementById('days').disabled = true;
			document.getElementById('uid').disabled = true;
			}
			}
		}
		//alert(phno)
		if(cas=='tkey')
		{
			var lbl = "Transmission";
			if(document.getElementById('tkey').value=='')
			{
			alert("Please Enter Transmit Key");
			return;
			}
			else
			{
				phno = document.getElementById('tkey').value;
			}
		}
		else
		{
			var lbl = "Access";
		}
		if(cas=='pass')
		{
			//alert(cas)
		var html='<table width="500px" height="100" border="0" cellpadding="3" bgcolor="#ffffff" cellpadding="0" style="font-size:12px;font-family:Arial;font-weight:normal;border:4px solid #9c9c9c; padding:3px; background:url(images/lightwindow_bg.jpg) bottom repeat-x #feffff;" >';
        html+='<tr><td height="10px" align="left" ><span style="font-size:18px; font-weight:bold;">Recover Password</span></b></td><td align="right"><a href="#" onclick=closepopup("moreInfo","'+cas+'") style="text-decoration:none;font-size:15px;font-weight:bold;color:#000;position:absolute;left:470px;top:6px;"><img src="images/close.gif" height="16" width="16" border="0" float="left"/></a></td></tr>';
		html+='<tr><td align="center" colspan="2"><div id="err" style="display:none;color:#FF8374"></div></td></tr>';

		html+='<tr><td align="right">Email ID:</td><td align="left"><input type="text" name="emailf" tabindex="1" size="20" id="emailf" style="background-color:#ffffff; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"  onblur="navigate(\'\',\'\',\'seca\')"/></td></tr>';
		html+='<tr><td align="right">Security Question:</td><td align="left"><input type="text" name="secqf" tabindex="2" size="20" id="secqf" style="background-color:#dbe0e3; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;" readonly/></td></tr>';
		html+='<tr><td align="right">Security Answer:</td><td align="left"><input type="text" name="secanswer" size="20" id="secanswer" style="background-color:#ffffff; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"/></td></tr>';
		html+='<tr><td></td><td colspan="2" align="left"><input type="button" name="access" id="access_pass" tabindex="3" style="background-color:#000000; border:1px solid #04597e; font-family:Arial, Helvetica, sans-serif; color:#FFFFFF; font-size:12px; font-weight:normal; cursor:pointer; width:70px; height:25px; padding-bottom:2px;" value="Submit" onclick="navigate(\'\',\'\',\''+cas+'\')">&nbsp;&nbsp;&nbsp;&nbsp;<span id="loader" style="display:none;padding-top:5px;padding-left:15px;"><img src="images/loader_small.gif" height="22" width="49"/></span></td></tr>';
		html+='</table>';
		}
		else if(cas=='support')
		{
		var html='<form action="ajax.php?action=support" name="myForm" method="post">';
		html='<table width="500px" height="270" border="0" cellpadding="3" style="font-size:12px;font-family:Arial;font-weight:normal;border:4px solid #9c9c9c; padding:3px; background:url(images/lightwindow_bg.jpg) bottom #feffff repeat-x;  " >';
        html+='<tr><td height="25px" align="left" ><span style="font-size:18px; font-weight:bold;">Contact Us</span></td><td align="right"><a href="#" onclick=closepopup("moreInfo") style="text-decoration:none;font-size:15px;font-weight:bold;color:#000;position:absolute;left:470px;top:6px;"><img src="images/close.gif" height="16" width="16" border="0" float="left"/></a></td></tr>';
		html+='<tr><td align="center" colspan="2"><div id="errsupport" style="display:none;color:#FF8374;"></div></td></tr>';

		html+='<tr><td align="right">Name:</td><td align="left"><input type="text" name="fname" size="20" id="fname" style="background-color:#ffffff; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"/></td></tr>';
		html+='<tr><td align="right">Email ID:</td><td align="left"><input type="text" name="femail" size="20" id="femail" style="background-color:#ffffff; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"/></td></tr>';
		html+='<tr><td align="right">Subject:</td><td align="left"><input type="text" name="subject" size="20" id="subject" style="background-color:#ffffff; border:1px solid #72c9ed; width:200px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"/></td></tr>';
		html+='<tr><td align="right" valign="top" valign="bottom">Comments:</td><td align="left" vlign="top"><textarea name="comments" id="comments" style="background-color:#ffffff; border:1px solid #72c9ed; width:300px; height:100px; vertical-align:top; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;';
		html+='onkeypress="leftChar(id,value,2);"  onkeyup="leftChar(id,value,2);"></textarea><br/>(up to <span name="remLen" id="leftcharcomments" style="background-color:Transparent;border:none; font-family:Arial,Helvetica,sans-serif; width:4px; color:#000000; font-size:12px;">125</span> characters)';
		html+='</td></tr>';
		html+='<tr><td></td><td colspan="3" align="left"><input type="submit" name="access" id="access_s" style="background-color:#000000; border:1px solid #04597e; font-family:Arial, Helvetica, sans-serif; color:#FFFFFF; font-size:12px; font-weight:normal; cursor:pointer; width:70px; height:25px; padding-bottom:2px;float:left;" value="Submit" onclick="navigate(\'\',\'\',\''+cas+'\')"><span id="loader" style="display:none; margin-left:5px;"><img src="images/loader_small.gif" height="22" width="49" border="0"/></span></td></tr>';
		html+='</table>';
		html+='</form>';
		}
		else if(cas=='help')
		{
		var html='<table width="500px" height="400" border="0" cellpadding="3" style="font-size:12px;font-family:Arial;font-weight:normal;border:4px solid #9c9c9c; padding:3px; background:url(images/lightwindow_bg.jpg) bottom #feffff repeat-x;  " >';
        html+='<tr><td height="20px" align="left" ><span style="font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:20px; font-weight:bold;">How to use itransmit?<span></td><td align="right"><a href="#" onclick=closepopup("moreInfo","'+cas+'") style="text-decoration:none;font-size:15px;font-weight:bold;color:#000;position:absolute;left:470px;top:6px;"><img src="images/close.gif" height="16" width="16" border="0" float="left"/></a></td></tr>';
		html+='<tr><td height="25px" align="left" colspan="2">';
		html+='<table><tr><td><div style="overflow:scroll; overflow-x:hidden; height:400px;"><p><span style="font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:14px; font-weight:bold;">itransmit requirements on iphone:</span><br /><br /><a class="arrow_text">Once the application is installed, you are requested to provide the following &nbsp;&nbsp;&nbsp;&nbsp;details :</a><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a. Phone Number (required).<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b. Your Name.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c. AccessKey.<br /><br /><span style="font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:14px; font-weight:bold;">How to Broadcast your location using iPhone :</span><br /><br /><a class="arrow_text">Creation of groups can be done through settings.</a><br /><br /><a class="arrow_text">Broadcast your location to anyone by clicking on "New" button you will navigated &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to new screen where you can add the contacts from the phone book, or the &nbsp;&nbsp;&nbsp;&nbsp;group memebers created by you.</a><br /><br /><a class="arrow_text">After adding the contacts, if you want to protect your location switch on accesskey.</a><br /><br /><a class="arrow_text">Automatic updation of your current location will be done based on frequency &nbsp;&nbsp;&nbsp;&nbsp;choosen by you.</a></a><br /><br /><a class="arrow_text">Now you can turn on the transmit switch to broadcast your location.</a><br /><br /><a class="arrow_text">You can also send small text messages to the contacts.</a><br /><br /><a class="arrow_text">You can also send the unique web link that is generated for each and every &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;broadcast.</a><br /><br/><span style="font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:14px; font-weight:bold;">How to Track others locations using iPhone:</span><br /><br /><a class="arrow_text">Clicking on "Track" button which will show you the list of broadcasters.</a><br /><br /><a class="arrow_text">Clicking on each and every broadcaster will give their locations in detail and they &nbsp;&nbsp;&nbsp;&nbsp;are shown on the map.</a><br /><br /><a class="arrow_text">Rotate iPhone to view the map in fullView mode.</a><br /><br /><span style="font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:14px; font-weight:bold;">How to Track others using website:</span><br /><br /><a class="arrow_text">Sign in to itransmit.<br/></a><br /><a class="arrow_text">Go to "Home" to know the information about last 10 recent transmitters, and &nbsp;&nbsp;&nbsp;&nbsp;messages. </a><br /><br /><a class="arrow_text">To know about all the transmissions sent to you click on "Track", each and every &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transmission provides the list of locations with MAP view. </a><br /><br /><a class="arrow_text">If Transmitter has locked his location, you can unlock only by getting the &nbsp;&nbsp;&nbsp;&nbsp;access key from the transmitter. </a><br /><br /><a class="arrow_text">If transmitter sends message to your mailbox, you can track easily either by &nbsp;&nbsp;&nbsp;&nbsp;clicking on the link provided or enter the transmit key where prompted on the &nbsp;&nbsp;&nbsp;&nbsp;portal.</a><br /></p></div</td></tr></table>';
		html+='</td></tr>';

		html+='</table>';

		}
		else
		{
		var html='<table width="500px" height="100%" border="0" cellpadding="3" style="font-size:12px;font-family:Arial;font-weight:normal;border:4px solid #9c9c9c; padding:3px; background:url(images/lightwindow_bg.jpg) bottom #f3f4f6 repeat-x;" >';
        html+='<tr><td height="10px" align="left" ><span style="font-size:18px; font-weight:bold;">Required '+lbl+' Key</span></td><td align="right"><a href="#" onclick=closepopup("moreInfo","'+cas+'") style="text-decoration:none;font-size:15px;font-weight:bold;color:#000;position:absolute;left:472px;top:6px;"><img src="images/close.gif" height="16" width="16" border="0" float="left"/></a></td></tr>';
		html+='<tr><td align="center" vllign="middle" colspan="2"><div id="errtr" style="display:none;color:#FF8374;"></div></td></tr>';

		html+='<tr><td align="right" vllign="middle">'+lbl+' Key:</td><td align="left"><input type="text" name="access" size="20" id="access" style="background-color:Transparent; border:1px solid #33c4ff; width:153px; height:16px; padding:3px; font-family:Arial, Helvetica, sans-serif; color:#000000; font-size:12px;"></td></tr>';
		html+='<tr><td></td><td colspan="2" align="left"><input type="button" name="access"  style="background-color:#000000; border:1px solid #04597e; font-family:Arial, Helvetica, sans-serif; color:#FFFFFF; font-size:12px; font-weight:normal; cursor:pointer; width:70px; height:25px; padding-bottom:2px;" value="Submit" onclick="navigate('+phno+','+bid+',\''+cas+'\')"></td></tr>';
		html+='</table>';
		}
        document.getElementById('moreInfo').innerHTML = html;
		document.getElementById('GrayOut').style.display="block";
        var x,y;
        var test1 = document.body.scrollHeight;
        var test2 = document.body.offsetHeight
			
        if (test1 > test2) // all but Explorer Mac
        {
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		}
        else // Explorer Mac;//would also work in Explorer 6 Strict, Mozilla and Safari
        {
			
			/*if(navigator.appName == 'Microsoft Internet Explorer')
			{
				var nam = 'MSIE 6.0';
				if(typeof(navigator.appVersion.split(';')[1]) == typeof(nam))
				{
					//x = alertSizew();
					//y = alertSizeh();
				    
					//x=screen.width;
					//y=screen.height; 
					
					x = document.body.offsetWidth;
					y = document.body.offsetHeight;
				   document.getElementById('GrayOut').style.position="absolute";	  
				}
			}
			else
			{
		   		//x = document.body.offsetWidth;
				//y = document.body.offsetHeight;
				//x = alertSizew();
				//y = alertSizeh();
				x=screen.width;
				y=screen.height; 
			}
		  */
		   if(screen.width == 1024){
				
				x = document.body.scrollWidth;
				y = document.body.scrollHeight;
			}else{
				
				x=screen.width;
			    y=screen.height; 
		
			 }
		   //x=screen.width;
		   //y=screen.height; 
		  // x = document.body.offsetWidth;
          //y = document.body.offsetHeight;
		   
        }
		document.getElementById('GrayOut').style.width=x+'px';
        document.getElementById('GrayOut').style.height=y+'px';

        document.getElementById('moreInfo').style.display="block";
 /*       document.getElementById('moreInfo').style.top=Math.ceil(Math.ceil(screen.height/2)/3)+'px';
//       document.getElementById('moreInfo').style.top='500px';
        document.getElementById('moreInfo').style.left=Math.ceil(Math.ceil(screen.width/2)/2)+'px';
 */
		 document.getElementById('moreInfo').style.top=Math.ceil(Math.ceil(screen.height/2)/4)+40;
        //alert(Math.ceil(screen.width)/4);//Math.ceil(Math.ceil(screen.width/4))'212px'
        document.getElementById('moreInfo').style.left=(screen.width-600)/2+'px';

	    

}

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}



	function leftChar(id,value,flag)
		{   

			var maxlength;
			if(flag==1)
			{
				maxlength=30;
			}
			else if(flag==2)
			{
				maxlength=125;
			}
			else if(flag==3)
			{
				maxlength=1000;
			}
			else if(flag==4)
			{
				maxlength=150;
			}
					var chars=maxlength-parseInt(document.getElementById(id).value.length);	
					 var lable_mess_div=document.getElementById("lable_mess_div");
					 var  lable_mess= document.getElementById("lable_mess");
			if(flag==2)
			{
				if(chars<=0)
					{
						alert("Please limit to less than "+maxlength+" characters");
						document.getElementById(id).value=document.getElementById(id).value.substring(0,maxlength);
						document.getElementById('leftchar'+id).value=0;
						return false;
					}
					else
					{
						document.getElementById('leftchar'+id).innerHTML=chars;
					}

			}
			else
			{
					if(chars<=0)
					{
						
						alert("Please limit to less than "+maxlength+" characters");
						document.getElementById(id).value=document.getElementById(id).value.substring(0,maxlength);
						document.getElementById('leftchar'+id).value=0;
						return false;
					}
					else
					{
						document.getElementById('leftchar'+id).value=chars;
					}
			}
		}
function closepopup(id,cas)
{
    document.getElementById('GrayOut').style.display='none';
    document.getElementById(id).style.display='none';
	//alert(cas)
	if(cas=='tr')
	{
	    if(navigator.appName == 'Microsoft Internet Explorer')
		{
			var nam = 'MSIE 6.0';
			if(typeof(navigator.appVersion.split(';')[1]) == typeof(nam))
			{
				
				if(document.getElementById('days')!='null')
				{
				document.getElementById('days').disabled = false;
				}
				if(document.getElementById('uid')!='null')
				{
				document.getElementById('uid').disabled = false;
				}
			}
		}
	}

}

function check(id)
	{
		if(id == 'user_email')
			var email_id=document.getElementById(id).value;
		if(id == 'phno')
			var phno=document.getElementById(id).value;
//		xmlHttp=GetXmlHttpObject();
		if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	
		
		var url="";
		if(id == 'user_email')
			url=filepath3+'email='+email_id;
		if(id == 'phno')
			url=filepath3+'phno='+phno;
		
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4 )
		  {
			var abc=xmlHttp.responseText.replace(/\n/,'');
			 var res=abc.split("#");
//alert("x\ny"+abc);
//alert("x\ny"+xmlHttp.responseText);
//alert(xmlHttp.readyState+"$$"+xmlHttp.status+"@"+escape(res[0])+"res"+res[1]);
var res1=res[0];
var res2=res[1];

		   if(res1 == "true"){
			   if(res2 == "email"){
				   document.getElementById("error_message_div").style.display="block";
				   document.getElementById("error_message_div").innerHTML="<b>'"+email_id+"' This Primary Email already exist!</b>";
				   document.getElementById('user_email').value = "";
			   }
			   if(res2 == "phone"){
				   document.getElementById("error_message_div2").style.display="block";
				   document.getElementById("error_message_div2").innerHTML="<b>'"+phno+"' This Phone No already exist!</b>";
				   document.getElementById('phno').value = "";
			   }
		   }
		   if(res1 == "false"){
			   if(res2 == "email"){
				   document.getElementById("error_message_div").style.display="none";
				   document.getElementById("error_message_div").innerHTML=" ";			   
				}
				 if(res2 == "phone"){
				   document.getElementById("error_message_div2").style.display="none";
				   document.getElementById("error_message_div2").innerHTML=" ";			   
				}
		   }
		}
	}
//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function checkCaptcha(captcha,id){
if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	


		var url="";
		if(id == 'security_code')
			url=filepath+'action=cap&security_code='+captcha;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState==200){
			response = eval('('+xmlHttp.responseText+')');
			//alert(response.status[0].status.cas);
			if(response.status[0].status.cas=='cap')
			{
				if(response.status[0].status.res=='success'){
				document.getElementById('captchaError').style.display = 'none';
				}else if(response.status[0].status.res=='wrong'){
				document.getElementById('captchaError').innerHTML = response.status[0].status.message;
				document.getElementById('captchaError').style.display = 'block';
				document.getElementById('security_code').value = '';
				refreshCaptcha('wrong');
				}else{
				document.getElementById('captchaError').innerHTML = response.status[0].status.message;
				document.getElementById('captchaError').style.display = 'block';
				}
			}

		}
		
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function refreshCaptcha(arg)
{
	if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	


		var url="";
			url=filepath+'action=caprefresh';
	
		xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4 || xmlHttp.readyState==200){
			response = eval('('+xmlHttp.responseText+')');
			if(response.status[0].status.cas=='caprefresh')
			{
				if(arg != 'wrong'){
			if(document.getElementById('captchaError'))
				document.getElementById('captchaError').style.display = 'none';
				}
			img = document.getElementById('imgCaptcha'); 
			img.src = 'captcha/CaptchaSecurityImages.php?' + Math.random();
			document.getElementById('security_code').value = '';
			}

		}
		
		}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	

}
