﻿jQuery(document).ready(function(){
	projectList();
	clickTreeButton();
	clickFootButton();
	clickFootButton2()
	photoTool();
	png();
	HonorList();
	secondTree();
})

function projectList(){
	jQuery(".projectList").find(".bg").add(".officebg").animate({opacity:0.7},0);
	jQuery(".projectList .img").hover(function(){		
		jQuery(this).find(".bg").animate({"width":"250px","height":"150px","marginTop":"-150px"},function(){
			jQuery(this).parent().find(".description").fadeIn();
			jQuery(this).parent().find(".name").fadeOut();
			})
	},function(){		
		jQuery(this).find(".bg").animate({"width":"250px","height":"35px","marginTop":"-35px"},function(){
			jQuery(this).parent().find(".name").fadeIn();
			jQuery(this).parent().find(".description").fadeOut();
			})		
		})
	
	}	

function lineButtonEN(){
	var linButtonNow1=getCookie("lineButton1");
	var linButtonNow2=getCookie("lineButton2");
	jQuery(window.parent.document).find("#line").siblings().mouseover(function(){
		jQuery(window.parent.document).find(".secondLine").remove();
		})
	if(linButtonNow1 && linButtonNow1!=""){
		jQuery("#"+linButtonNow1).css("color","red");
		}else if(linButtonNow2 && linButtonNow2!=""){
			jQuery("#"+linButtonNow2).css("color","#F5B848");			
			}else{
				jQuery("#lineButton1").css("color","red");
				}
			
	jQuery(".lineButton1").click(function(){
		setCookie("lineButton1",jQuery(this).attr("id"));
	}).mouseover(function(){
		var id=jQuery(this).attr("id");
		jQuery(window.parent.document).find(".secondLine").remove();
		if(id=="enLineButton2"){
			jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:130px;width:520px;'><table cellpadding='0' cellspacing='0' border='0' style='text-align:center'><tr><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_about.aspx?id=2'>about Zhongxin Furniture</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_about.aspx?id=5'>history</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_about.aspx?id=6'>our group of companies</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_abouthonor.aspx'>merit</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_construction.html'>more ...</a></td></tr></table></div>");
			}else if(id=="enLineButton3"){
				jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:250px;width:210px'><table cellpadding='0' cellspacing='0' border='0'><tr><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_news.aspx'>latest news</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_construction.html'>viedo</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_construction.html'>more...</a></td></tr></table></div>");
				}else if(id=="enLineButton4"){
					jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:340px;width:175px'><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_quality.html'>Technique</a>&nbsp;|&nbsp;<a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_quality.html'>Certification</a></div>");
					}
			jQuery(window.parent.document).find(".secondLine").animate({opacity:0.8},0);
		})
	
	jQuery(".lineButton2").click(function(){
		setCookie("lineButton1","");
		setCookie("lineButton2",jQuery(this).attr("id"));		
	})
}

function lineButtonCN(){
	var linButtonNow1=getCookie("lineButton1");
	var linButtonNow2=getCookie("lineButton2");
	jQuery(window.parent.document).find("#line").siblings().mouseover(function(){
		jQuery(window.parent.document).find(".secondLine").remove();
		})
	if(linButtonNow1 && linButtonNow1!=""){
		jQuery("#"+linButtonNow1).css("color","red");
		}else if(linButtonNow2 && linButtonNow2!=""){
			jQuery("#"+linButtonNow2).css("color","#F5B848");			
			}else{
				jQuery("#lineButton1").css("color","red");
				}
			
	jQuery(".lineButton1").click(function(){
		setCookie("lineButton1",jQuery(this).attr("id"));
	}).mouseover(function(){
		var id=jQuery(this).attr("id");
		jQuery(window.parent.document).find(".secondLine").remove();
		if(id=="enLineButton2"){
			jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:130px;width:520px;'><table cellpadding='0' cellspacing='0' border='0' style='text-align:center'><tr><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_about.aspx?id=2'>简介</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_about.aspx?id=5'>发展历程</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_about.aspx?id=6'>关于中新集团</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_abouthonor.aspx'>荣誉证书</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_construction.html'>更多 ...</a></td></tr></table></div>");
			}else if(id=="enLineButton3"){
				jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:250px;width:210px'><table cellpadding='0' cellspacing='0' border='0'><tr><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_news.aspx'>最新消息</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_construction.html'>视频</a></td><td>&nbsp;|&nbsp;</td><td><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='cn_construction.html'>更多...</a></td></tr></table></div>");
				}else if(id=="enLineButton4"){
					jQuery(window.parent.document).find("#line").append("<div class='secondLine' style='margin-left:340px;width:175px'><a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_quality.html'>Technique</a>&nbsp;|&nbsp;<a onclick='setCookie(\"lineButton1\",\""+id+"\")' href='en_quality.html'>Certification</a></div>");
					}
			jQuery(window.parent.document).find(".secondLine").animate({opacity:0.8},0);
		})

	
	jQuery(".lineButton2").click(function(){
		setCookie("lineButton1","");
		setCookie("lineButton2",jQuery(this).attr("id"));
	})
}

function setCookie(name, value) //cookies设置 
{ 
var argv = setCookie.arguments; 
var argc = setCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 
if(expires!=null) 
{ 
var LargeExpDate = new Date (); 
LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24)); 
} 
document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString())); 
} 

function getCookie(Name) //cookies读取 
{ 
var search = Name + "=" 
if(document.cookie.length > 0) 
{ 
offset = document.cookie.indexOf(search) 
if(offset != -1) 
{ 
offset += search.length 
end = document.cookie.indexOf(";", offset) 
if(end == -1) end = document.cookie.length 
return unescape(document.cookie.substring(offset, end)) 
} 
else return "" 
} 
}

function photoTool(){

	jQuery(".photoTool div").click(function(){
		jQuery("#bigPhoto").attr("src",jQuery(this).attr("src"));
		jQuery(this).css("background-color","white").siblings().removeAttr("style");
		}).mouseover(function(){
			jQuery(this).append("<img class='mousePhoto' src='"+jQuery(this).attr('src')/*.replace('productpic','smallpic')*/+"'/>");
			}).mouseout(function(){
				jQuery(".mousePhoto").remove();
				})
	
	jQuery(".project_Title").add(".project_TitleCN").mouseover(function(){
			//alert(jQuery(this).offset().top)
			jQuery(this).prepend("<img class='mousePhoto2' style='top:"+(jQuery(this).offset().top-300)+"px' src='"+jQuery(this).attr('src').replace('productpic','smallpic')+"'/>");
		}).mouseout(function(){
				jQuery(".mousePhoto2").remove();
				})
	
	jQuery(".STT").mouseover(function(){
			jQuery(this).prepend("<img class='mousePhoto3' src='"+jQuery(this).attr('src')+"'/>");
		}).mouseout(function(){
				jQuery(".mousePhoto3").remove();
				})
	
	jQuery("#leftB").click(function(){
		jQuery(".photoTool div").each(function(){
			if(jQuery(this).css("backgroundColor")=="white"){
				if(jQuery(this).prev().length>0){
					jQuery(this).prev().click();
					}
				return false;
				}
		})
		})
	
	jQuery("#rightB").click(function(){
		jQuery(".photoTool div").each(function(){
			if(jQuery(this).css("backgroundColor")=="white"){				
				if(jQuery(this).next().length>0){
					jQuery(this).next().click();
					}
				return false;
				}
		})	
		})
	
	jQuery("#bigPhoto").click(function(){
			var oft=jQuery(this).offset().top+160;
			var ofl=jQuery(this).offset().left;			
			var imgUrl=jQuery(this).attr("src");
			
			jQuery("#photoUrl").remove();
			jQuery("body").append("<div class='showPhoto'>&nbsp;</div><img id='photoUrl'/>");			
			
			jQuery(".showPhoto").css({top:oft,left:ofl,opacity:0}).show().animate({opacity:0.5,"top":"0px","left":"0px","width":"100%","height":"600px"},function(){jQuery("#photoUrl").attr("src",imgUrl).css({"marginLeft":-(jQuery("#photoUrl").width()/2),"marginTop":-(jQuery("#photoUrl").height()/2)}).show();}).add("#photoUrl").click(function(){jQuery(".showPhoto").add("#photoUrl").remove()});;
		})
	
	 jQuery("#Label1").mouseover(function(){
	 //alert(jQuery(this).offset().top)
	 var oft=jQuery(this).offset().top+27;
	var ofl=jQuery(this).offset().left-253;	

	jQuery("#downloadPanel").css({top:oft,left:ofl,display:'block'});
        }).mouseout(function(){jQuery("#downloadPanel").css({display:'none'})});

	}

function clickTreeButton(){
	if(jQuery(".tree_img").length>0){	
	var leng=jQuery(".tree_img").find("img").length-4;
	var marginTop=119;
	var nowLeng=0;
	var nowMarginTop=0;
	jQuery("#treeUpB").click(function(){
		if(nowLeng>0){
		nowLeng-=1;
		nowMarginTop+=marginTop;
		jQuery(".tree_img div").animate({"marginTop":nowMarginTop});	
		}
		})
	
	jQuery("#treeDownB").click(function(){
		if(nowLeng<=leng){
		nowLeng+=1;
		nowMarginTop-=marginTop;
		jQuery(".tree_img div").animate({"marginTop":nowMarginTop});	
		}
		})
	}
	}

function clickFootButton(){
	if(jQuery(".foot_img").length>0){	
	var leng=jQuery(".foot_img").find("img").length-4;
	if(jQuery(document).width()>1200){
	jQuery(".foot_img").width(745);
	leng=jQuery(".foot_img").find("img").length-5;
	}
	var marginLeft=187;
	var nowLeng=0;
	var nowMarginLeft=0;
	jQuery("#footRightB").click(function(){
		if(nowLeng<=leng){
		nowLeng+=1;
		nowMarginLeft-=marginLeft;
		jQuery(".foot_img div").animate({"marginLeft":nowMarginLeft});	
		}
		})
	
	jQuery("#footLeftB").click(function(){
		if(nowLeng>0){
		nowLeng-=1;
		nowMarginLeft+=marginLeft;
		jQuery(".foot_img div").animate({"marginLeft":nowMarginLeft});	
		}
		})
	}
	}
	
function clickFootButton2(){
	if(jQuery(".foot_img2").length>0){	
	var leng=jQuery(".foot_img2").find("img").length-5;
	if(jQuery(document).width()>1200){
	jQuery(".foot_img2").width(935);
	leng=jQuery(".foot_img2").find("img").length-6;
	}
	var marginLeft=187;
	var nowLeng=0;
	var nowMarginLeft=0;
	jQuery("#footRightB").click(function(){
		if(nowLeng<=leng){
		nowLeng+=1;
		nowMarginLeft-=marginLeft;
		jQuery(".foot_img2 div").animate({"marginLeft":nowMarginLeft});	
		}
		})
	
	jQuery("#footLeftB").click(function(){
		if(nowLeng>0){
		nowLeng-=1;
		nowMarginLeft+=marginLeft;
		jQuery(".foot_img2 div").animate({"marginLeft":nowMarginLeft});	
		}
		})
	jQuery(".foot_img2 div img").click(function(){
		jQuery("#bigPhoto").attr("src",jQuery(this).attr("src").replace("smallpic","productpic"));
		})
	}
	}

function png(){
	if(jQuery('div.png').length){
	jQuery('div.png').pngFix( );
	}
}

function showEnProjects(){

if(jQuery(".ProjectDialog").length==0){	
	var html="";
	var oldSrc=jQuery("#indexBigPhoto").attr("src");
	for(var i=0;i<project.length;i++){
	var name=project[i].name;
	var url=project[i].url+"?id="+project[i].id;
	var src=project[i].src;
	html+="<div>&nbsp;·&nbsp;<a src="+src+" href="+url+">"+name+"</a></div>"
	}
	jQuery("body").append("<div class='ProjectDialog'><div class='projectTitle'><div style='float:left'>Project List</div><div style='float:right; padding-right:5px; cursor:pointer;' onclick='jQuery(\".ProjectDialog\").remove();jQuery(\"#indexBigPhoto\").attr(\"src\",\""+oldSrc+"\")'>X</div></div><div class='projectBody'>"+html+"</div></div>");
	 jQuery(".ProjectDialog").css({top:500}).animate({left:150,top:500},1000).find("a").mouseover(function(){
		jQuery("#indexBigPhoto").attr("src",jQuery(this).attr("src"))
		});

  var global_MOUSEDOWN=false;
  var box=jQuery('<div />');
  box.css({display:'none',position:'absolute',border:'1px dotted red'});
  box.appendTo('body');
  var _x,_y;
  jQuery('.projectTitle').mousedown(function(event){
   global_MOUSEDOWN=true;
   var offset=jQuery('.ProjectDialog').offset();
   _x=event.pageX-offset.left;
   _y=event.pageY-offset.top;
   box.width(jQuery(this).parent().width());
   box.height(jQuery(this).parent().height());
   box.css({left:event.pageX-_x,top:event.pageY-_y});
   box.show();
  });
  jQuery(document).mousemove(function(event){
   if(global_MOUSEDOWN){
    box.css({left:event.pageX-_x,top:event.pageY-_y});
   }
  }).mouseup(function(event){
   if(global_MOUSEDOWN){
    jQuery('.ProjectDialog').animate({left:box.offset().left-50,top:box.offset().top+100},1000);
    box.hide();
   }
   global_MOUSEDOWN=false;
  });
}
}

function showCnProjects(){

if(jQuery(".ProjectDialog").length==0){	
	var html="";
	var oldSrc=jQuery("#indexBigPhoto").attr("src");
	for(var i=0;i<project.length;i++){
	var name=project[i].name;
	var url=project[i].url+"?id="+project[i].id;
	var src=project[i].src;
	html+="<div>&nbsp;·&nbsp;<a src="+src+" href="+url+">"+name+"</a></div>"
	}
	jQuery("body").append("<div class='ProjectDialog'><div class='projectTitle'><div style='float:left'>所有业绩</div><div style='float:right; padding-right:5px; cursor:pointer;' onclick='jQuery(\".ProjectDialog\").remove();jQuery(\"#indexBigPhoto\").attr(\"src\",\""+oldSrc+"\")'>X</div></div><div class='projectBodyCn'>"+html+"</div></div>");
	 jQuery(".ProjectDialog").css({top:500}).animate({left:150,top:500},1000).find("a").mouseover(function(){
		jQuery("#indexBigPhoto").attr("src",jQuery(this).attr("src"))
		});

  var global_MOUSEDOWN=false;
  var box=jQuery('<div />');
  box.css({display:'none',position:'absolute',border:'1px dotted red'});
  box.appendTo('body');
  var _x,_y;
  jQuery('.projectTitle').mousedown(function(event){
   global_MOUSEDOWN=true;
   var offset=jQuery('.ProjectDialog').offset();
   _x=event.pageX-offset.left;
   _y=event.pageY-offset.top;
   box.width(jQuery(this).parent().width());
   box.height(jQuery(this).parent().height());
   box.css({left:event.pageX-_x,top:event.pageY-_y});
   box.show();
  });
  jQuery(document).mousemove(function(event){
   if(global_MOUSEDOWN){
    box.css({left:event.pageX-_x,top:event.pageY-_y});
   }
  }).mouseup(function(event){
   if(global_MOUSEDOWN){
    jQuery('.ProjectDialog').animate({left:box.offset().left-50,top:box.offset().top+100},1000);
    box.hide();
   }
   global_MOUSEDOWN=false;
  });
}
}

function HonorList(){
	if(jQuery(".HonorList").length>0){
		
		jQuery(".HonorList .img").click(function(){
			var oft=jQuery(this).offset().top+160;
			var ofl=jQuery(this).offset().left;			
			var imgUrl=jQuery(this).find('img').attr("src").replace("smallpic","productpic");	
			jQuery("#imgUrl").remove();
			jQuery("body").append("<div class='showHonor'>&nbsp;</div><img id='imgUrl'/>");			
			
			jQuery(".showHonor").css({top:oft,left:ofl,opacity:0}).show().animate({opacity:0.5,"top":"230px","left":"50%","width":"600px","height":"400px","marginLeft":"-360px"},function(){jQuery("#imgUrl").attr("src",imgUrl).show(function(){jQuery(".showHonor").remove();}).click(function(){jQuery(this).remove()});});
		})
		
	}
}

function sitemap(){
	var sitemap="<div class='sitemap'><div class='stemapClose'><img onclick='jQuery(this).parent().parent().add(jQuery(\".sitemapBg\")).remove();' src='file/stemapClose.gif'/></div><div class='sitemapBody'><div class='sitemapTitle'>SITEMAP</div><table class='sitemapTB' cellpadding='0' cellspacing='0' border='0'><tr><td class='smTD1'><a href='en_index.aspx'>Home</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='en_about.aspx'>About us</a></td><td class='smTD2'><a href='en_about.aspx'>about Zhongxin Furniture</a> | <a href='en_about.aspx?id=5'>history</a> | <a href='en_about.aspx?id=6'>our group of companies</a> | <a href='en_aboutHonor.aspx'>merit</a> | <a href='en_construction.html'>more...</a></td></tr><tr><td class='smTD1'><a href='en_news.aspx'>Latest</a></td><td class='smTD2'><a href='en_news.aspx'>latest news</a> | <a href='en_construction.html'>viedo</a> | <a href='en_construction.html'>more...</a></td></tr><tr><td class='smTD1'><a href='en_projectList.aspx'>Out Work</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='en_contact.aspx'>Contact us</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='en_download.html'>Download</a></td><td class='smTD2'>&nbsp;</td></tr></table></div></div>";	
	jQuery(window.top.document).find("body").append("<div class='sitemapBg'>&nbsp;</div>"+sitemap);
	jQuery(window.top.document).find(".sitemapBg").css({opacity:0}).show().animate({width:"100%",height:"600px",opacity:0.5},function(){jQuery(window.top.document).find(".sitemap").show()});
	
	}

function sitemapCn(){
	var sitemap="<div class='sitemapCn'><div class='stemapClose'><img onclick='jQuery(this).parent().parent().add(jQuery(\".sitemapBg\")).remove();' src='file/stemapClose.gif'/></div><div class='sitemapBody'><div class='sitemapTitle'>网站地图</div><table class='sitemapTB' cellpadding='0' cellspacing='0' border='0'><tr><td class='smTD1'><a href='cn_index.aspx'>主页</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='cn_about.aspx'>走进中新</a></td><td class='smTD2'><a href='cn_about.aspx?id=2'>简介</a> | <a href='cn_about.aspx?id=5'>发展历程</a> | <a href='cn_about.aspx?id=6'>关于中新集团</a> | <a href='cn_aboutHonor.aspx'>荣誉证书</a> | <a href='cn_construction.html'>更多...</a></td></tr><tr><td class='smTD1'><a href='cn_news.aspx'>最新资讯</a></td><td class='smTD2'><a href='cn_news.aspx'>最新消息</a> | <a href='cn_construction.html'>视频</a> | <a href='cn_construction.html'>更多...</a></td></tr><tr><td class='smTD1'><a href='cn_projectList.aspx'>工程业绩</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='cn_contact.aspx'>与我们联系</a></td><td class='smTD2'>&nbsp;</td></tr><tr><td class='smTD1'><a href='cn_download.html'>下载中心</a></td><td class='smTD2'>&nbsp;</td></tr></table></div></div>"
	jQuery(window.top.document).find("body").append("<div class='sitemapBg'>&nbsp;</div>"+sitemap);
	jQuery(window.top.document).find(".sitemapBg").css({opacity:0}).show().animate({width:"100%",height:"600px",opacity:0.5},function(){jQuery(window.top.document).find(".sitemapCn").show()});
	}
function secondTree(){
	jQuery(".secondTreeE").click(function(){
		jQuery(this).animate({"left":"0px"});
		}).mouseover(function(){
		return false;
		})
	jQuery("body").mouseover(function(){
	jQuery(".secondTreeE").animate({"left":"-150px"});
	})
	}
