// JavaScript Document
	var address = "";
	
	
function GetMap()
	{
		map = new VEMap("myMap");
		map.LoadMap();
	}   

function Find(what,where)
	{
		address = where;
		 
		try
		{
			map.Find(what,where);
			//map.Find(null, where, null,null, 0, 20, true, true, true, true, onMoreResults);
			//map.Find(null, where);
		}
		catch(e)
		{
			alert(e.message);
		}
	}



function onMoreResults(a,b,c,d,e)
	{
		// show your location icon
		var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
		var icon = '<div style=\"background-color:transparent;width:24px;height:24px;\" >' +
				'<img src=\"images/resultsHome2.gif\" border=\"0\" alt=\"\"/></div>';
		shape.SetCustomIcon(icon);
		shape.SetTitle('Your location');
		shape.SetDescription(address);
		map.AddShape(shape);
	}	


function EmptyMe()
				{
					document.zipcode.email.value = "";
				}
				

if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlHttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }

var map = null;

function CallParentFind(what,where)
			  {
				 parent.Find(what,where);
			  }
			  
function ValidateMe()
{
	var zip = document.zipcode.zip.value;
	//var distance = document.zipcode.distance.value;
	var email = document.zipcode.email.value;
	var specialoffers = document.zipcode.specialoffers.checked;
	
	//zip validation
	if (document.zipcode.zip.value.length != 5)
	{
		alert('Please enter a 5 digit zip code');
		document.zipcode.zip.focus();
		return false;
	}
	if (isNaN(zip))
	{
		alert("Please enter numeric value");
		document.zipcode.zip.focus();
		return false;
	}
	
	if (document.zipcode.email.value.length > 0 && document.zipcode.email.value != "Enter Email Address")
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(email) == false)
		{
			alert ('Please enter valid email address');
			document.zipcode.email.focus();
			return false;
		}
		
	}
	
	GetMap();

	//Code for AJAX Implementation By Rajat
			
	if(email=="Enter Email Address"){email="";}
	
	
	var url="iframe_results1.php";
	var params = "zip=" + zip + "&email=" + email + "&specialoffers=" + specialoffers;	
	
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");	
		
		xmlHttp.onreadystatechange=function(){ 
		  if(xmlHttp.readyState == 4) 
		   { 
			 if(xmlHttp.status == 200)
			   {
			 
				 document.getElementById('iframedata').innerHTML=xmlHttp.responseText; 	
				 
				 $("a.nav").fancybox({'titleShow' : false,'padding' : 0,'width' : '40%','height' : '70%','autoDimensions' : true,'autoScale' : true,'scrolling' : false}); 
				 
  			   } 
		   }	
		}
		
		 xmlHttp.send(params);

}


function callparent_updated(sname,sadd,sid)
{
  CallParentFind(sname,sadd);
  
  var url='iframe_results2.php';
  var params = "storeid=" + sid;		
	
		xmlHttp.open("POST",url,true);
		
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		
		xmlHttp.onreadystatechange=function(){ 
			  if(xmlHttp.readyState == 4) 
			   { 
				 if(xmlHttp.status == 200)
				   {
				   //alert(xmlHttp.responseText);
					 document.getElementById('iframedata').innerHTML=xmlHttp.responseText; 	
					 
					  $("a.nav").fancybox({'titleShow' : false,'padding' : 0,'width' : '40%','height' : '70%','autoDimensions' : true,'autoScale' : true,'scrolling' : false}); 
							 
				   } 
			   }	
		}
		
		 
         xmlHttp.send(params); //Posting storeid to PHP File
  
  $.fancybox.close();
}  




function VisitMe(url)
{
	//parent.document.location = url;
	parent.document.location = "https://www.hyluniadirect.com/cgi/commerce.cgi?display=home";
	
}

function UpdateLink(url)
{
	parent.document.getElementById('mapIframe').src = url;
	return false;
}



