function add_fav() { 

	var url = "http://www.9daiyu.com";
	var title = "翡翠传家宝-云南玖代珠宝有限公司-9daiyu.com";		

	var ua = navigator.userAgent.toLowerCase(); 
	if(ua.indexOf("msie 8")>-1){			
		try { 
				window.external.AddToFavoritesBar(url,title,null);//IE8 
			} catch(e) { 
				alert("加入收藏失败，请使用Ctrl+D进行添加"); 
			} 
	}else{ 
		try { 
			window.external.addFavorite(url, title); 
		} catch(e) { 
			try { 
				window.sidebar.addPanel(title, url, "");//firefox 
			} catch(e) { 
				alert("加入收藏失败，请使用Ctrl+D进行添加"); 
			} 
		}
	}
	
} 

function addBookmark(url, title) {  
 
    var ua = navigator.userAgent.toLowerCase(); 
	if(ua.indexOf("msie 8")>-1){			
		try { 
				window.external.AddToFavoritesBar(url,title,null);//IE8 
			} catch(e) { 
				alert("加入收藏失败，请使用Ctrl+D进行添加"); 
			} 
	}else{ 
		try { 
			window.external.addFavorite(url, title); 
		} catch(e) { 
			try { 
				window.sidebar.addPanel(title, url, "");//firefox 
			} catch(e) { 
				alert("加入收藏失败，请使用Ctrl+D进行添加"); 
			} 
		}
	}  
}


function checkAll(form)
{
	//alert(form.elements);
	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[1] + '-' + aDate[2] + '-' + aDate[0]);//转换为12-18-2009格式 
	//aDate = sDate2.split("-");
	//oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
	oDate1 = new Date(sDate1);
	oDate2 = new Date(sDate2);
	if(oDate1>=oDate2) { alert("结束日期不能小于开始日期。"); 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 goto(url){
	var ie='\v'=='v'?1:0;
	if(ie==1)
	{
		window.location.href(url);
	}
	else
	{
		window.location.href=url;
	}

}


//获取元素的竖坐标 
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;

}


//-------------- 自动刷新页面 ---------------
var parselimit = 15;

function html_fresh(){ 	
	if (parselimit==1) {		
		window.location.reload();
	}else{  
		parselimit-=1; 		
		setTimeout("html_fresh()",1000) 
	} 
} 





 
//---- 通过ID号打开新网页查看产品 --------------
 
$(document).ready(function(){
	$("#view_product").bind("click",function(){		
		var id = $("#product_id").val();
		if(id == ''){ 
			$("#product_id").focus();
			alert('ID号不能为空');
			return false;
		}
		
		var sFeatures = "height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=n o, status=no";	
		window.open( '/product.php?id='+id, '产品详情', sFeatures );
	});
	
	$("#edit_product").bind("click",function(){		
		var id = $("#product_id").val();
		if(id == ''){ 
			$("#product_id").focus();
			alert('ID号不能为空');
			return false;
		}
		
		var sFeatures = "height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=n o, status=no";	
		window.open( 'product_edit.php?act=modi&id='+id, '产品详情', sFeatures );
	});
	
	$(".one_tr").bind("mouseover",function(){	
		$(this).children("td").css({"background-color":"#F4FAFF"});
	});
	
	$(".one_tr").bind("mouseout",function(){
		$(this).children("td").css({"background-color":"#FFFFFF"});
	});
	
	$(".one_tr2").bind("mouseover",function(){	
		$(this).children("td").css({"background-color":"#FFF9EC"});
	});
	
	$(".one_tr2").bind("mouseout",function(){
		$(this).children("td").css({"background-color":"#FFFFFF"});
	});
	
	
	//会员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 );
		   }
		});
	});
	
	
	$(".price_in").bind('dblclick',function(){	
		var type = $(this).attr('type');
		var pcode;
		var pid = $(this).attr('pid');
		
		if(type == 'text')
			pcode = $(this).val();
		else
			pcode = $(this).html();
		//alert(type);
		
		$.ajax({
		   type: "POST",
		   url: "/admin/pcode.php",
		   data: "pcode=" + pcode,
		   success: function(msg){
			 alert(msg);
			 //if(type=='text')$('#'+pid).val(msg); else $('#'+pid).html(msg); 
		   }
		});
	});

})
