function signin()
{
	$j.ajax({
	type: "POST",
	url:"/index/login",
	data: ({username : $j('#user_name').val(),pass:$j('#user_password').val()}),
	success: function(response)
		{
			//alert(response);
			//window.location.href="/community/pg/profile/"+$j('#user_name').val();
			
			var user	=	response.split('|');
			if(user[1]=="success")
			{
				gzi_signin()
			}
			else
			{
				$j('#user_password').val("");
				$j('#login_msg').html('Incorrect Username or Password');
			}
		}
	});
return false;
}
function guest_login(url)
{
	$j.ajax({
	type: "POST",
	url:"/user/guest",
	data: ({url : url}),
	success: function(response)
		{
			//window.location.href="/community/pg/profile/"+$j('#user_name').val();
			if(response=="success")
			{
				window.location.href	=	url;
			}
		}
	});
return false;
}

function gzi_signin()
{
	$j.ajax({
	type: "POST",
	url:"/community/gziaction/login.php",
	data: ({username : $j('#user_name').val(),password:$j('#user_password').val()}),
	success: function(response)
		{
			//alert(response);
			var baseurl= $j('#baseurl').val();
			 if(baseurl=="/user/signup")
				{
					window.location.href="/index";
				}
				
				//if(window.location==$j('#baseurl').val()+"gift/#" || window.location==$j('#baseurl').val()+"redemption/gift/")
				if(window.location.pathname=="/gift/#" || window.location.pathname=="/redemption/gift/")
				 {
					window.location.reload(); 
					//listgift(1);
				 }
				else
				{
					getuserpoints();//get point here by ajax

					var linkUrl	=	"<a href='/community/pg/profile/"+$j('#user_name').val()+"' class='toplinkpart1_linkletter_login'> Welcome "+$j('#user_name').val()+"</a>";
					$j('#welcome_note').html(linkUrl);
					
					
					$j('#user_online').show();
					$j('#sliderWrap').hide();
					if($j('#review').val()=="review")
					{
						$j('#signin_div').hide();
						$j('#div_write_review').show();
						
					}
				}
		
		}
	});
return false;
}

function getuserpoints()
{
	$j.ajax({
	type: "GET",
	url:"/champions/getuserpoints",
	success: function(response)
		{
			var mySplitResult = response.split("||");
			$j('#user_points').html(mySplitResult[0]);
			$j('#user_points').show();
			$j('#dropmenu3').html(mySplitResult[1]);
		}
	});
}
function signinform()
{
	//alert("dfdf");
	$j('#errormsg').html('');
	var username	=	$j('#username').val();
	var password	=	$j('#password').val();
	$j.ajax({
	type: "POST",
	url:"/index/login",
	data: ({username : $j('#username').val(),pass:$j('#password').val()}),
	success: function(response)
		{
			//alert(response);
			var user	=	response.split('|');
			if(user[1]=="success")
			{
				gzi_signinform();
				
			}
			else
			{
				$j('#password').val("");
				$j('#errormsg').html('Incorrect Username or Password');
			}
		}
	});
return false;	
}
function gzi_signinform()
{
	var target	    =	$j('#target').val();
	$j.ajax({
	type: "POST",
	url:"/community/gziaction/login.php",
	data: ({username : $j('#username').val(),password:$j('#password').val()}),
	success: function(response)
		{
			//alert(response);
			if(target!="") {
					//alert(target);
					window.location.href=target;
					return false;
				}
				else {
					window.location.href="/index";
					return false;
				}
		}
	});
return false;
}
function communitysignin()
{
	$j.ajax({
	type: "POST",
	url:"/index/login",
	data: ({username : $j('#username').val(),pass:$j('#password').val()}),
	success: function(response)
		{
			document.myform.submit();
			return true;	
		}
	});

return false;	
}
function gziUserLogin()
{
	var username	=	$j('#username').val();
	var password	=	$j('#password').val();
	var target	    =	$j('#target').val();
	$j.ajax({
	type: "POST",
	url:"/index/login",
	data: ({username : $j('#username').val(),pass:$j('#password').val()}),
	success: function(response)
		{
			var user	=	response.split('|');
			if(user[1]=="success")
			{
				if(target!="") {
					window.location.href=target;
				}
				else {
					window.location.href="/index";
				}
			}
			else
			{
				$j('#errormsg').html('Incorrect Username or Password');
			}
		}
	});

return false;	
}
function identifySignInEnter(e) 
{
	if(e.keyCode==13){
	signin();
	}
}
function identifyEnterkey(e) 
{
	if(e.keyCode==13){
	signinform();
	}
}


