var ITr='';
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) str = str + ' '; 
  return (str == checkstr);
}
//去掉空格
function Trim(str){
 if(str.charAt(0) == " "){
  str = str.slice(1);
  str = Trim(str); 
 }
 return str;
}
//判断是否是空
function isEmpty(pObj,errMsg){
 var obj = eval(pObj);
 if( obj == null || Trim(obj.value) == ""){
  if (errMsg == null || errMsg =="")
   alert("输入为空!");
  else
   alert(errMsg); 
  obj.focus(); 
  return false;
 }
 return true;
}
//判断是否是数字
function isNumber(pObj,errMsg){
 var obj = eval(pObj);
 strRef = "1234567890";
 for (i=0;i<obj.value.length;i++) {
  tempChar= obj.value.substring(i,i+1);
  if (strRef.indexOf(tempChar,0)==-1) {
   if (errMsg == null || errMsg =="")
    alert("数据不符合要求,请检查");
   else
    alert(errMsg);
   if(obj.type=="text") 
    obj.focus(); 
   return false; 
  }
 }
 return true;
}
function Func_Chk(){
  if ($('#frm_ic_sale #key').val()==''){
      alert('请填写搜索关键字！');
      $('#frm_ic_sale #key').focus();
      return false;
  }
  else if ($('#frm_ic_sale #key').val().length()<4){
      alert('搜索关键字长度不能少于4个字符！');
      $('#frm_ic_sale #key').focus();
      return false;
  }
  return true;
}
var MaxICN=0;
function Func_Del(id){
	if(MaxICN<6){if(!confirm('您确定要删除此型号吗？'))return false;}
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=delcookie&rnd="+Math.random(),
		cache: false,
		data:'id='+id,
		dataType:"json",
		success: function(data){
			if (data.show!='')alert(data.show);
			if (data.error==0)$('#tr'+ITr+'_'+id).remove();
			if (data.error==-1){
				alert('您目前型号选择为空！');
				window.location='/';
			}
		},
		error: function(html){
			alert("页面错误！");
		}
	});
  //DelCookie(id);
  //Func_Txt_DD(id);
  return false;
}
function Func_Null(iType){
	if (iType==1){
		if(!confirm('您确定要清空型号记录吗？'))return false;
	}
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=delcookieall&rnd="+Math.random(),
		cache: false,
		dataType:"json",
		success: function(data){
			if (data.show!='')alert(data.show);
			if (data.error==0){
				alert('您目前型号已被清空！');
				window.location='/';
			}
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
function ShowGWL(){
	window.location='/ic-product-collect.html';
}
function Func_Order_Reg(){
	var PostV='';
	if($('#Uic1').is('input')){
		if(CHF('#uname','请填写登录名！'))return;
		if(CHF('#upass','请填写登录密码！'))return;
		if(CHF('#Uic1','请填写联系人！'))return;
		if(CHF('#Uic2','请填写公司名称！'))return;
		if(CHF('#Uic3','请填写公司电话！'))return;
		//if(CHF('#Uic5','请填写传真号码！'))return;
		if(CHF('#Uic6','请填写E-Mail！'))return;
		PostV=$("#frm_Main").serialize()+'&'+$("#frm_Login").serialize();
	}
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?rnd="+Math.random(),
		cache: false,
		data:PostV,
		dataType:"json",
		success: function(data){
			if (data.show!='')alert(data.show);
			if (data.error==0)window.location='myorder-step2.html';
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
function Func_UserReg(){
	var PostV='';
	if($('#Uic1').is('input')){
		if(CHF('#uname','请填写登录名！'))return;
		if(CHF('#upass','请填写登录密码！'))return;
		if(CHF('#Uic1','请填写联系人！'))return;
		if(CHF('#Uic2','请填写公司名称！'))return;
		if(CHF('#Uic3','请填写公司电话！'))return;
		//if(CHF('#Uic5','请填写传真号码！'))return;
		if(CHF('#Uic6','请填写E-Mail！'))return;
		PostV=$("#frm_Login").serialize();
	}
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=userreg&rnd="+Math.random(),
		cache: false,
		data:PostV,
		dataType:"json",
		success: function(data){
			if (data.show!='')alert(data.show);
			if (data.error==0)Func_CHKLogin();
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
function CHF(ipt,info){
	if ($(ipt).val()==''){
		alert(info);
		$(ipt).focus();
		return true;
	}
	else
		return false;
}
function Func_Order_Login(){
	var PostV='';
	if($('#Lic1').is('input')){
		if(CHF('#Lic1','请填写联系人！'))return;
		if(CHF('#Lic2','请填写公司名称！'))return;
		if(CHF('#Lic3','请填写公司电话！'))return;
		//if(CHF('#Lic5','请填写传真号码！'))return;
		if(CHF('#Lic6','请填写E-Mail！'))return;
		PostV=$("#frm_Main").serialize()+'&'+$("#frm_Login").serialize();
	}
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=loginsubmit&rnd="+Math.random(),
		cache: false,
		data:PostV,
		dataType:"json",
		success: function(data){
			if (data.show!='')alert(data.show);
			if (data.error==0)window.location='myorder-step2.html';
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
var isLoginEd=false;
var isLoginName='';
function Func_CHKLogin(){
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=quickloginchk&rnd="+Math.random(),
		cache: false,
		dataType:"json",
		success: function(data){
			if (data.error==0){
				isLoginEd=true;
				$('#Mic1').val(data.uName);
				isLoginName=data.uName;
	            $('#fore2').html('<a href="myorder.html" target="_blank">我的订单</a>');
				$('#order_goto').attr('title','欢迎您:'+isLoginName);
				$('#idunLogined').hide();
				$('#id_loginName').html(isLoginName);
				$('#idLogined').show();
			}
			else{
				isLoginEd=false;
				$('#idLogined').hide();
				$('#idunLogined').show();
			}
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
function FuncT_Login(){
    $('#ID_Login_1').removeClass('cTunsel').addClass('cTsel');
    $('#ID_Login_2').removeClass('cTsel').addClass('cTunsel');
    $('#ID_Order').hide();
	if (isLoginEd){
		$('#ID_Login').hide();
		$('#ID_Order_Login').show();
	}
	else{
		$('#ID_Order_Login').hide();
		$('#ID_Login').show();
	}
}
var isReg=false;
function reg(This){
	isReg=true;
	TL_ShowBoxURL("免费注册","iframe/user_reg.html",400,420);
}
function login(This){
	isReg=true;
	TL_ShowBoxURL("登录用户","iframe/user_login.html",400,420);
}
function Func_JS(This){
	isReg=false;
	if (isLoginEd)
		window.location='myorder-step2.html';
	else
		TL_ShowBoxURL("结算","iframe/user_submit_corp.html",400,370);
}
function regedit(This){
	TL_ShowBoxURL("修改资料","iframe/user_edit_corp.html",400,340);
}
function loginout(ty){
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=loginout&rnd="+Math.random(),
		cache: false,
		dataType:"json",
		success: function(data){
			if (data.error==0){
				$('#idLogined').hide();
				$('#idunLogined').show();
				$('#id_loginName').html('');
				$('#order_goto').attr('title','您尚未登录');
				isLoginEd=false;
				$('#fore2').html('<a href="#" onclick="alert(\'请登录!\');return false;">我的订单</a>');
				if(ty==1)window.location='/';
			}
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}

function Func_EditKNum(sid){
    var num=$('#ID_'+sid).val();
	$.ajax({
		type: "POST",
		url: "/IC_Sale_Save.asp?action=editordernum&num="+num+"&id="+sid+"&rnd="+Math.random(),
		cache: false,
		dataType:"json",
		success: function(data){
            if (data.show!='')alert(data.show);
			if (data.error==1){$('#ID_'+sid).focus();}
		},
		error: function(html){
			alert("页面错误！");
		}
	});
}
