
(function()
{
	UNLOCKCLUB = (
	  {
		  currentDate: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=currentdate',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#CurrenDdate").html(rs);	 					  
				  }
			  });
		  },
		  
		  getOnlineUser: function(c_name)
		  {
				if(document.cookie.length>0)
				{
					c_start=document.cookie.indexOf(c_name + "=");
					if(c_start!=-1)
					{
						c_start=c_start + c_name.length+1;
						c_end=document.cookie.indexOf(";",c_start);
						if (c_end==-1) c_end=document.cookie.length;
						return unescape(document.cookie.substring(c_start,c_end));
					}
				}		
				return "";
		  },
		  
		  setHeader: function(currentpage)
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=header&currentpage='+currentpage,
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#Header").html(rs);				  
				  }
			  });
		  },
		  
		  setTopTab: function(currentpage)
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=toptab&currentpage='+currentpage,
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#TopTab").html(rs);				  
				  }
			  });
		  },
		  
		  setFooter: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=footer',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#Footer").html(rs);				  
				  }
			  });
		  },
		
		 getState: function(cid)
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=getstate&cid='+cid,
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#stateDiv").html(rs);				  
				  }
			  });
		  },

		setRegister: function()
		  {
			
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=register',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#ContentDiv").html(rs);				  
				  }
			  });
		  },
		
		
			
		  
		  setTestimonials: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=testimonials',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#ContentDiv").html(rs);				  
				  }
			  });
		  },

		setServices: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=services',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#ContentDiv").html(rs);				  
				  }
			  });
		  },
		  
		  setFeatures: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=features',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#ContentDiv").html(rs);				  
				  }
			  });
		  },
		  
		  testimonialsIndex: function()
		  {
			  jQuery.ajax(
			  {
				  type:'post',
				  data:'action=testimonialsindex',
				  url:'rootaction.php',
				  success: function(rs)
				  {
					 jQuery("#TestiMonialsDiv").html(rs);				  
				  }
			  }); 
		  },
		  
		  alert: function()
		  {
		  		var vars = [], hash;
    			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    			for(var i = 0; i < hashes.length; i++)
   		 	{
        			hash = hashes[i].split('=');
					
					if(hash[0]=="msg")
					{   
						     				        				
        				alert(decodeURIComponent(hash[1]));
        			}	
    			}
    		}	  
	  });
	
})(jQuery);

(function()
{
	UNLOCK_CONTACTUS = ({
	
	error:false,
	postdata:'',
	processContactMail: function()
	{
		this.validatePostDate();
		
		if(!this.error)
		{
			UNLOCK_LOADER.show();
			this.getPostData();
			
			jQuery.ajax({
			
				type: 'post',
				data: this.postdata,
				url:  '/rootaction.php',
				success: function(rs)
				{
					UNLOCK_LOADER.hide();
					if(rs=='')
					{
						jQuery("#email").val("");
						jQuery("#subject").val("");
						jQuery("#message").val("");
						
						alert("Mail has been sent successfully");	
					}
					else alert(rs);
				}				
			});
		}
	},
	
	validatePostDate: function()
	{		
		var errors = new Array();
		
		var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
		
		if(!regex.test(jQuery("#email").val()))
		{
			errors[errors.length] = '- Email address';
		}
		
		if(jQuery("#subject").val()=='')
		{
			errors[errors.length] = '- Subject';
		}
		
		if(jQuery("#message").val()=='')
		{
			errors[errors.length] = '- Message';
		}
		
		if(errors.length > 0)
		{
			this.error = true;
			alert('Following fields have invalid value \n\n'+errors.join('\n'));
		}
		else
		{
			this.error = false;
		}
		
	},
	
	getPostData: function()
	{
		this.postdata	= 'subject='+	this.addslashes(jQuery("#subject").val());
		this.postdata	+= '&message='+	this.addslashes(jQuery("#message").val());
		this.postdata	+= '&email='+	this.addslashes(jQuery("#email").val());
		this.postdata	+= '&action=contactus';
	},
	
	addslashes: function(str)
	{
		return escape(str);	
	}
	
	});
	
})(jQuery);


(function()
{
	UNLOCK_LOADER  = ({
					  
	/*
	<div id="LoaderDiv" style="width:235px; border:3px solid #3D92AD; padding:30px 20px; z-index:9999; top:150px; position:fixed; background:#FFFFFF; display:none">
	<span style="display:block; margin-right:15px; float:left"><img id="loaderImage" src="/images/client/wait_root.gif" /></span>
	<span style="display:block; padding-top:5px; float:left; font-weight:bold; color:#3D92AD">Please Wait...</span>
	<div style="clear:both"></div>
	</div>
	<div id="MaskDiv" style="z-index:9999; position:fixed; background:#FFFFFF;"></div>
	*/
					  
	
	show: function()
	{
		var w = jQuery(document).width();
		var h = (jQuery(document).height() > jQuery(window).height()) ? jQuery(document).height() : jQuery(window).height();
		jQuery("#MaskDiv").css({left:0, top:0, width:w, height:h, opacity:0.10}).css({display:'block'}).show(function()
		{
			UNLOCK_LOADER.loader();
		});		
	},
	
	loader: function()
	{
		var leftPosition = (jQuery(window).width()/2)-(jQuery("#LoaderDiv").width()/2);
		
		jQuery("#LoaderDiv").css({left:leftPosition, opacity:1}).css({display:'block'});
	},
	
	
	hide: function()
	{
		/*jQuery("#LoaderDiv").hide();
		jQuery("#MaskDiv").hide();
		*/
		jQuery("#LoaderDiv").css({display:'none'});
		jQuery("#MaskDiv").css({display:'none'});
	},
	
	default_hide: function()
	{
		jQuery("#LoaderDiv").hide();
		jQuery("#MaskDiv").hide();
	}
	
	});
	
})(jQuery);

(function()
{
	UNLOCK_MSG  = ({
	
	show: function(msg)
	{
		/*var w = jQuery(document).width();
		var h = (jQuery(document).height() > jQuery(window).height()) ? jQuery(document).height() : jQuery(window).height();
		jQuery("#MessageMaskDiv").css({left:0, top:0, width:w, height:h, opacity:0.10}).css({display:'block'}).show(function()
		{*/
			UNLOCK_MSG.loader(msg);
		//});		
	},
	
	loader: function(msg)
	{
		var leftPosition = (jQuery(window).width()/2)-(jQuery("#MessageDiv").width()/2);
		jQuery("#MessageContent").html(msg);
		jQuery("#MessageDiv").css({left:leftPosition, opacity:1}).css({display:'block'});
	},
	
	
	hide: function()
	{		
		alert(1);
		jQuery("#MessageDiv").css({display:'none'});
		jQuery("#MessageMaskDiv").css({display:'none'});
	}
	
	});
	
})(jQuery);

(function()
{
	UNLOCK_PASSWORD = ({
	
	processForgotPassword: function()
	{
		UNLOCK_LOADER.show();
		
		jQuery.ajax({
			
				type: 'post',
				data: 'action=processpassword&email_address='+jQuery("#email_address").val(),
				url:  '/rootaction.php',
				success: function(rs)
				{
					UNLOCK_LOADER.hide();
					alert(rs);					
				}				
			});
	}	
	
	});
})(jQuery);
