$(document).ready(function () 
{
	
	///  The code begins for the quick search in the member album area
	
	$('#quick_search_open').hide();
	$('#quick_search').click(function()
	{  
	$('#quick_search_open').fadeIn("slow");
	});
	
	$('#Close_quick_search').click(function()
	{  
	$('#quick_search_open').hide();
	});
	
	/// The code begins for  user information edit area for general information
	
	$('#edit_general_info_area').hide();
	$('#Edit_gen_info').click(function()
	{  
	$('#edit_general_info_area').fadeIn("slow");
	});
	
	$('#Close_edit_gen_info').click(function()
	{  
	$('#edit_general_info_area').hide();
	});
	
	/// The code ends for  user information edit area for general information
	
	/// The code begins for  user information edit area for professinol information
	
	$('#professinol_edit_info').hide();
	$('#Edit_professnol_info').click(function()
	{  
	$('#professinol_edit_info').fadeIn("slow");
	});
	
	$('#Close_edit_profes_info').click(function()
	{  
	$('#professinol_edit_info').hide();
	});
	
	/// The code ends for  user information edit area for professinol information
	
	
	/// The code begins for  user information edit area for personal information
	
	$('#personal_edit_info').hide();
	$('#Edit_Personal_info').click(function()
	{  
	$('#personal_edit_info').fadeIn("slow");
	});
	
	$('#Close_edit_personal_info').click(function()
	{  
	$('#personal_edit_info').hide();
	});
	
	/// The code ends for  user information edit area for personal information
	
	
	/// The code begins for  user information edit area for personal information
	
	$('#Edit_personal_info').hide();
	$('#Edit_personal_info').click(function()
	{  
	$('#Edit_personal_info_show').fadeIn("slow");
	});
	
	$('#Close_edit_perso_info').click(function()
	{  
	$('#Edit_personal_info_show').hide();
	});
	
	/// The code ends for  user information edit area for personal information
	
	//// Registration validation begins
	$('#ferror').hide();
	$('#lerror').hide();
	$('#doberror').hide();
	$('#emailerror').hide();
	$('#passworderror').hide();
	$('#confirmpassworderror').hide();
	$('#mobileerror').hide();
	$('#mobileerror1').hide();
	$('#cityerror').hide();
	$('#generror').hide();
	$('#userreg1').click(function()
	{ 
		var str="";
		re = /^.+\@.+\..{2,4}$/gi;
		var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
		var username=document.profile_reg1.uname.value.replace(/^\s+|\s+$/g,'');
		var email=document.profile_reg1.email.value;
		var firstname=document.profile_reg1.fname.value;
		var lastname=document.profile_reg1.lname.value;
		var password=document.profile_reg1.password.value.replace(/^\s+|\s+$/g,'');
		//var confirmpassword=document.profile_reg1.confirmpassword.value.replace(/^\s+|\s+$/g,'');
		var mobile=document.profile_reg1.mobile.value;
		var year=document.profile_reg1.year.value;
		var month=document.profile_reg1.month.value;
		var day=document.profile_reg1.day.value;
		var country=document.profile_reg1.country.value;
		//var state=document.profile_reg1.state.value;
		var city=document.profile_reg1.city.value;
		var msg=document.getElementById("msg").innerHTML.replace(/^\s+|\s+$/g,'');
		var msg2=document.getElementById("msg2").innerHTML.replace(/^\s+|\s+$/g,'');
		var mob=document.getElementById("mob").innerHTML.replace(/^\s+|\s+$/g,'');
		var dat=document.getElementById("dayerror1").innerHTML.replace(/^\s+|\s+$/g,'');
		var pas=document.getElementById("passworderror1").innerHTML.replace(/^\s+|\s+$/g,'');
		if(firstname=='')
		{
			$('#fnerror').html('Please enter your first name').fadeIn(500);
			str="dsadsa";
		}
		else
		{	
			$('#fnerror').fadeOut(500);
		}
		if(lastname=='')
		{
			$('#lnerror').html('Please enter your last name').fadeIn(500);
			str="dsadsa";
		}
		else
		{	
			$('#lnerror').fadeOut(500);
		}
		if(email=='')
		{
			$('#msg').html('').fadeIn(500);
			$('#emailerror').html('Please enter a valid email address.').fadeIn(500);
			str="dsadsa";
		}
		else if(!email.match(re))
		{
			$('#msg').html('').fadeIn(500);
			$('#emailerror').html("Please enter a valid email address.").fadeIn(500);
			str="dsadsa";
		}
		else
		{	
			$('#emailerror').fadeOut(500);
		}
		if(password=='')
		{
			$('#passworderror1').html('').fadeIn(500);
			$('#passworderror').html('Please enter your password').fadeIn(500);
			str="dsadsa";
		}
		else if(password.length<5)
			{
				$('#passworderror1').html('').fadeIn(500);
				$('#passworderror').html('Your password must be at least five characters.').fadeIn(500);
				str="dsadsa";
			}
		else if(password.length>16)
			{
				$('#passworderror1').html('').fadeIn(500);
				$('#passworderror').html('Your password may not exceed 16 characters.').fadeIn(500);
				str="dsadsa";
			}
		else
		{
			$('#passworderror').fadeOut(500);
		}
		if(year=='')
		{
			$('#dayerror1').html('').fadeIn(500);
			$('#dayerror').html('The birth date you provided is not valid.').fadeIn(500);
			str="year";
		}
		else
		{
			$('#dayerror').fadeOut(500);
		}
		if(month=='')
		{
			$('#dayerror1').html('').fadeIn(500);
			$('#dayerror').html('The birth date you provided is not valid.').fadeIn(500);
			str="month";
		}
		else
		{
			$('#dayerror').fadeOut(500);
		}
		if(day=='')
		{
			$('#dayerror1').html('').fadeIn(500);
			$('#dayerror').html('The birth date you provided is not valid.').fadeIn(500);
			str="day";
		}
		else
		{
			$('#dayerror').fadeOut(500);
		}
		
		if(mobile=='')
		{
			$('#mob').html('').fadeIn(500);
			$('#mobileerror').html('Please enter a mobile number').fadeIn(500);
			//$('#mobileerror1').fadeOut(500);
			str="mobile";
		}
		else
		{
			$('#mobileerror').fadeOut(500);
			$('#mobileerror1').fadeOut(500);
		}
		if(country=='')
		{
			$('#countryerror').html('You must select a country.').fadeIn(500);
			str="country";
		}
		else
		{
			$('#countryerror').fadeOut(500);
		}
		/*if(state=='')
		{
			$('#stateerror').html('You must select a state.').fadeIn(500);
			str="state";
		}
		else
		{
			$('#stateerror').fadeOut(500);
		}*/
		if(city=='')
		{
			$('#cityerror').html('You must select a city.').fadeIn(500);
			str="city";
		}
		else
		{
			$('#cityerror').fadeOut(500);
		} 
		if(username=="")
		{
			$('#msg2').html("").fadeIn(500);
			$('#usererror').html("Your login name must be at least five characters.").fadeIn(500);
			str="username";		
		}
		else if(username.length<5)
			{
				$('#msg2').html("").fadeIn(500);
				$('#usererror').html('Your login name must be at least five characters.').fadeIn(500);
				str="username";
			}
		else if(username.length>20)
			{
				$('#msg2').html("").fadeIn(500);
				$('#usererror').html('Your login name may not exceed 20 characters.').fadeIn(500);
				str="username";
			}
		else
		{
			$('#usererror').fadeOut(500);
		}
		
		if(msg!="")
		{
			/*$('#ulklrerror').fadeOut(500);
		}
		else
		{*/
			str="msg";
		}
		if(msg2!="")
		{
		/*	$('#usjhjerror').fadeOut(500);
		}
		else
		{*/
			str="uname";
		}
		if(pas!="")
		{
		/*	$('#usjhjerror').fadeOut(500);
		}
		else
		{*/
			str="uname";
		}
		if(mob!="")
		{
			/*$('#usjhjerror').fadeOut(500);
		}
		else
		{*/
			str="mob";
		}
		if(dat!="")
		{
			/*$('#usjhjerror').fadeOut(500);
		}
		else
		{*/
			str="dat";
		}
		if(str!="")
		{
			
			return false;
		}
		else
		{
			cobj = document.getElementsByName('country')[0];
	cobj = cobj.options[cobj.selectedIndex];	
	cobj.value = cobj.text;
	
	//state
	/*cobj = document.getElementsByName('state')[0];
	cobj = cobj.options[cobj.selectedIndex];	
	cobj.value = cobj.text;*/
			return true;
		}
	});
	$('#email').blur(function()
	{
		re = /^.+\@.+\..{2,4}$/gi;
		var email=document.profile_reg1.email.value;
		if(email=="")
		{
			$('#emailerror').html('*').fadeIn(500);
			str="dsadsa";
		}
		else if(!email.match(re))
		{
			$('#emailerror').html("Invalid Mail").fadeIn(500);
			str="dsadsa";
		}
		else
		{
			$('#emailerror').fadeOut(500);
		}
	});
	
	//registration validation ends
	
	
	// login validation begins
	
	    $('#usernameerrorlo').hide();
		$('#passworderrorlo').hide();
		$('#loginma').click(function()
		{ //alert('hai');
			var strlm="";
			var username=document.connect_login.emailm.value;
			var password=document.connect_login.password.value;
			if(username=="")
			{
				$('#usernameerrorlo').show();
				strlm="fsdsdf";
			}
			else
			{
				$('#usernameerrorlo').hide();
			}
			if(password=="")
			{
				$('#passworderrorlo').show();
				strlm="fsdsdf";
			}
			else
			{
				$('#passworderrorlo').hide();
			}
			if(strlm!="")
			{
				return false;
			}
			else
			{
				document.connect_login.submit();
			}
		});
		
		//login validation ends
		
		//Forgot password validation begins
		
		//$('input.two').simpleDatepicker({ startdate: 1960, enddate: 2012 });
		$('#usernameerror').hide();
		$('#doberror').hide();
		$('#usernameinvaliederror').hide();
		$('#forgot').click(function()
		{
			var strfp="";
			re = /^.+\@.+\..{2,4}$/gi;
			var username=document.connect_forgot.username.value;
			var dob=document.connect_forgot.dob.value;
			if(username=="")
			{
				$('#usernameerror').html('Required...').fadeIn();
				strfp="sdfdsfsdf";
			}
			else
			{
				$('#usernameerror').fadeOut();
				if(!username.match(re))
				{
					$('#usernameerror').html('Invalied Email Id').fadeIn();
					strfp="sdfsdfsdfdfs"
				}
				else
				{
					$('#usernameerror').fadeOut();
				}
			}
			if(dob=="")
			{
				$('#doberror').html('Required...').fadeIn();
				strfp="sdfdsfsdf";
			}
			else
			{
				$('#doberror').fadeOut();
			}
			if(strfp!="")
			{
				return false;
			}
			else
			{
				document.connect_forgot.submit();
			}
		});
		
		
		//Forgot password validation ends
	
});

function numbersonly(e)
{
	var unicode=e.keyCode? e.keyCode: e.charCode;
	if(unicode!=8)
	{
		if(unicode!=9)
		{
			if(unicode!=46)
			{
				if(unicode<48||unicode>57)
				{
					return false;
				}	
			}
		}
	}
}


