function seccode(){	
		
		var showobj = $('seccodeverify');
		var menuobj = $('seccodeshow');
		
		$("seccodeshow").className='seccodeshow';
	
		if ($("seccodeshow").style.display == 'none'){	
			var showobj_pos = fetchOffset(showobj);
			var showobj_x = showobj_pos['left'];
			var showobj_y = showobj_pos['top'];
			var showobj_w = showobj.offsetWidth;
			var showobj_h = showobj.offsetHeight;
			
	
			menuobj.style.left =showobj_x + 'px';
			menuobj.style.top = (showobj_y-parseInt(menuobj.style.height)-4)+ 'px';
		}
		$("seccodeshow").style.display='';
		showobj.focus();
		var Ax = new ajax();
		Ax.succecshow = function (strValue){
			$("seccodeshow").innerHTML =  strValue;			
		};
		Ax.method 	= "GET";
		Ax.targeturl		= "ajax.php?action=seccode";
		Ax.actiontype		= true;
		Ax.charset	= ajaxcharset;
		Ax.send();

}



function getseccode(){
	
	if ($('seccodeshow').innerHTML=='')	{
		seccode();
	}else{
		if ($('seccodeshow').style.display=='none')	{
			$('seccodeshow').style.display=''
		}
		 
	}
}
function checkcar(){
	var check = new ajax();
	check.succecshow = function(strValue){
		$('shopingcar').innerHTML = '<a href="deal.php">'+strValue+'</a>';
	};
	check.method 	= "GET";
	check.targeturl		= cmspath+"add_to_cart.php?ajax=4";
	check.actiontype		= true;
	check.charset	= ajaxcharset;
	check.send();
	checkoncart();
}

function checkoncart(){
	var ck = new ajax();
	ck.succecshow = function(strValue){

		if (strValue !="")	{
			var ids=strValue.split(',');
			for (i=0;i<ids.length ;i++ ){
				
				if ($('addtocart_'+ids[i]))	{
					$('addtocart_'+ids[i]).className='addtocart_on';
				}
				
			
			}
		}

	};
	ck.method 	= "GET";
	ck.targeturl		= cmspath+"ajax.php?ajax=1&action=checkcart";
	ck.actiontype		= true;
	ck.charset	= ajaxcharset;
	ck.send();
}

function login(){
	var postvalues="";
	
	postvalues +="ajax=1&";
	if(useseccode>0){
		postvalues +=$("seccodeverify").name+"="+$("seccodeverify").value+"&";
	}

	postvalues +=$("username").name+"="+$("username").value+"&";
	postvalues +=$("password").name+"="+$("password").value+"&";
	postvalues +=$("referer").name+"="+$("referer").value;
	postvalues +=$("formhash").name+"="+$("formhash").value;
	var A = new ajax(); 

	A.succecshow = function (strValue){
	if (strValue == 'True')	{	
		$('loginbox').style.display = 'none';	
		$('usercp').style.display = '';

	}else{
		$('loginbox').style.display = '';
		$('usercp').style.display = 'none';
		seccode();
		alert(strValue);
		
	}
	
	checkcar();
};

	A.method 	= "POST";
	A.targeturl		= "loggin.php?action=loggin&logsubmit=yes";
	A.actiontype		= true;
	A.postdatas		= postvalues;
	A.charset	=  ajaxcharset;
	A.send();
	return false;
}
function logout(){
	var check = new ajax();
	check.succecshow = function(strValue){

		$('loginbox').style.display = 'block';
		$('usercp').style.display = 'none';
		$('password').value = '';
		if(useseccode>0){
			$('seccodeverify').value = '';
			seccode();
		}
		checkcar();
	};
	check.method 	= "GET";
	check.targeturl		= cmspath+"loggin.php?action=logout&ajax=1";
	check.actiontype		= true;
	check.charset	= ajaxcharset;
	check.send();
	return false;
}

function checklogin(){
	var ck = new ajax();
	ck.succecshow = function(strValue){	
	
		 if (strValue != ''){
			$('usercp').style.display = '';
			$('loginbox').style.display = 'none';
		
		 }else{
			$('loginbox').style.display = 'block';
	
		 }
		 checkcar();
		
	};
	ck.method 	= "GET";
	ck.targeturl		= "ajax.php?action=checklogin&ajax=1";
	ck.actiontype		= true;
	ck.charset	= ajaxcharset;
	ck.send();

}

	function renewcode(innername){
	var Ax = new ajax();
	Ax.succecshow = function (strValue){
	$(innername).innerHTML =  strValue;			
	};
	Ax.method 	= "GET";
	Ax.targeturl		= "ajax.php?action=seccoder";
	Ax.actiontype		= true;
	Ax.charset	=  ajaxcharset;
	Ax.send();
	}


	function addtocar(cid){
	var postvalues="";
	postvalues +="ajax=1&";
	postvalues +=$("formhash").name+"="+$("formhash").value;
	var A = new ajax(); 
	A.succecshow = function (strValue){
		
		$('shopingcar').innerHTML = '<a href="deal.php">'+strValue+'</a>';
		$('addtocart_'+cid).className='addtocart_on';
	};
	A.method 	= "POST";
	A.targeturl		= "add_to_cart.php?id="+cid+"&addnew=yes";
	A.actiontype		= true;
	A.postdatas		= postvalues;
	A.charset	= ajaxcharset;
	A.send();	
		return false;
}

function delfromcart(key){
	window.location='deal.php?del='+key;
return false;
}

function loginform(){
var postvalues="";
$("tips").innerHTML="";
postvalues +="ajax=1&";
if(useseccode>0){
	postvalues +=$("seccodeverify").name+"="+$("seccodeverify").value+"&";
}
postvalues +=$("username").name+"="+$("username").value+"&";
postvalues +=$("password").name+"="+$("password").value+"&";
postvalues +=$("referer").name+"="+$("referer").value;
postvalues +=$("formhash").name+"="+$("formhash").value;
var A = new ajax(); 
A.interror 	= function (strValue){
$("tips").innerHTML = strValue;
};
A.stateinfo 	= function (strValue){
$("tips").innerHTML =  strValue;
};
A.succecshow = function (strValue){
if (strValue == 'True')	{
	window.location='user_center.php';
}else{
	seccode();
	$("tips").innerHTML =strValue;
}

};
A.method 	= "POST";
A.targeturl		= "loggin.php?action=loggin&logsubmit=yes";
A.actiontype		= true;
A.postdatas		= postvalues;
A.charset	= ajaxcharset;
A.send();
return false;
}	


