function checkAll(form)
{
	//alert(form);
	for (var i=0;i<form.elements.length;i++)
	{
	var e = form.elements[i];
	if (e.name != 'SELECTALL')
	e.checked = form.SELECTALL.checked;
	}
}


function submitForm(form)
{
	var rs=window.confirm("是否操作?");
	if(rs==true)form.submit();
}


// 计算两个日期的间隔天数 
function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2009-12-18格式 
	var aDate, oDate1, oDate2, iDays;
	aDate = sDate1.split("-");	
	oDate1 = new Date(aDate[0], aDate[1], aDate[2]);//转换为12-18-2009格式 
	aDate = sDate2.split("-");
	oDate2 = new Date(aDate[0], aDate[1], aDate[2]);	
	//oDate1 = new Date(sDate1);
	//oDate2 = new Date(sDate2);
	//alert(oDate1 +'|'+ oDate2);
	if(oDate1>=oDate2) { alert("结束日期"+sDate2+"不能小于开始"+sDate1+"日期。"); return false; }
	iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24);//把相差的毫秒数转换为天数 
	
	return iDays;
}


//------------姓名身份证--------------

var  nameid = {

	init:function(eid,n,str){		
		this.eid = eid;		
		if(str!=''){ this.str = str; this.a = str;}		
		this.create(n);
	},

	//a   : '<div><br>姓名：<input name="name[]" id = "name[]">身份证号码：<input name="name[]" id="id[]">[<u onclick="delnameid(this)">删除</u>]</div>',
	a   : '<div><br>姓名：<input name="name[]" size=20 id = "name[]">身份证号码：<input name="certid[]" size=30 id="certid[]"></div>',

	str : '',

	eid : 'nameid_area',

	n   : 0,
	
	create:function (n){		
		for(i=0;i<n;i++) this.str += this.a;
		$("#"+this.eid).html(this.str);	
		this.n = parseInt(this.n)+n;		
	},
	
	modi:function(n){		 
		if(n>parseInt(this.n)) this.add(n-this.n);
		if(n<parseInt(this.n)) this.del(this.n-n);		
	},

	add: function(n){
		this.str = $("#"+this.eid).html();
		for(i=0;i<n;i++){ this.str += this.a;}
		$("#"+this.eid).html(this.str);		
		this.n = parseInt(this.n)+n;
		
	},

	del:function(n){		
		this.str = $("#"+this.eid).html().toLowerCase().split('<br>',this.n-n+1).join('<br>');
		$("#"+this.eid).html(this.str);
		this.n = parseInt(this.n)-n;
	},

	delthis :function(id){		
		id.parent().remove();
		this.n = parseInt(this.n)-1;

	}

}

function addBookMark(url, title) {   
    if (window.sidebar) {    
        window.sidebar.addPanel(title, url,"");    
    } else if (document.all) {   
        var external = window.external;   
        external.AddFavorite(url, title);   
    } else if (window.opera && window.print) {   
        return true;   
    }   
}


function SetHome(obj,url){
	try { 
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url); 
	} catch(e) { 
		if(window.netscape) { 
			try { 
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			} catch (e) { 
				alert("此操作被浏览器拒绝！");
			}
			
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
			prefs.setCharPref('browser.startup.homepage',url); 
		} 
	} 
}


function goto(url){
	var ie='\v'=='v'?1:0;
	if(ie==1)
	{
		window.location.href(url);
	}
	else
	{
		window.location.href=url;
	}

}

//会员ajax登录

$("#AJAX_LOGIN").bind('click',function(){	
	var member = $("#member").val();
	var pass = $("#pass").val();
	var chcode = $("#chcode").val();
	$.ajax({
	   type: "POST",
	   url: "/member/member_login_ajax.php",
	   data: "member=" + member + "&pass=" + pass + "&chcode=" + chcode,
	   success: function(msg){
		 if(msg == 1 )alert( "登录成功，请刷新当前页面！" );
		 else
		 alert( msg );
	   }
	});
});



//获取元素的竖坐标 
function getTop(e){
	var offset=e.offsetTop;
	if(e.offsetParent!=null){ 
		offset+=getTop(e.offsetParent); //递归
		//alert(offset);
	}
	return offset;
}


function getLeft(e){

	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); //递归
	return offset;

}

function confirmLink(theLink,confirmMsg)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)   
    
    var is_confirmed = confirm(confirmMsg); 
    return is_confirmed;
} // end of the 'confirmLink()' function
