function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;

    elements.push(element);
  }

  return elements;
}
 

function $F(element)
{
	 return $(element).value;
}
function $I(element)
{
	 return $(element).innerHTML;
}
function js_request(par)
{
	var thisLocation;
	var tmpStr1;
	var Arr2=new Array();
	var expKey;
	var outString;
	
	
	lct=window.location.toString();
	
	
	var tmpArr1=lct.split("?");
	tmpStr1=tmpArr1[tmpArr1.length-1];
	Arr2=tmpStr1.split("&");
	for (i=0;i<Arr2.length;i++)
	{
		
		expKey=eval("/^"+par+"\\s*\\=/");
		if (expKey.test(Arr2[i]))
		{
			
			outString=Arr2[i].replace(expKey,"");
			outString=outString.replace(/\%20/g," ");
			outString=unescape(outString);
			return outString;
		}

	}
	return "";
}

function Request(par)
{
	var thisLocation;
	var tmpStr1="";
	var Arr2=new Array();
	var expKey;
	var outString;
	lct=window.location.toString();
	lct=unescape(unescape(lct));
	lct=lct.replace("[|L]","\/")
	lct=lct.replace("[|R]","\\")
	var tmpArr1=lct.split("?");
	for (i=1;i<tmpArr1.length;i++)
	{
		tmpStr1+=tmpArr1[i]+"?";
	}
	tmpStr1=tmpStr1.substr(0,tmpStr1.length-1)
	Arr2=tmpStr1.split("&");
	for (i=0;i<Arr2.length;i++)
	{
		expKey=eval("/^"+par+"\\s*\\=/");
		if (expKey.test(Arr2[i]))
		{
			
			outString=Arr2[i].replace(expKey,"");
			outString=outString.replace(/\%20/g," ");
			return outString;
		}

	}
	return "";
}

////////////////function pop message box
function RIT_popMsg(url,width,height,buttontype,msg,msgtype)
{    
     //alert(msg)
	 //return
	
	//var isDoingThing=window.external.IsPendClose()
	//window.external.PendClose(false);
	window.external.SetStaticData(msg);
	var returnStr;
	if (msgtype!="" && msg!="")
	{
		if (msgtype=="confirm")
		{
			//window.external.SetStaticData("");
			window.external.ShowChild("reg/alertmsg.htm?msg=a&width="+width+"&height="+height+"&msgtype="+msgtype, width, height);
			returnStr=window.external.GetStaticData();
			//window.external.PendClose(isDoingThing);
			return returnStr;
		}
		if (msgtype=="okcancel")
		{
			//window.external.SetStaticData("");
			window.external.ShowChild("reg/alertmsg.htm?msg=a&width="+width+"&height="+height+"&msgtype="+msgtype, width, height);
			returnStr=window.external.GetStaticData();
			//window.external.PendClose(isDoingThing);
			return returnStr;
		}
		else if(msgtype=="tryagain")
		{
			//window.external.SetStaticData("");
			window.external.ShowChild("reg/alertmsg.htm?msg=a&width="+width+"&height="+height+"&msgtype="+msgtype, width, height);
			returnStr=window.external.GetStaticData();
			//window.external.PendClose(isDoingThing);
			return returnStr;	
		}
		else
		{
			window.external.ShowChild("reg/alertmsg.htm?msg=a&width="+width+"&height="+height+"&msgtype="+msgtype, width, height);
			//window.external.Navigate("mainui/about.htm",320,420)
		}
	}
	else
	{
		window.external.ShowChild(url, width, height);
	}
	//window.external.PendClose(isDoingThing);
	return "";
}
//////////////////////////////////////





/////////////////////
//Cut string(get short string)
//////////////////////
function getCuttedString(str,len,leftLen)
{
	if (str.length<=len)
	{
		return str;
	}
	else
	{
		rightLen=len-leftLen;
		leftStr=str.substr(0,leftLen);
		rightStr=str.substr(str.length-rightLen,rightLen)
		return (leftStr+"..."+rightStr);
	}
}
var xmlStringAgent=function()
{
	this.attachVar=function(name,value)
	{
		value = value.replace(/\"/gi,"\\\"");
		eval("this."+name+"=\""+value+"\"")
	}
}
function analyseXml(str)
{
	var innerStr;
	var XSA=new xmlStringAgent();
	str=str.replace(/^\s+/,'');
	str=str.replace(/\s+$/,'');
	var arrtmp=str.match(/\<([\w\s]+)\>([^\<]+)\<\/\1\>/);
	while (arrtmp!=null)
	{
		str=str.replace(/\<([\w\s]+)\>[^\<]+\<\/\1\>/,"");
		XSA.attachVar(arrtmp[1],arrtmp[2]);
		arrtmp=str.match(/\<([\w\s]+)\>([^\<]+)\<\/\1\>/);
	}
	return XSA;
}
var XMLDOM = function(loadxml,parentNode)
{
	this.xmlDoc = new ActiveXObject("Microsoft.xmldom");
	this.xmlDoc.loadXML(loadxml);
	this.GetNode=function(nodename)
	{
		if(parentNode.length>0)
		{
			nodename=parentNode+"/"+nodename;
		}
		var rv=this.xmlDoc.selectSingleNode(nodename).text;
		return rv;
	}
	this.SetNode=function(nodename,value)
	{
		if(parentNode.length>0)
		{
			nodename=parentNode+"/"+nodename;
		}
		this.xmlDoc.selectSingleNode(nodename).text=value;
		//alert(value);
	}
	this.getXmlString=function()
	{
		return this.xmlDoc.xml;
	}
	//this.xml=this.xmlDoc.xml;
}

function getbgimg(imgnum)
{
	var pid = window.external.GetProductID();
	pid = pid.toUpperCase();
	switch(pid)
	{
		case "FARSTONE_VDP11":
		return "url(img/vd"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_VDPRO11":
		return "url(img/vdp"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_DCP3":
		return "url(img/dc"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_DCPRO03":
		return "url(img/dcp"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_DCSERVER":
		return "url(img/dcs"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_DCN03":
		return "url(img/dcn"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_RITP8":
		return "url(img/rit"+imgnum+langid+".jpg)";
		break;
		case "FARSTONE_RIT08":
		return "url(img/rit"+imgnum+langid+".jpg)";
		break;	
		case "FARSTONE_VHDPRO02":
		return "url(img/vhdpro"+imgnum+langid+".jpg)";
		break;
	}
}

