
/* For Front User Login Starts */
	j(document).ready(function(){
				
		j('#errormsg').hide();
		j("#forgot-password").mouseout(function(){
			j("body").bind('click',hideit);										   
		});
			
		j("#openForgotPass").mouseover(function(){
			j("body").unbind('click',hideit);										   
		});
		j("#forgot-password").mouseover(function(){
			j("body").unbind('click',hideit);										   
		});
		
		j('#testimonial-content').cycle({ 
		fx:     'fade', 
		timeout: 6000, 
		delay:  -2000 
		});
	});

	function hideit()
	{
		j('#errormsg').hide();
		j("#forgot-password").hide();		  
	}

	function GetLoginUser(formID)
	{
		
		j('#myusername').html('');
		j('#mypassword').html('');
		j('#TransMsgDisplay').html('');
		
		
		var is_emptyEmail 		= 'N';
		var is_emptyPassword 	= 'N';
		if(j('#Email').val()=='' || j('#Email').val() == "Enter your email")
		{
			j('#myusername').html('Please enter Email');
			is_emptyEmail = 'Y';
		}
		else if(!j('#Email').emailCheck())
		{
			j('#myusername').html('Please enter Valid Email');
			is_emptyEmail = 'Y';
		}
		if(j('#Password').val()=='' || j('#Password').val() == "Password")
		{
			j('#mypassword').html('Please enter Password');
			is_emptyPassword = 'Y';
		}
		
		if(is_emptyEmail== 'Y' || is_emptyPassword== 'Y')
		{
			return false;
		}
		var frmID='#'+formID;
				var params ={
					'module': 'user',
					'action': 'login'
				};
				var paramsObj = j(frmID).serializeArray();
				j.each(paramsObj, function(i, field){
					params[field.name] = field.value;
				});
				
			j('#myusername').html('<img src="images/ajax-loader.gif" align="middle">');	
			j.ajax({
					type: "POST",
					url: ajaxUrl,
					data: params,
					dataType: 'json',
					success: function(data){
						if(data.flag)
						{
								j('#myusername').html('');
								window.location.href=data.loggedRedirect;
								//alert(data.loggedRedirect);
						}
						else
						{
							j('#myusername').html('Authentication failed');
						}
					}
			});
			return false;
	
	}

	function ForgotPassword(formID)
	{
		if(j('#email_send').val()=='' || j('#email_send').val() == "Enter your email")
		{	
			j('#errormsg').show();
			j('#errormsg').html('Please enter your Email');
			return false;
		}
		else if(!j('#email_send').emailCheck())
		{
			j('#errormsg').show();
			j('#errormsg').html('Please enter valid email address');
			return false;
		}
		
		j('#errormsg').html('<img src="images/ajax-loader.gif" align="middle">');	
		var frmID='#'+formID;
		var params ={
			'action': 'forgotPassword'
		};
		var paramsObj = j(frmID).serialize();
		j.ajax({
					type: "POST",
					url: 'forgotuserpass_process.php?action=forgotPassword',
					data: paramsObj,
					dataType: 'json',
					success: function(data){
						if (data.flag == 1)
						{
								j('#errormsg').show();
								j('#errormsg').html(data.html);
						}
						else
						{
							j('#errormsg').show();
							j('#errormsg').html(data.html);
						}
					}
			});
		
	
	}
	
	function Usersubmitbyenter(formid,myfield, e, dec)
	{
		
		var key;
		var keychar;
		if (window.event)
		key = window.event.keyCode;
		else if (e)
		key = e.which;
		else
		return true;		
		if (key==13)
		{		
			GetLoginUser('frmLogin');		
		}	
	}

/* For Front User Login Ends */



	function RemoveFromCart()
	{
		j('#errmsg').html('');
		var id = j('#price_id :selected').val();
		
		if(id == '' || id == 0)
		{	
			j('#errmsg').html("Please select duration");
			return false;
		}
		j('#errmsg').html('<img src="images/ajax-loader.gif" align="middle" border="0">');	
				var params ={
					'action': 'RemoveFromoCart',
					'id':	id
					};
		j.ajax({
				type: "POST",
				url: 'handleAjax.php',
				data: params,
				dataType: 'json',
				success: function(jData){
					if(jData.flag == 2)
						j('#errmsg').html(jData.html);
					if(jData.flag == 1)
					{
						//j('#add-tocart').html('<div style="color:white;">'+jData.question_bank+'----'+jData.duration+'----'+jData.price+'</div>');
						j('#errmsg').html(jData.html);
						j('#addToCartButton').html('<input name="" class="add-tocartbttn" type="button" onclick="AddToCart()"/>');
					}
				}
			});
	}


	function CheckOut()
	{
		var params ={
					'action': 'CheckOut'
					};
				j.ajax({
					type: "POST",
					url: 'handleAjax.php',
					data: params,
					dataType: 'text',
					success: function(data){
						j('#errmsg').html(data);
						}
					});

	}

