<!--
function loginprompt()
{
	document.form1.username.focus();
	alert("You can see our worldwide references only by password.\nIf this is your first time here, please register.\nIf you forgot your password, just click in Forget Password to get it back.");
	return false;
}

var lastThirdElemnet;
function changeSubStyle(obj)
{
    var objSubChild = obj.parentNode.getElementsByTagName("ul")[0];
    
    var isDisplay = objSubChild.style.display=="none";
    
    objSubChild.style.display = isDisplay?"block":"none";
    if(lastThirdElemnet!=null)
    {
        lastThirdElemnet.style.display = "none";
        lastThirdElemnet = null;
    }
    if(isDisplay)
    {
         lastThirdElemnet = objSubChild; 
    }
   
   
}
var LastLeftID = "";
function menuFix() {
var obj = document.getElementById("nav").getElementsByTagName("li");

for (var i=0; i<obj.length; i++) {
obj[i].onmouseover=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseDown=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseUp=function() {
   this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onmouseout=function() {
   this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
}
}
}
function DoMenu(emid)
{

var obj = document.getElementById(emid); 
obj.className = (obj.className.toLowerCase() == "expanded"?"collapsed":"expanded");
if((LastLeftID!="")&&(emid!=LastLeftID)) //关闭上一个Menu
{
document.getElementById(LastLeftID).className = "collapsed";
}
LastLeftID = emid;
}
function GetMenuID()
{
var MenuID="";
var _paramStr = new String(window.location.href);
var _sharpPos = _paramStr.indexOf("#");

if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1)
{
_paramStr = _paramStr.substring(_sharpPos + 1, _paramStr.length);
}
else
{
_paramStr = "";
}

if (_paramStr.length > 0)
{
var _paramArr = _paramStr.split("&");
if (_paramArr.length>0)
{
   var _paramKeyVal = _paramArr[0].split("=");
   if (_paramKeyVal.length>0)
   {
    MenuID = _paramKeyVal[1];
   }
}

}

if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID(); //*这两个function的顺序要注意一下，不然在Firefox里GetMenuID()不起效果
menuFix();

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//AJAX程序段开始

var xmlHttp;
//建立xmlHttp对象
function createXMLHttpRequest(){
	try{
		xmlHttp=new XMLHttpRequest(); 	//Firefox
	}
	catch(e){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");		//通用XML
	}
}
//开启发送
function startRequest(){
	createXMLHttpRequest();
	xmlHttp.onreadystatechange=StateChange;
	xSelect=document.getElementById("select");
	xSelection=xSelect.options[xSelect.selectedIndex].text;
	alert(xSelection);
	requesturl="feedbackproc.php?select="+xSelection;
	xmlHttp.open("GET",requesturl,true);
	xmlHttp.send(null);
}
//分类响应
function StateChange(){
	if(xmlHttp.readState==4){
		switch(xmlHttp.status){
			case 200:
				xmlDoc=xmlHttp.responseXML;
				xmlroot=xmlDoc.documentElement;
				alert('Complete!');
				switch (xmlroot.firstChild.nodeName){
					case 'scratch':
						ScratchSelect(xmlroot);
						break;
					case 'magnetic':
						MagneticSelect(xmlroot);
						break;
					case 'plastic':
						PlasticSelect(xmlroot);
						break;
					case 'lottery':
						LotterySelect(xmlroot);
						break;
					case 'fridge':
						FridgeSelect(xmlroot);
						break;
				}
				break;
			case 404:
				alert('Some Page may be MISSING! Please contact developers.');
				break;
			case 500:
				alert('Program Failure! Please contact developers.');
				break;
			case 503:
				alert('Server Down!');
				break;
		}
		}		
}

//递归式XML遍历充填表格程序。
function createElement(kind,type,name){
	var element=null;
	try{
		element=document.createElement("<"+kind+" type='"+type+"' name='"+name+"'>");
	} catch(e) {
      element = document.createElement(type);   
      element.name = name;  
	  element.type = type;
   }   
   return element;
}

function ExpoXML(root){
	alert('Function envolved.'+root.childNodes.length+root.childNodes(0).nodeName);
	for(i=0;i<=root.childNodes.length;i++){
		//alert("Times: "+i+"  And now turn to "+root.childNodes(i).nodeName);
		if(root.childNodes(i).nodeName=='main'){
			//alert(root.childNodes(i).getAttribute('insertin'));
			document.getElementById(root.childNodes(i).getAttribute('insertin')).innerHTML=root.childNodes(i).getAttribute('title');
			alert("main:"+root.childNodes(i).hasChildNodes());
			if(root.childNodes(i).hasChildNodes()){
				SelNodes='main[@title=\''+root.childNodes(i).getAttribute('title')+'\']';
				ExpoXML(root.selectSingleNode(SelNodes));
			}
		}
		if(root.childNodes(i).nodeName=='radioselect'){		
			var newradio=createElement("input","radio",root.childNodes(i).getAttribute("group"));
			newradio.setAttribute("id",root.childNodes(i).getAttribute("id"));
			newradio.setAttribute("value",root.childNodes(i).getAttribute("title"));
			document.getElementById(root.childNodes(i).getAttribute("insertin")).appendChild(newradio);
			var newradiotext=document.createTextNode(root.childNodes(i).getAttribute("title"));
			document.getElementById(root.childNodes(i).getAttribute("insertin")).appendChild(newradiotext);
			
			alert("radio:"+root.childNodes(i).hasChildNodes());
			if(root.childNodes(i).hasChildNodes()){
				SelNodes='radioselect[@title=\''+root.childNodes(i).getAttribute('title')+'\']';
				ExpoXML(root.selectSingleNode(SelNodes));
			}
		}
		if(root.childNodes(i).nodeName=='inputbox'){
			HtmlGen='<input type=\'text\' name=\''+root.childNodes(i).getAttribute('id')+'\' id=\''+root.childNodes(i).getAttribute('id')+'\' />';
			document.getElementById(root.childNodes(i).getAttribute('insertin')).innerHTML=HtmlGen;
			var newinput=createElement("input","text",root.childNodes(i).getAttribute("id"));
			newinput.setAttribute("id",root.childNodes(i).getAttribute("id"));
			document.getElementById(root.childNodes(i).getAttribute("insertin")).appendChild(newinput);
			
			alert("inputs:"+root.childNodes(i).hasChildNodes());
			if(root.childNodes(i).hasChildNodes()){
				SelNodes='inputbox[@id=\''+root.childNodes(i).getAttribute('id')+'\']';
				ExpoXML(root.selectSingleNode(SelNodes));
			}
		}
		if(root.childNodes(i).nodeName=='selection'){
			var newselect=document.createElement("select");
			newselect.setAttribute("name",root.childNodes(i).getAttribute("id"));
			newselect.setAttribute("id",root.childNodes(i).getAttribute("id"));
			document.getElementById(root.childNodes(i).getAttribute("insertin")).appendChild(newselect);
			
			alert("select:"+root.childNodes(i).hasChildNodes());
			optBranch=root.childNodes(i).selectNodes('option');
			for(o=0;o<=optBranch.length;o++){
				alert(optBranch[o].getAttribute("default")+"   "+o+"   "+i);
				if(optBranch[o].getAttribute("default")=='yes'){
					document.getElementById(root.childNodes(i).getAttribute("id")).options.add(new Option(optBranch.item(o).text,optBranch[o].text,true));
				}else{
					document.getElementById(root.childNodes(i).getAttribute("id")).options.add(new Option(optBranch.item(o).text,optBranch[o].text));
				}
			}
		}
	}
}

//AJAX分类处理程序段开始,root一律表示取得XML文件的根。

function ScratchSelect(root){
	var newhidden=createElement("input","hidden","switch");
	newhidden.setAttribute("value","scratch");
	document.getElementById('grid-0-0').appendChild(newhidden);
	if(root.hasChildNodes()){
		ExpoXML(root);
	}
}

function MagenticSelect(root){
	var newhidden=createElement("input","hidden","switch");
	newhidden.setAttribute("value","magnetic");
	document.getElementById('grid-0-0').appendChild(newhidden);
	if(root.hasChildNodes()){
		ExpoXML(root);
	}
}

function PlasticSelect(root){
	var newhidden=createElement("input","hidden","switch");
	newhidden.setAttribute("value","plastic");
	document.getElementById('grid-0-0').appendChild(newhidden);
	if(root.hasChildNodes()){
		ExpoXML(root);
	}
}

function LotterySelect(root){
	var newhidden=createElement("input","hidden","switch");
	newhidden.setAttribute("value","lottery");
	document.getElementById('grid-0-0').appendChild(newhidden);
	if(root.hasChildNodes()){
		ExpoXML(root);
	}
}

function FridgeSelect(root){
	var newhidden=createElement("input","hidden","switch");
	newhidden.setAttribute("value","fridge");
	document.getElementById('grid-0-0').appendChild(newhidden);
	if(root.hasChildNodes()){
		ExpoXML(root);
	}
}
-->


