var rootdomain="http://"+window.location.hostname;

function ajaxinclude(url) {
	var page_request = false;

	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){}
		}
	}else
		return false;

	page_request.open('GET', url, false);
	page_request.send(null);
	writecontent(page_request);
}

function writecontent(page_request){
	if (window.location.href.indexOf("http")==-1 || page_request.status==200)
		document.write(page_request.responseText)
}

function selectcountry(val,val1,val2){
	if(val=='US'){
	document.getElementById(val1).style.display="none";
	document.getElementById(val2).style.display="block";	
	}else{		
	document.getElementById(val1).style.display="block";
	document.getElementById(val2).style.display="none";	
	}
}

function getCompetitorDetails(competitorModelId, hubcityModelId, productId, drawingId) {
	window.location = "competitordetails.do?invoke=getCompetitorDetails&competitorModelId="+competitorModelId+"&hubcityModelId="+hubcityModelId+"&productId="+productId+"&drawingId="+drawingId;
}

function searchnum(){		
	val=document.getElementById('competitorNo').value;
	
	if(val=="" || val== null){
		alert('Please enter Competitors\'s\ Number ')
		document.getElementById('competitorNo').focus();
		return false;
	}
	else {
		document.forms[0].submit();
	}
}
	
/************** Check All Related  function start *****/
function checkAll(obj,objName){
    var masCheck= obj.checked;
    var Ad_List=document.getElementsByName(objName);
    if(masCheck == true){
      for (var i=0;i<Ad_List.length;i++)  {
         if (Ad_List[i].checked == false && Ad_List[i].disabled == false) {
            Ad_List[i].checked = true				
         }
      }
    }else{
       for (var i=0;i<Ad_List.length;i++)  {
         if (Ad_List[i].checked == true ) {
            Ad_List[i].checked = false;				
         }
       }
    }
    return true;
}


function deselectTopCheckBox(objVal,topCheckBox){
    if(!objVal.checked)  
             topCheckBox.checked=false;
}

function setSelectedProducts(sSelectedProducts){
	var gfield = document.forms[0].gearProducts;

	if(gfield.length > 0 ){
		for(i=0;i<gfield.length; i++)
		{
			if(sSelectedProducts.indexOf(gfield[i].value) != -1)
				gfield[i].checked=true;
		}
	}else{
		if(sSelectedProducts.indexOf(gfield.value) != -1)
				gfield.checked=true;
	}

	var bfield = document.forms[0].bearProducts;
	
	if(bfield.length > 0 ){
		for(j=0;j<bfield.length; j++)
		{
			if(sSelectedProducts.indexOf(bfield[j].value) != -1)
				bfield[j].checked=true;
		}
	}else{
		if(sSelectedProducts.indexOf(bfield.value) != -1)
				bfield.checked=true;
	}
}


function validatedistributor(){
	
	if(document.DistributorsSearchForm.country.value=='US'){
		
		if(document.DistributorsSearchForm.zip.value==""){
			alert("Please enter Zip Code ");
		   document.DistributorsSearchForm.zip.focus();			
			return;
		}		
		
	}else if(document.DistributorsSearchForm.country.value=='Canada'){
				
		if(document.DistributorsSearchForm.czip1.value==""){
			alert("Please enter first three letters of Canada Zip Code ");
			 document.DistributorsSearchForm.czip1.focus();	
			 return;					
		}
		if(document.DistributorsSearchForm.czip2.value==""){
			alert("Please enter second three letters of Canada Zip Code ");
			 document.DistributorsSearchForm.czip2.focus();	
			 return;					
		}
		
	}
		
		document.DistributorsSearchForm.submit();
		
	
	
} 

	

