//检查form
$(function(){
	$("#myform").submit(function(){
		var err=0;
		var count=0;
		//必填项
		$("#myform td:contains('*')").each(function(){
			if($(this).children(":first-child").val()==""){
				err=1;
			}
		});
		//必为整数项
		$("#myform td:contains('必须为整数')").each(function(){
			var PI=$(this).children(":first-child").val();
			if(parseInt(PI)!=PI)
			{
				err=3;
			}
		});
		//选填项
		$("#myform td:contains('选填')").each(function(){
			if($(this).children(":first-child").val()==""){
				count++;
			}
		});
		if(count>=$("#myform td:contains('选填')").length&&count!=0)
		{
			err=2;
		}
		//对比各项
		var i=0;
		var v = new Array()
		$("#myform td:contains('相等')").each(function(){
			v[i]=$(this).children(":first-child").val()
				i++;
		});
		var comv=v[0];
		for (k in v)
		{
			if(v[k]!=comv)
			{
				err=4;
				break;
			}
		}
		
		if(err==1){
			alert("带*的是必填项！");
			return false;
		}
		else if(err==2)
			{
			alert("标记“选填”的各项必须选填一项或一项以上！");
			return false;
			}
			else if(err==3)
				{
				alert("标记“必须为整数”必须为整数！");
				return false;
				}else if(err==4)
					{
					alert("标记“相等”各项必须为相同");
					return false;
					}else
					{
					return true;
					}
	});
});
$(function(){
	$("#AddFavorite").click(function(){
		window.external.AddFavorite("http://www.cnhyjs.com.cn","市政工程，水水电利工程，道路工程，园林绿化工程，室内装饰工程——嘉兴市宏宇建设有限公司");
	});
	$("#homepage").click(function(){
		if (document.all)
		 {
		 document.body.style.behavior='url(#default#homepage)';
		 document.body.setHomePage("www.cnhyjs.com.cn");
		 }
		 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',"www.cnhyjs.com.cn");
		 }
	});
});
$(function(){
	var i=1;
	$("#cates li[msg!='submenu']").each(function(){
		var id=$(this).attr("id");
		var subid=id.replace("cate","par");
		$(this).hover(function(){
			$("#"+subid).fadeIn(500);
		},function(){
			$("#"+subid).fadeOut(500);
		});
	});
});

$(function(){
	$("#newsMenu li[msg='1']").css("background","#E0E0E0");
	$("#newsMenu li[msg!='1']").mouseover(function(){
		$(this).css("background","#E0E0E0");
	});
	$("#newsMenu li[msg!='1']").mouseout(function(){
		$(this).css("background","#fff");
	});
	$("#procat li[msg='1']").css("background","url(images/triangle.gif) 15px center no-repeat #ccc");
	$("#procat li[msg!='1']").mouseover(function(){
		$(this).css("background","url(images/triangle.gif) 15px center no-repeat #ccc");
	});
	$("#procat li[msg!='1']").mouseout(function(){
		$(this).css("background","url(images/triangle.gif) 15px center no-repeat #F0F0F0");
	});
	$("#newslist li").mouseover(function(){
		$(this).removeClass("newsoff");
		$(this).addClass("newson");
	});
	$("#newslist li").mouseout(function(){
		$(this).removeClass("newson");
		$(this).addClass("newsoff");
	});
	$("#joblist tr:odd").css("background","#EFEFF1");
});
