var My = {
	swf : function(swf, width, height, body, wmode, quality) {
		if(swf == '') {
			return false;
		}
		var width = width || 400;
		var height = height || 300;
		var quality = quality || 'high';
		var wmode = wmode || 'opaque';
		var content = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width +'" height="' + height + '">' + 
			'<param name="allowScriptAccess" value="sameDomain">' + 
			'<param name="movie" value="' + swf + '">' + 
			'<param name="quality" value="' + quality + '">' + 
			'<param name="menu" value="false">' + 
			'<param name=wmode value="transparent">' + 
			'<embed src="' + swf + '" wmode="transparent" menu="false" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' + 
			'</object>';
		var swfBody = document.getElementById(body);
		if(swfBody) {
			swfBody.innerHTML = content;
		} else {
			document.write(content);
		}
	}
};

$(function(){
	$("#cod").click(function(){
		$(this).attr("src","./data/vdimgck.php?" + Math.random());
	})

	$("input,textarea").not(".G_botton").each(function(){
		$(this).focus(function(){
			$(this).css({"background":"#820500","border":"1px solid #680400"});
		}).blur(function(){
			$(this).css({"background":"#8A0500","border":"1px solid #680400"});
		}).hover(function(){
			$(this).css({"background":"#820500","border":"1px solid #680400"});
		},function(){
			$(this).css({"background":"#8A0500","border":"1px solid #680400"});
		});
	});
	
	$(".borderLi").hover(function(){
		$(this).css("border-bottom","1px solid #560C0B");
		$(this).css("color","#000");
	},function(){
		$(this).css("border-bottom","1px dashed #560C0B");
		$(this).css("color","#CBC57B");
	});
	
	$("#leave_word").submit(function(){
		if($.trim($("input[name='name']").val())==''){
			alert("对不起，请填写您的姓名！");
			$("input[name='name']").focus();
			return false;
		}else if($.trim($("input[name='telephone']").val())==''){
			alert("对不起，请填写您的联系电话！");
			$("input[name='telephone']").focus();
			return false;
		}else if($.trim($("input[name='address']").val())==''){
			alert("对不起，请填写您的联系地址！");
			$("input[name='address']").focus();
			return false;
		}else if($.trim($("textarea").val())==''){
			alert("对不起，请填写留言内容！");
			$("textarea").focus();
			return false;
		}else if($.trim($("input[name='checkCode']").val())==''){
			alert("对不起，请填写验证码！");
			$("input[name='checkCode']").focus();
			return false;
		}
	});
	
	$('#aboutmenu').each(function () {
		$('ol', this).soChange({
			thumbObj: $('h2', this),
			slideTime:0,
			autoChange:false
		});
	});
	
	$("#nav li").hover(function(){$(this).children("#navXL").fadeIn("")},function(){$(this).children("#navXL, #introXLBox").fadeOut("")});
	
	$("#forTheJob").submit(function(){
		var error = 0;
		$(".inputText,textarea").each(function(){
			var val = $.trim($(this).val());
			if(val==''){
				alert("请认真填写您的信息，以便我们能更多的了解您！");
				error++;
				$(this).focus();
				return false;
			}
		});
		if(error>0){
			return false;
			$("input[error='0']").focus();
		}
	});
	
	$("#online_order").submit(function(){
		if($.trim($("input[name='name']").val())==''){
			alert("请填写您的姓名！");
			$("input[name='name']").focus();
			return false;
		}else if($.trim($("input[name='telephone']").val())==''){
			alert("请填写您的联系电话！");
			$("input[name='telephone']").focus();
			return false;
		}else if($.trim($("input[name='address']").val())==''){
			alert("请填写您的联系地址！");
			$("input[name='address']").focus();
			return false;
		}else if($.trim($("input[name='num']").val())==''){
			alert("请填写您的订购数量！");
			$("input[name='num']").focus();
			return false;
		}else if($.trim($("input[name='checkCode']").val())==''){
			alert("请填写验证码！");
			$("input[name='checkCode']").focus();
			return false;
		}
		if(!confirm("确定提交订单信息吗？")){
			return false;
		}
	});
	$("#user_order").submit(function(){
		if($.trim($("input[name='telephone']").val())==''){
			alert("请填写您的联系电话！");
			$("input[name='telephone']").focus();
			return false;
		}else if($.trim($("input[name='email']").val())==''){
			alert("请填写您的联系地址！");
			$("input[name='email']").focus();
			return false;
		}else if($.trim($("input[name='checkCode']").val())==''){
			alert("请填写验证码！");
			$("input[name='checkCode']").focus();
			return false;
		}
		if(!confirm("确定提交申请信息吗？")){
			return false;
		}
	});
	jQuery.extend({
		FlashFont:function(obj){
			//$(obj).css("color",$(obj).css("color")=="#297eae"?"#f00":"#297eae");
			//$(obj).css("color",$(obj).css("color")=="rgb(41, 126, 174)"?"rgb(255, 0, 0)":"rgb(41, 126, 174)");
			$(obj).css("color",$(obj).css("color")=="blue"?"red":"blue");
		}
	});
	setInterval("$.FlashFont('#h_telBox')",750);
})


//设为首页
function setHomepage(){
  if (document.all){
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(document.URL);
  }else if (window.sidebar){
        if(window.netscape){
       try{
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       }catch (e){
                    alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
       }
        }
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',document.URL);
    }
}
//加为收藏
function addfavor(URL,title) {
	if(confirm("网站名称："+title+"\n网址："+URL+"\n确定添加收藏?")){
		var ua = navigator.userAgent.toLowerCase();
			if(ua.indexOf("msie 8")>-1){
				external.AddToFavoritesBar(document.URL,document.title,'IT有道');//IE8
			}else{
				try {
				window.external.addFavorite(document.URL,document.title);
				} catch(e) {
			try {
				window.sidebar.addPanel(document.title, document.URL, "");//firefox
				} catch(e) {
				alert("加入收藏失败，请使用Ctrl+D进行添加");
				}
			}
		}
	}
	return false;
}

//resize image
function DrawImage(ImgD,FitWidth,FitHeight){  
    var image=new Image();  
    image.src=ImgD.src;  
    if(image.width>0 && image.height>0){  
        if(image.width/image.height>= FitWidth/FitHeight){  
            if(image.width>FitWidth){  
                ImgD.width=FitWidth;  
                ImgD.height=(image.height*FitWidth)/image.width;  
            }  
            else{  
                ImgD.width=image.width;  
                ImgD.height=image.height;  
            }  
        }  
        else{  
            if(image.height>FitHeight){  
                ImgD.height=FitHeight;  
                ImgD.width=(image.width*FitHeight)/image.height;  
            }  
            else{  
                ImgD.width=image.width;  
                ImgD.height=image.height;  
            }  
        }  
    }  
}  
