//Country Map common functions

function Region(rgnid, langid, rgnname){
	this.rgnid = rgnid;
	this.langid = langid;
	this.rgnname = rgnname;
}
  
function chooseRegion(){
	//alert("asdsa"+centerLangs2[parent.curLangPrefix]);
	var chr = " ";
	try{
	//if(parent.adjustIFrameSize){parent.adjustIFrameSize(window);}
	var chr =  centerLangs2[parent.curLangPrefix];
	if((chr==null) || (chr==undefined)){
		chr = " ";
	}
	}catch(err){
		chr = "Choose a Region below ..";
	}
	return chr;

}

function showRegion(rgncode){
	try{
	var spage = rnav[rgncode];
	if((spage==null) || (spage==undefined) || (spage == "[object Object]") ){
		alert("Invalid region");
	}else{  
	var pageName = parent.location.href;
	if(pageName.indexOf("?")>0){
	pageName = pageName.substring(0,pageName.indexOf("?"));
	}

 	 }
	parent.location.href = pageName + "?rgncode=" + rgncode;
	//showSmallPgae();
	//parent.contArea.location = "../common/"+spage;
	
	
	}catch(ee){
		//alert("Error :: "+ee.message);
	}	
}

function setRegions(){
		var selRgnCode = getURLParam("rgncode");
	var selContactCode = getURLParam("dealercontact");

	if(selRgnCode!="-1"){
		try{
		showRegionPages(selRgnCode);
		}catch(err){
			//alert("Error :: "+err.message);
		}
	}else if(selContactCode!="-1"){
		try{
		
		 var strHref = window.location.href;
		 var strQueryString = "";
  var hasPara=strHref.indexOf("?");
  if ( hasPara > -1 ){
    strQueryString = strHref.substr(strHref.indexOf("?"));
		}
		
		parent.contArea.location = "ContactDealer.html" + strQueryString;
		
		}catch(err){
			//alert("Error :: "+err.message);
		}
	}
}

function getURLParam(strParamName){
	 
  var strReturn = "-1"; 
  var strHref = window.location.href;
  var hasPara=strHref.indexOf("?");
  if ( hasPara > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }else{
	return "-1";	  
  }
  return unescape(strReturn);
}

function showRegionPages(rgncode){
	try{
	
	var spage = rnav[rgncode];
	if((spage==null) || (spage==undefined) || (spage == "[object Object]") ){
		alert("Invalid region");
	}else{
	
	showSmallPgae();
	parent.contArea.location = "../common/"+spage;
	}
	
	}catch(ee){
		//alert(ee.message);
	}	
}

function showSmallPgae(){
	try{
		parent.miniPage.location = "../common/"+countryspage;
	}
	catch(ee){
		
		}
	}




function iFrameHeight(){		
var minheight = 800;
try{
if(document.getElementById && !(document.all)) {
//alert(document.getElementById('contArea').contentDocument.body.offsetHeight);
h = document.getElementById('contArea').contentDocument.body.offsetHeight;	

if (h>minheight){		
document.getElementById('contArea').setAttribute("height", h);	
//document.getElementById('contExtra').setAttribute("height", h-400);	
}else{
	document.getElementById('contArea').setAttribute("height", minheight);
	}
}else if(document.all) {

	h =document.frames('contArea').document.body.scrollHeight;

	if(h>minheight){	
		document.all.contArea.style.height = h+100;
//		document.all.contArea.style.height = h-390;
	}else{
		document.all.contArea.style.height = minheight + 100;	
	}
}
}catch(ee){
//	alert(ee.message);
	}
}
function dealerContact(urlPart){
 var pageURL = "";
	try{
	var strHref = parent.location.href;
	  var hasPara=strHref.indexOf("?");
	if ( hasPara > -1 ){
		strHref = strHref.substring(0,strHref.indexOf("?"));	
	  }
	if(strHref.indexOf("www.gps-buddy.com")>-1){		
		 pageURL=  strHref.replace("http://www.gps-buddy.com/site/", "http://web.gps-buddy.com:8080/gpsweb/front/"); 
		}else{ 	
		pageURL = strHref; 
		}
	 
	  
	
	
			parent.location.href= pageURL + "" + urlPart.substr(urlPart.indexOf("?")) + "&dealercontact=1" ;
		}catch(err){}
	} 