var postxml = null;
function postXML(pref,xmlstr,statefun) {
var rand_no = Math.random();
	rand_no = rand_no * 100000;
	rand_no = Math.ceil(rand_no);
	strurl = '/ajax.php?rand=' + rand_no + '&' + pref + '=1';
	if (JSglobal_SID != '') {
	strurl = strurl + "&sid=" + JSglobal_SID;	
	}
			postxml=null
			if (window.XMLHttpRequest) {
  		postxml=new XMLHttpRequest();
  		} else if (window.ActiveXObject) {
  		postxml=new ActiveXObject("Microsoft.XMLHTTP");
			}
			if (postxml!=null) {
			var params  = xmlstr;
  		postxml.onreadystatechange=statefun;
  		postxml.open("POST",strurl,true);
  		postxml.setRequestHeader("Content-type", "text/html");
			postxml.setRequestHeader("Content-length", params.length);
			postxml.setRequestHeader("Connection", "close");
  		postxml.send(params);
  		} else { alert("Data Error, please try again."); }

}
function http_submit(strurl) {
			var rand_no = Math.random();
			rand_no = rand_no * 100000;
			rand_no = Math.ceil(rand_no);
			strurl = strurl + "&rand=" + rand_no;
			xmlhttp=null
			if (window.XMLHttpRequest) {
  		xmlhttp=new XMLHttpRequest();
  		} else if (window.ActiveXObject) {
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			if (xmlhttp!=null) {
  		xmlhttp.onreadystatechange=state_Change;
  		xmlhttp.open("GET",strurl,true);
  		xmlhttp.send(null);
  		} else { alert("Data Error, please try again."); }
}
var cur_select = '';
function state_Change() {
			if (xmlhttp.readyState == 4) {
  		if (xmlhttp.status == 200) {
  			resp_text = xmlhttp.responseText;
  			xmllast = '';
  			if (resp_text == '1') {
				//Show Tick;
				document.getElementById('statusloc').src = '/images/your_location/bluetick.gif';
  			}
  			else if (resp_text == '0')
  			{
  			//Show Cross;
				document.getElementById('statusloc').src = '/images/your_location/redcross.gif';	
  			}
  			else
  			{
  			document.getElementById(cur_select).innerHTML = resp_text;
  			}
  			}
  		}
  		}
function getSelectVal(el) {
elm = document.getElementById(el);
if (elm.selectedIndex) {
elid = elm.options[elm.selectedIndex].value;
} else {elid = '';}
return elid;	
}
function getInputVal(el) {
return document.getElementById(el).value;
}
function cdata(val) {
return "<![" + "CDATA["	+ val + "]]" +  ">";
}

function setOpacity_fp(val,inter) {
	switch(inter) {
	case 1:
	elid = 'loc_arrow';
	break;
	case 2:
	elid = 'locstate';
	break;
	case 3:
	elid = 'locpostcode';
	break;
}
	document.getElementById(elid).style.opacity = val/10;
	document.getElementById(elid).style.filter = 'alpha(opacity=' + val*10 + ')';
}

function fader(updwn)  {
if (updwn == 'state') {
	var i = 0;
	document.getElementById('locstate').style.display = 'block';
	var m = 10;
	while (i < 11) {
		i++;
		setTimeout('setOpacity_fp('+i+',1)',100*i);
		setTimeout('setOpacity_fp('+i+',2)',100*i);
		setTimeout('setOpacity_fp('+m+',3)',100*i);
		m = m - 1;
	}
	document.getElementById('locpostcode').style.display = 'none';
}
else
{
	m = 10;
	i = 0;
	document.getElementById('locpostcode').style.display = 'block';
	while (-1 < m) {
		i++;
		setTimeout('setOpacity_fp('+m+',1)',100*i);
		setTimeout('setOpacity_fp('+m+',2)',100*i);
		setTimeout('setOpacity_fp('+i+',3)',100*i);
		m = m - 1;
	}
	document.getElementById('locstate').style.display = 'none';
}
}


function selectOption(elid, val) {
      for (var idx=0;idx<document.getElementById(elid).options.length;idx++) {
						if (val ==document.getElementById(elid).options[idx].value) {
            document.getElementById(elid).selectedIndex=idx;
          }
      }

}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.$";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function replaceQueryString(ur,param,value) {
	ur = ur.toString();
    var re = new RegExp("([?|&])" + param + "=.*?(&|$)","i");
    if (ur.match(re))
        return ur.replace(re,'$1' + param + "=" + value + '$2');
    else if (ur.indexOf("?") == -1)
        return ur + '?' + param + "=" + value;
    else
        return ur + '&' + param + "=" + value;
}