function 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 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=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 swapImage() { //v3.0

  var i,j=0,x,a=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; 

		//alert(x.src);

		if(!x.oSrc) 

			x.oSrc=x.src;

		x.src=a[i+2];

			//alert(x.src);

		}

   //alert(1);

}



function select_all_action()

{

	search_str=document.getElementById('search').value;

	//alert('search_str');

	//return true;

	

	if(search_str!='')

		{

		return true;

		}

	else{

		alert('Type a text');

		return false;

		}

}

function focus_event(){

document.getElementById('search').value='';	

	

}



function focus_event2(){



document.getElementById('email_address').value='';	

}



function get_pageinfo(){

	div='email_address';

	commondiv = div;

	//fname=document.getElementById('fname').value;

	//lname=document.getElementById('lname').value;

	email_address=document.getElementById('email_address').value;	
	var email = document.getElementById('email_address');
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email.value)) {
		alert('Please provide a valid email address');
		//document.getElementById(div).innerHTML = xmlhttp.responseText;	
		email.focus
		return false;
		}
	
	page="subscribe.php"+"?" +"email_address="+email_address;

	//alert(page);

	var response = load_form(page)

	document.getElementById(div).innerHTML = xmlhttp.responseText;	

	document.getElementById('email_address').value= xmlhttp.responseText;	

}



function get_pageinfo2(){

	div='hmw_ltext2';

	commondiv = div;

	fname=document.getElementById('fname').value;

	lname=document.getElementById('lname').value;

	hmw_ltext2=document.getElementById('hmw_ltext2').value;	

	email_address=document.getElementById('email_address').value;	

	page="subscribe.php"+"?" + "fname="+fname+"&"+"lname="+lname+"&"+"email_address="+email_address;

	//alert(page);

	var response = load_form(page)

	//alert(xmlhttp.responseText);

	document.getElementById(div).innerHTML = xmlhttp.responseText;	

	document.getElementById('hmw_ltext2').value= xmlhttp.responseText;	

}









function load_form(page)



{  

	xmlhttp= (window.XMLHttpRequest ? new XMLHttpRequest(): ((window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null) );



	xmlhttp.onreadystatechange = state_change;

    xmlhttp.open("GET",page,false)



	xmlhttp.send(null);

	//alert (xmlhttp.responseText)

	return (xmlhttp.responseText);



}



	



function state_change()

{

  if (xmlhttp.readyState==4)

  {

	



  }

}

function openPopUp(URL) {

day = new Date();

id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=800,height=600,left = 50,top = 50');");

}



function openPopUp2(URL) {

day = new Date();

id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=500,height=300,left = 50,top = 50');");

}



 function addAddressToMap(address_field) {

 //map.clearOverlays();

 	//

	address = document.getElementById(address_field).value

	//alert(address);

   	geocoder = new GClientGeocoder();

    geocoder.getLocations(address, function(response){

      	if (!response || response.Status.code != 200) {

        	//alert("Sorry, we were unable to geocode that address");

			//document.getElementById('form_add').submit();

			return true;

      		} 

		else {

        		place = response.Placemark[0];



				//alert(place.Point.coordinates[1] +"   " +place.Point.coordinates[0])

				document.getElementById('xcod').value = place.Point.coordinates[1];

				document.getElementById('ycod').value = place.Point.coordinates[0];

				document.getElementById('upload_data').value = place.Point.coordinates[0];

				//alert(document.getElementById('celeb_description').value);

				//alert(place.Point.coordinates[1]);

				//document.form_mugshot.submit();

				//alert()

				

				return false;

			}

      });

    }

	