var xmlHttp;
var COUNTRY_MESSAGE="Select a Country";

function loadWidget(){
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert(HTTP_FAILURE);
        return;
    }
    xmlHttp.onreadystatechange = stateChanged;
    xmlHttp.open("GET", "http://tools.cisco.com/WWChannels/LOCATR/openWidgetAjax.do" , true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(null);
}

function stateChanged (){
	if (xmlHttp.readyState == 4 ) {
		if(xmlHttp.status == 200){
		var responseResult = xmlHttp.responseText;
	  	}
	  	document.getElementById("Widget").innerHTML=responseResult;
	}
}

function GetXmlHttpObject(handler) {
    var objXMLHttp = null;
    if (window.XMLHttpRequest) {
        objXMLHttp = new XMLHttpRequest();
    } else {
        if (window.ActiveXObject) {
            objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return objXMLHttp;
} 

function submitBasicSearch() {
		var countryValue;
		countryValue = document.getElementById("country").value;
		if(countryValue == ""){
    		alert(COUNTRY_MESSAGE);
    		return;
    	}
    	 var currentURL=document.location;
		 document.plSearchForm.widgetURL.value=currentURL;
		 document.plSearchForm.state.value = "";
	     document.plSearchForm.zip.value = "";
	     document.plSearchForm.city.value =document.plSearchForm.address.value;
	     document.plSearchForm.latitude.value = "";
         document.plSearchForm.longitude.value ="";		      
         document.plSearchForm.lonlatRequired.value  = "N";
	     document.plSearchForm.submit();
}