// headNav
function addClass(element,value) {
	if (!element.className){
		element.className = value;
	}
	else{
		newClassName=element.className;
		newClassName+="";
		newClassName+=value;
		element.className=newClassName;
	}
}

function nav() {
	var nav=document.getElementById("nav");
	var lis=nav.getElementsByTagName("li");
	for (var i=0;i<lis.length;i++){
		lis[i].oldClassName=lis[i].className;
		lis[i].onmouseover = function(){
			addClass(this,"active");
		}
		lis[i].onmouseout = function(){
			this.className = this.oldClassName
		}
	}
}

function box1() {
	var box1=document.getElementById("box1");
	var lis=box1.getElementsByTagName("li");
	for (var i=0;i<lis.length;i++){
		lis[i].oldClassName=lis[i].className;
		lis[i].onmouseover = function(){
			addClass(this,"active");
		}
		lis[i].onmouseout = function(){
			this.className = this.oldClassName
		}
	}
}

function showMenu(tab,content,n,sum) {
	for (var i=1;i<=sum;i++) {
		if (i==n) {
			document.getElementById(tab+"_"+i).className="active";
			document.getElementById(content+"_"+i).style.display="block";
		}else {
			document.getElementById(tab+"_"+i).className="lab";
			document.getElementById(content+"_"+i).style.display="none";
		}
	}
}

function setImgSize(theURL,sImage,stand,ctand) {
	var imgObj;
	var sizeStand=stand;
	var CStand=ctand;
	if(arguments.length>=3) {
		sizeStand=arguments[2];
	}

	imgObj=new Image();
	imgObj.src=theURL;
	if(ctand==0) {
		if((imgObj.width!=0)&&(imgObj.height!=0)) {
			if(imgObj.width>sizeStand||imgObj.height>sizeStand) {
				if(imgObj.width>imgObj.height) {
					var iHeight=imgObj.height*sizeStand/imgObj.width;
					sImage.height=iHeight;sImage.width=sizeStand;
				}
				else {
					var iWidth=imgObj.width*sizeStand/imgObj.height;sImage.width=iWidth;sImage.height=sizeStand;
				}
			}
			else {
				sImage.width=imgObj.width;sImage.height=imgObj.height;
			}
		}
		else {
			sImage.width=sizeStand;sImage.height=sizeStand;
		}
	}
	else {
		if((imgObj.width!=0)&&(imgObj.height!=0)) {
			if(imgObj.width>sizeStand||imgObj.height>CStand) {
				var wi=imgObj.width/sizeStand;
				var hi=imgObj.height/CStand;
				if(wi>hi) {
					var iHeight=imgObj.height*sizeStand/imgObj.width;
					sImage.height=iHeight;sImage.width=sizeStand;
				}
				else {
					var iWidth=imgObj.width*CStand/imgObj.height;
					sImage.width=iWidth;sImage.height=CStand;
				}
			}
			else {
				sImage.width=imgObj.width;sImage.height=imgObj.height;
			}
		}
		else {
			sImage.width=sizeStand;sImage.height=CStand;
		}
	}
}

function closewin() {
	self.opener = null;
	self.close();
}

//old category left menu js
function w(vd)
{
  var ob=document.getElementById(vd);
  if(ob.style.display=="block" || ob.style.display=="")
  {
     ob.style.display="none";
     var ob2=document.getElementById('s'+vd);
     ob2.style.backgroundImage="url(/images//ico080426_open.gif)";
  }
  else
  {
    ob.style.display="block";
    var ob2=document.getElementById('s'+vd);
    ob2.style.backgroundImage="url(/images/ico080426_close.gif)";
  }
}
function k(vd)
{
  var ob=document.getElementById(vd);  
  if(ob.style.display=="block")
  {
     ob.style.display="none";
     var ob2=document.getElementById('s'+vd);
     ob2.style.backgroundImage="url(/images/ico080426_open.gif)";
  }
  else
  {
    ob.style.display="block";
    var ob2=document.getElementById('s'+vd);
    ob2.style.backgroundImage="url(/images/ico080426_close.gif)";
  }
}

function goto_url(src){
    location=get_goto(src);
    return false;
}
function get_goto(src){
    var str=location.toString();
    var pa=(str.split('?',2));
    var has_p=src.indexOf('?')>-1?1:0;
    if(pa.length==1){
        return src+ (has_p?'&':'?')+'&goto='+encodeURIComponent(str);
    }
    var arr=pa[1].split('&');
    for(var i=0;i<arr.length;i++){
        var t=arr[i].split('=',2);
        var v = t.length>1?t[1]:'';
        var k = t[0];
        if (k=='goto'){
            return  src+ (has_p?'&':'?')+'&goto='+v;
        }
    }
    return src+ (has_p?'&':'?')+'&goto='+encodeURIComponent(str);
}

function change_img_up(img,count,comefrom,themes){
    if(comefrom=='PL'){
        datas = dataPL;
        descs = descPL;
        titles = titlePL;
        img_pos = img_pospl;
    }else if(comefrom=='OEM'){
        datas = dataOEM;
        descs = descOEM;
        titles = titleOEM;
        img_pos = img_posoem;
    }else if(comefrom=='RD') {
        datas = dataRD;
        descs = descRD;
        titles = titleRD;
        img_pos = img_posrd;
    }
    if(img_pos+1>=count){
        img_pos = count-1;
    }else{
	img.src = themes+'/style/images/waiting_small2.gif';
	var imgsrc = datas[img_pos+1 % datas.length];
            var loadimage = new Image();
            loadimage.src = imgsrc;
            loadimage.onload = function(){
                img.src = imgsrc;
	}
	document.getElementById('countNum'+comefrom).innerHTML=img_pos+2;
        document.getElementById('pic'+comefrom).innerHTML=descs[img_pos+1 % descs.length];
        document.getElementById('title'+comefrom).innerHTML=titles[img_pos+1 % titles.length];
        img_pos++;
    }
    if(comefrom=='PL'){
        img_pospl = img_pos;
    }else if(comefrom=='OEM'){
        img_posoem = img_pos;
    }else if(comefrom=='RD') {
        img_posrd = img_pos;
    }

}
function change_img_down(img,comefrom){
    if(comefrom=='PL'){
        datas = dataPL;
        descs = descPL;
        titles = titlePL;
        img_pos = img_pospl;
    }else if(comefrom=='OEM'){
        datas = dataOEM;
        descs = descOEM;
        titles = titleOEM;
        img_pos = img_posoem;
    }else if(comefrom=='RD') {
        dataRD = dataRD;
        descs = descRD;
        titles = titleRD;
        img_pos = img_posrd;
    }
    if(img_pos-1<0){
        img_pos = 0;
    }else{
            img.src = 'images/waiting_small2.gif';
	    var imgsrc = datas[img_pos-1 % datas.length];
            var loadimage = new Image();
            loadimage.src = imgsrc;
            loadimage.onload = function(){
                img.src = imgsrc;
        }
        document.getElementById('countNum'+comefrom).innerHTML=img_pos;
        document.getElementById('pic'+comefrom).innerHTML=descs[img_pos-1 % descs.length];
        document.getElementById('title'+comefrom).innerHTML=titles[img_pos-1 % titles.length];
        img_pos--;
    }
    if(comefrom=='PL'){
        img_pospl = img_pos;
    }else if(comefrom=='OEM'){
        img_posoem = img_pos;
    }else if(comefrom=='RD') {
        img_posrd = img_pos;
    }
}
