/**
 * @author fangkaiming
 */
 /****数码导购 javascript****/
var stopscroll=false;
 var preTop=0; 
 //var newTop=0;
 var currentTop=0; 
 var stoptime=0;
 var iInterval ;
 var ftag=1;
 var img_interval;
 var set_tag;
 var stop_tag = false;

 function init_srolltext(){
	 document.getElementById("scrollid").scrollTop=0;
	 document.getElementById("scrollid").onmouseover   = new Function("stopscroll=true");
	 document.getElementById("scrollid").onmouseout    = new Function("stopscroll=false");
	 document.getElementById("scrollid").oncontextmenu = new Function("return false;");
	 document.getElementById("scrollid").onselectstart = new Function("return false;");
	 iInterval = setInterval("scrollUp()",25);
 }

 function scrollUp(){
  if(stopscroll==true) return;
  currentTop+=1; //每次滚动 1 个象素
  if(currentTop==27){ //刚滚动完一行后(每行高23)
   stoptime+=1;  //停顿时间累计 1 个单位时间(25毫秒)
   currentTop-=1; //滚动位移数恢复原值
   if(stoptime==100){ //停顿时间累计 100 个单位时间后重新计算滚动位移和停顿时间
    currentTop=0;
    stoptime=0;
    //if(confirm("One line end ...... \n\nok to stop , cancel to go on.")){clearInterval(iInterval);}
   }
  }else{   
	   document.getElementById("scrollid").scrollTop = preTop +1; //滚动 1 个象素
	   if(preTop< document.getElementById("scrollid").scrollTop){
	    	preTop = document.getElementById("scrollid").scrollTop ;
	   }else {//如果滚动到末尾了(滚动跟没滚一样)
	    	preTop =1;
	    	document.getElementById("scrollid").scrollTop = 1;
	    	//clearInterval(iInterval);
	    	//clearInterval(iInterval);
	    	//setTimeout("stop_time()",1000);
		//document.documentElement.scrollTop = 1;
	    //if(confirm("scroll to all text ending.......["+preTop+"/"+document.getElementById("scrollid").scrollTop+"] \n\nok to stop , cancel to go on.")){clearInterval(iInterval);}
	   }
  	}
 }
 function stop_time(){
 	iInterval = setInterval("scrollUp()",25);
 }
window.onload=init_srolltext; //启动

function guide_show(id,str,num){
	    var value;
		for(var i=1;i<=num;i++){
		    value = str+i;
			document.getElementById(value).style.display="none";
		}
		document.getElementById(id).style.display="";
}

function add_favorite(){
	var title = document.title;
	var url = document.URL;
	if (document.all) window.external.AddFavorite(url,title);
	else if (window.sidebar) window.sidebar.addPanel(title,url,"");
}

function set_first(obj){
	vrl="http://digi.zol.com.cn/";
    obj.style.behavior='url(#default#homepage)';
    obj.setHomePage(vrl);
}
var price_arr = new Array("price_id1","price_id2","price_id3");
var area_arr = new Array();
var tab_arr = new Array();
var time_interval1;
var time_interval2;
var status_flag = false;
var settag =1;
area_arr['price1']="area_id1";
area_arr['price2']="area_id2";
area_arr['price3']="area_id3";
area_arr['price4']="area_id4";
area_arr['price5']="area_id5";
area_arr['price6']="area_id6";
area_arr['price7']="area_id7";
area_arr['price8']="area_id8";

for(j=0;j<3;j++){
	child_node = document.getElementById(price_arr[j]).childNodes;
    for(k=0;k<child_node.length;k++){
    	child_id= child_node[k].id;
    	child_obj = document.getElementById(child_node[k].id);
		if (document.all){
			content_obj = document.getElementById(area_arr[child_id]);
		}else{
			temp_str1 = "price"+settag;
            if (area_arr[temp_str1]) content_obj = document.getElementById(area_arr[temp_str1]);
		}
		settag++;
		child_node[k].onmouseover=function(){
			if (time_interval1) clearTimeout(time_interval1);
			check_content(this);
			this.parentNode.className="hrSCT hrBG";
			if (this.parentNode.id =="price_id2" && this.className=="nor3 r") this.className="act3 r";
	    	else if (this.parentNode.id =="price_id2" && this.className!="nor3 r") this.className="act2";
	    	else if (this.className=="nor1 r") this.className="act1 r";
	    	else this.className="act1";
	    	document.getElementById(area_arr[this.id]).style.display="";
		}
		child_node[k].onmouseout=function(){
			temp_id1 = this.id;
			temp_id2 = area_arr[this.id];
			temp_obj = this.parentNode;
			time_interval1 = setTimeout('show_content(temp_id1,temp_id2,temp_obj)',1000);
		}
		content_obj.onmouseover=function(){
			clearTimeout(time_interval1);
			check_content();
			temp_num = (this.id).substr(7);
			temp_id = "price"+temp_num;
			temp_obj = document.getElementById(temp_id);
			//alert(temp_obj.className);
			temp_obj.parentNode.className="hrSCT hrBG";
			if (obj.id =="price2" || obj.id =="price8") {
				obj.className="act1 r";
			}else if (obj.id =="price6"){
				obj.className="act3 r";
			}else{
				if (temp_obj.parentNode.id =="price_id2" && temp_obj.className=="nor3 r") temp_obj.className="act3 r";
		    	else if (temp_obj.parentNode.id =="price_id2" && temp_obj.className!="nor3 r") temp_obj.className="act2";
		    	else if (temp_obj.className=="nor1 r") temp_obj.className="act1 r";
		    	else temp_obj.className="act1";
			}
	    	this.style.display="";
		}
		content_obj.onmouseout = function(evt){
			var event_obj = evt?evt:window.event;
			temp_num = (this.id).substr(7);
			temp_id1 = "price"+temp_num;
			temp_id2 = area_arr[temp_id1];
			temp_obj = document.getElementById(temp_id1).parentNode;
			if (!document.all&& event_obj.target.nodeName!="A"){
				time_interval1 = setTimeout('show_content(temp_id1,temp_id2,temp_obj)',1000);
			}else if (document.all && event_obj.toElement.tagName != "A"){
				time_interval1 = setTimeout('show_content(temp_id1,temp_id2,temp_obj)',1000);
			}else{
				return false;
			}
		}
	}
}
function show_content(id1,id2,parent){
	document.getElementById(id2).style.display="none";
	parent.className="hrSCT";
	obj = document.getElementById(id1);
	if (obj.id =="price2" || obj.id =="price8") {
		obj.className="nor1 r";
	}else if (obj.id =="price6"){
		obj.className="nor3 r";
	}else if (obj.id == "price3" || obj.id == "price4" || obj.id == "price5"){
		obj.className="nor2";
	}else{
		obj.className="nor1";
	}
}
function check_content(obj1){
	var tmp_id1;
	var tmp_id2;
	var tmp_obj;
	var temp_value;
	for(var j=1;j<=8;j++){
		tmp_id1 = "price"+j;
		tmp_id2 = area_arr[tmp_id1];
		tmp_obj = document.getElementById(tmp_id1).parentNode;
		if (document.getElementById(area_arr[tmp_id1]).style.display==""){
			show_content(tmp_id1,tmp_id2,tmp_obj);
			break;
		}
	}
}
var per_left=0;
var init_interval;
var left_intrerval;
document.getElementById("scroll_id").onmouseover=function (){
	stop_tag = true;
}
document.getElementById("scroll_id").onmouseout=function (){
	stop_tag = false;
}
document.getElementById("img_id2").onmouseover=function (){
	stop_tag = true;
	this.src ="../../product/images/a5.gif";
}
document.getElementById("img_id1").onmouseover=function (){
	stop_tag = true;
	this.src ="../../product/images/add1.gif";
}
document.getElementById("img_id1").onmouseout=function (){
	stop_tag = false;
	this.src ="../../product/images/a4.gif";
}
document.getElementById("img_id2").onmouseout=function (){
	stop_tag = false;
	this.src ="../../product/images/right1.gif";
}
//自动触发的函数
function inti_scroll(){
	img_interval = setInterval(scroll_left,1);
	if (stop_tag) return;
}
function set_stop(){
	setTimeout(inti_scroll,30000);
	if (stop_tag) return;
}
function sef_init(){
	init_interval = setInterval(scroll_first,1);
	if (stop_tag) return;
}
function scroll_left(){
	if (stop_tag) return;
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft+24;
	per_left+=24;
	if (document.getElementById("scroll_id").scrollLeft%800 ==0){
		clearInterval(img_interval);
		set_stop();
	}
	if (document.getElementById("scroll_id").scrollLeft<per_left) {
		clearInterval(img_interval);
		sef_init();
		per_left =0;
	}
}
function scroll_first(){
	if (stop_tag) return;
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft-24;
	if (document.getElementById("scroll_id").scrollLeft ==0) {
		clearInterval(init_interval);
		//set_stop();
	}
}

//点击触发的函数
function scroll_left_click(){
	clearInterval(left_intrerval);
	left_intrerval = setInterval(scroll_left_func,1);
}
function scroll_right_click(){
	clearInterval(left_intrerval);
	left_intrerval = setInterval(scroll_right_func,1);
}
function scroll_left_func(){
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft+24;
	per_left+=24;
	if (document.getElementById("scroll_id").scrollLeft%800 ==0){
		clearInterval(left_intrerval);
	}
	if (document.getElementById("scroll_id").scrollLeft<per_left) {
		clearInterval(left_intrerval);
		left_intrerval = setInterval(set_first_click,1);
		per_left =0;
	}
}
function scroll_right_func(){
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft-24;
	per_left-=24;
	if (document.getElementById("scroll_id").scrollLeft%800 ==0){
		clearInterval(left_intrerval);
	}
	if (document.getElementById("scroll_id").scrollLeft > per_left) {
		clearInterval(left_intrerval);
		left_intrerval = setInterval(scroll_end_func,1);
		per_left =1008;
	}
}
function scroll_end_func(){
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft+24;
	if (document.getElementById("scroll_id").scrollLeft ==1080) {
		clearInterval(left_intrerval);
	}
}
function set_first_click(){
	document.getElementById("scroll_id").scrollLeft=document.getElementById("scroll_id").scrollLeft-24;
	if (document.getElementById("scroll_id").scrollLeft ==0) {
		clearInterval(left_intrerval);
	}
}
set_stop();//初始化
function change_div(eventt,obj,id1,id2){
        var event_obj = eventt ? eventt :(window.event ? window.event : null); 
		if (event_obj.type && event_obj.type == "mouseover"){
		    if (obj.id == "camer1") obj.className="norr";
		    else if (obj.id=="mp4"){
		    	obj.className="norr5";
		    	document.getElementById("camer1").className="act";
		    } else if (obj.id=="mp3") {
		    	obj.className="norr3";
		    	document.getElementById("camer1").className="actt";
		    }else if (obj.id=="tempid"){
		    	obj.className="norr4";
		    }
		    else obj.className="nor";
			document.getElementById(id1).style.display="none";
		    if (id2!="0") document.getElementById(id2).style.display="none";
		}
		if (event_obj.type && event_obj.type == "mouseout"){
		    if (obj.id =="tempid") obj.className="temp_act";
		    else if (obj.id=="mp4" || obj.id=="mp3") {
		    	obj.className="logo_temp";
		    	document.getElementById("camer1").className="act";
		    }
			else {
				obj.className="act";
				document.getElementById("camer1").className="act";
			}
			document.getElementById(id1).style.display="";
		    if (id2!="0") document.getElementById(id2).style.display="";
		}
}
//定位
function getPos(el,sTOp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sTOp];
		el = el.offsetParent;
	}
	return iPos;
}
var price_arr1 = new Array("digi_price1","digi_price2","digi_price3");
var content_arr = new Array();
var price_arr_con = new Array();
content_arr["digi_price1"] = "content_price1";
content_arr["digi_price2"] = "content_price2";
content_arr["digi_price3"] = "content_price3";
price_arr_con["content_price1"] = "digi_price1";
price_arr_con["content_price2"] = "digi_price2";
price_arr_con["content_price3"] = "digi_price3";
function get_in_content(){
	for (var j= 0;j<3;j++){
		document.getElementById(price_arr1[j]).onmouseover=function (){
			var obj = this;
			document.getElementById(content_arr[this.id]).style.left=getPos(obj,"Left")+"px";
			document.getElementById(content_arr[this.id]).style.top=getPos(obj,"Top")+obj.offsetHeight+"px";
			document.getElementById(content_arr[this.id]).style.display="";
		}
		document.getElementById(price_arr1[j]).onmouseout=function (){
			document.getElementById(content_arr[this.id]).style.display="none";
		}
		document.getElementById(content_arr[document.getElementById(price_arr1[j]).id]).onmouseover=function (){
			var obj = document.getElementById(price_arr_con[this.id]);
			this.style.left=getPos(obj,"Left")+"px";
			this.style.top=getPos(obj,"Top")+obj.offsetHeight+"px";
			this.style.display="";
		}
		document.getElementById(content_arr[document.getElementById(price_arr1[j]).id]).onmouseout=function (){
			this.style.display="none";
		}
	}
}
get_in_content();//初始化