//swf caller function for Comunnication with AS  和flash交互
/*function thisMovie(movieName){
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ?window[movieName] : document[movieName];
};*/
$(function(){
	//window.document.oncontextmenu = function(){ return false; };  //网页禁止使用右键
	
	/*if iPad, iPone & iPod visit this site, redirect to a picture homepage 如果是iPad, iPone, iPod,将跳转到html老板首页
	var pageURL = document.URL;
	if((navigator.userAgent.indexOf('iPhone')!=-1)||(navigator.userAgent.indexOf('iPad')!=-1)){
		if((pageURL.indexOf('index.php')!=-1)||(pageURL.indexOf('.php')==-1))
			document.location.href = 'apple_index.php'; 
	};*/
	
	$('a').focus(function(){this.blur();});  //fix all outline in the IE6
	$(".Wapper_left").height($(".Wapper_right").height());
	(function(){
		//首页导航栏
		/*sub_menu.each(function(i){
			$(this).data('index', i);	
		})
		sub_menu.hover(
			function(){
				alert (0)
				var i = $(this).data("index");
				$(this).find('ol').fadeOut(200).eq(i).fadeIn(500);
			},
			function(){
				$(this).find('ol').fadeOut(200);
			}
		);*/
		var sub_menu = $(".Header .menu > li[class *= 'second_popup']");
		var sub_menu_cont = $(".popup_menu");
		sub_menu.hover(
			function(){
				setIDIn = setTimeout(function(){
					sub_menu_cont.show();
				},200);	
			},
			function(){
				clearTimeout(setIDIn);
				setIDOut = setTimeout(function(){
					sub_menu_cont.hide();
				},200);	
			}
		);
		sub_menu_cont.hover(
			function(){
				clearTimeout(setIDOut);
			},
			function(){
				sub_menu_cont.hide();
			}
		);
		var second_btns = $("ul.list_slide_down > li:not([class *= 'show'])");
		second_btns.live('click',function(){
				var $this = $(this);
				$(this).siblings("li[class *= 'show']").removeClass("show").addClass("hide").find('ol').slideUp("fast",function(){
					$this.addClass("show").removeClass("hide").find('ol').slideDown();
				});
			}
		);
		/*服务支持 太阳能使用常识 效果*/
		var knowledge_btns = $(".knowledge_box:not([class *= 'show']) .knowledge_box_cont dt");
		knowledge_btns.live('click',function(){
				var $this = $(this);
				$(this).parent().parent().siblings("div[class *= 'show']").removeClass("show").find('dd').slideUp("fast",function(){
					$this.parent().parent().addClass("show").find('dd').slideDown();
				});
			}
		);
	})();
	
	(function(){
		var tab_btn = $(".Tab ul.Tab_btns > li");
		var tab_cont = $(".Tab div .text");
		tab_btn.each(function(i){
			$(this).data("index", i);	
		})
		tab_btn.click(function(){
			var i = $(this).data("index");
			$(this).addClass("gbnone").siblings().removeClass("gbnone");
			tab_cont.hide().eq(i).show();
			//alert (i);
			if( $(this).hasClass("scroll") ){
				//alert (0)
				$('.Tab_cont .text .scrollpane').jScrollPane({verticalDragMinHeight:70, verticalDragMaxHeight:70});
			}
			else {
				return false;
			}
		})
	})();
	
	(function(){
		//插入首页flash
		var flashvars = {}
		var attributes = {}
		var params ={allowFullScreen:'true',allowScriptAccess:'always',quality:'high',wmode:'Transparent'}
		//swfobject.embedSWF("flash/home_banner.swf", "home_banner", "993", "435", "9.0.0", "flash/expressInstall.swf",flashvars, params, attributes);
		swfobject.embedSWF("flash/story.swf", "story_flash", "700", "520", "9.0.0", "flash/expressInstall.swf",flashvars, params, attributes);
		swfobject.embedSWF("flash/honour.swf", "honour_flash", "700", "440", "9.0.0", "flash/expressInstall.swf",flashvars, params, attributes);
		swfobject.embedSWF("flash/technology.swf", "technology_flash", "993", "419", "9.0.0", "flash/expressInstall.swf",flashvars, params, attributes);
		swfobject.embedSWF("flash/project.swf", "project_flash", "770", "289", "9.0.0", "flash/expressInstall.swf",flashvars, params, attributes);
		
		//产品滚动  首页box3 和 产品中心
		$('.product_list').jCarouselLite({
			visible:2,
			btnPrev: ".left",
			btnNext: ".right",
			auto:0,
			speed:800,
			circular: false,
			scroll:1,
			easing: "easeInOutBack"
		});	
		$('.index_scroll').jCarouselLite({
			visible:1,
			btnPrev: ".left",
			btnNext: ".right",
			auto:4000,
			speed:800,
			circular: true,
			scroll:1,
			easing: "easeInOutBack"
		});
		$('.left_project').jCarouselLite({
			visible:1,
			auto:4000,
			speed:800,
			circular: true,
			scroll:1
		});	
	})();
	
	//表单提交验证
	(function(){
		var input = $(".search_box form input.text");
		var inputid = $("#letter_input");
		var btnid = $("#letter_btn");
		var emailReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
		var data;
		/*头部*/
		input.focus(function(){
			if($(this).val() == this.defaultValue){
				$(this).val("");				
			}
		}).blur(function(){
			if($(this).val() == ''){
				$(this).val(this.defaultValue);	
			}			
		});
		/*底部*/
		inputid.focus(function(){
			if($(this).val() == this.defaultValue){
				$(this).val("");				
			}
		}).blur(function(){
			if($(this).val() == ''){
				$(this).val(this.defaultValue);	
			}			
		}).keypress(function(e) {
			if (e.keyCode == 13) {
				btnid.trigger("click");
				return false;
			}
		});
		btnid.click(function(){
			if( ($('#letter_input').val() == '') || (!emailReg.test($('#letter_input').val())) )
			{
				alert ("请输入正确的电子邮件！")
				return false;
			}
			else{};
			data = $('#letter_form').serialize();
			$.ajax({
				type: "POST",
				url: "enewsletter.php",
				data: data,
				success: function(result){
					(result=="Ok") ? alert ("提交成功，谢谢！") : ''; 
					(result=="Been") ? alert ("你输入的邮件地址已存在，请重新输入！") : '';
					(result=="Wrong") ? alert ("服务超时，请重新输入！") : '';
				}
			});
		})
	})();
	
	$(".Tab_btns li").hover(function(){
		$(this).css("color","#fff");
		}
		,function(){
			$(this).css("color","#647079");
		}
	);
});
