function GI(id) { return document.getElementById(id); }

function GN(name) { return document.getElementsByName(name); }

function DW(str) { document.write(str); }

function getOs()
{
  var browser = navigator.appName;
  var b_version = navigator.appVersion;
  var version = b_version.split(";"); 
  var trim_Version = version[1].replace(/[   ]/g,"");   
  if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") return 6;
  if(navigator.userAgent.indexOf("MSIE")>0) return 1;
  if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)  return 2;
  if(isSafari=navigator.userAgent.indexOf("Safari")>0)  return 3;
  if(isCamino=navigator.userAgent.indexOf("Camino")>0)  return 4;
  if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0) return 5;
  return 7;
}

function Ion_trim(sInputString,iType){
	var sTmpStr = ' ';
	var i = -1;
	if (iType==3){
		while(sInputString.indexOf(" ")!=-1)sInputString=sInputString.replace(" ","");
		return sInputString;
	}
	if(iType==0 || iType == 1) {
		while(sTmpStr==' '){
			++i;
			sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(i);
	}
	if(iType==0 ||iType==2){
		sTmpStr=' ';
		i = sInputString.length;
		while(sTmpStr == ' '){
			--i;
			sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(0,i+1);
	}
	return sInputString;
}

function DrawImage(ImgD,w,h)
{
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		if(image.width/image.height>= w/h)
		{
			if(image.width>w)
			{
			  ImgD.width=w;
			  ImgD.height=(image.height*w)/image.width;
			}
			else
			{
			  ImgD.width=image.width;
			  ImgD.height=image.height;
			}
		}
		else
		{
			if(h==0)
			{
			  if(image.width > w)
			  {
			    ImgD.width = w;
			    ImgD.height = (w/image.width)*image.height;
			  }
			  else
			  {
			    ImgD.width=image.width;
				  ImgD.height=image.height;
			  }
			}
			else
			{
			  if(image.height>h)
			  {
				  ImgD.height=h;
				  ImgD.width=(image.width*h)/image.height;
			  }
			  else
			  {
				  ImgD.width=image.width;
				  ImgD.height=image.height;
			  }
			}
		}
	}
}

function replaceAll(str,oldStr,reStr)
{
	return str.split(oldStr).join(reStr);
}

function GoPage(url, oId, totalPages)
{
	var pageId = GI(oId).value;
	if(pageId<1)
		pageId = 1;
	else if(pageId>totalPages)
		pageId = totalPages;
	
	location.href = url + (url.indexOf("?")==-1 ? "?" : "&") + "pageId=" + pageId;
}

function ErrorImg(o)
{
	o.style.display = "none";
}

function ErrorImgX(o, version)
{
	o.src = "/images/"+ version +"/ImgNone.gif";
}

function NoImg(o, version)
{
	o.src = "/images/"+ version +"/ImgNone.gif";
}

function HAS(idstr)
{
	alert(idstr);
	var obj = document.getElementById(idstr);
  if(obj.style.display=="none")
    obj.style.display = "";
  else
    obj.style.display = "none";
}

function IndexRight(flag)
{
	for(var i=0; i<7; i++)	
	{
		if(GI("r_c_" + i)!=null)
			GI("r_c_" + i).style.display = "none";	
	}
	GI("r_c_" + flag).style.display = "";
}

function LoginSubmit(msgA, msgB)
{
	var uV = GI("_username").value;
	var pV = GI("_password").value;
	if(uV=="")
	{
		alert(msgA);	
		return;
	}
	else if(pV=="")
	{
		alert(msgB);	
		return;
	}
	LoginForm.username.value = uV;
	LoginForm.password.value = pV;
	LoginForm.submit();
}

function ShowMoreProduct()
{
	GI("moreProduct_0").style.display = "none";
	GI("moreProduct_1").style.display = "";
}

function SearchNavPos(p2, oid)
{
	var p1 = GI(oid).options[GI(oid).selectedIndex].value;
	var url = "http://wap.gyxgps.com/web?p1="+ p1 +"&p2=" + p2;
	//alert(url);
	GI("mapFrame").src = url;
}