// when mouse over, change the image
function change_image(_this,x){
	_this.src=x;
}

//show and hide second menu
function show_hide(x,y){
	a=document.getElementById(x);
	d=document.getElementById(y);
	if (d.style.display=="none"){
		a.src="/images/common/arrow_on.gif";
		d.style.display="";
	}
	else {
		a.src="/images/common/arrow_off.gif";
		d.style.display="none";
	}
}

//check the menu arrow
function checkitem(){
	if(document.getElementById("Audio & Multimedia").style.display!="none"){document.getElementById("arrow_01").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Business").style.display!="none"){document.getElementById("arrow_02").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Games & Entertainment").style.display!="none"){document.getElementById("arrow_03").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Home & Education").style.display!="none"){document.getElementById("arrow_04").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Internet").style.display!="none"){document.getElementById("arrow_05").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Software Development").style.display!="none"){document.getElementById("arrow_06").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Utilities").style.display!="none"){document.getElementById("arrow_07").src="/images/common/arrow_on.gif";}
	if(document.getElementById("Web Authoring").style.display!="none"){document.getElementById("arrow_08").src="/images/common/arrow_on.gif";}
}

//for dvd-to-ipod.html page
function choose_p(t,c,x){
	for(i=1;i<=x;i++){
		document.getElementById("tab"+i).className="choose_off";
		document.getElementById("content"+i).style.display="none";
	}
	document.getElementById(t).className="choose_on";
	document.getElementById(c).style.display="";
}



//for search
function search_onfocus()
{
	if(document.getElementById("q").value=="Search..."){document.getElementById("q").value="";}
}
	
function search_onblur()
{
	if(document.getElementById("q").value==""){document.getElementById("q").value="Search...";}
}

function submit_check(){
	if(document.getElementById("q").value=="Search...")	{alert("Please Input Your Keywords.");}
	else document.searchform.submit();
}

//for browse couter
function gotoCountInfo(cType, cId) {
	var xmlHttp = false;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				xmlHttp = false;
			}
		}
	}
	var url = "/webapp/browse.php?type=" + cType + "&cid=" + cId + "&rand=" + Math.random();
    xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = function(){
        if (xmlHttp.readyState == 4) {
           
        }
    };
    xmlHttp.send(null);
}
function highLightKeyWord (nodeID, keys, color) { 
	var NodeID = nodeID || "";
	var keyWord = keys || "";   
	var keyColor = color || "red";   
	var keyWordArray = keyWord.split(" ");
	for(var i=0; i<keyWordArray.length; i++) {
		if(keyWordArray[i]=='to') continue;
    	if (NodeID != "") {   
    	    hilitWord(keyWordArray[i],nodeID,color);
    		/*var pattern = new RegExp('(>[^<]*)('+keyWordArray[i]+')([^>]*<)', "gi");
    		var node = document.getElementById(nodeID);
    		var html = node.innerHTML;
    		var htm = html.replace(pattern,"$1<span style='color:"+keyColor+"; font-weight:bold' >$2</span>$3");
    		node.innerHTML = htm;*/
    	}
    }
}
function show_links(parentDiv,subDiv,obj) {
	var divs = document.getElementById(parentDiv).getElementsByTagName('div');
	divNum = divs.length;
	for(var i=0; i< divNum; i++) {
		if(subDiv == divs[i].id) {
			divs[i].style.display='block';
		}else{
			divs[i].style.display='none';
		}
	}
	var as = document.getElementById('listlinks').getElementsByTagName('a');
	for(var i=0; i< as.length; i++) {
		if(obj == as[i]) {
			as[i].className='on';
		}else{
			as[i].className='';
		}
	}
}

