// JavaScript Document

function RegistrationValidateForm()
{
	var todoStatus = trim(document.getElementById('todo').value);
	
	if(todoStatus == 'add')
	{
		var Email = trim(document.getElementById('Email').value);
	
		if(Email == "")
		{
			alert("Please Enter your Email ID");
			document.getElementById('Email').focus();
			return false;
		}
		if(!ChkEmail(Email))
		{
			document.getElementById('Email').focus();
			return false;
		}
	
		var DisplayName = document.getElementById("DisplayName").value;
		if(AllTrim(DisplayName)=='')
		{
			alert('Please Enter DisplayName');
			document.getElementById("DisplayName").focus();
			return false;
		}
	}
	
	var Password = document.getElementById("Password").value;
	if(AllTrim(Password)=='')
	{
		alert('Please Set Password');
		document.getElementById("Password").focus();
		return false;
	}

	var ConfirmPassword = document.getElementById("ConfirmPassword").value;
	if(AllTrim(ConfirmPassword)=='')
	{
		alert('Please Retype ConfirmPassword');
		document.getElementById("ConfirmPassword").focus();
		return false;
	}

	if(AllTrim(Password) !='' && AllTrim(ConfirmPassword) !='' && AllTrim(Password) != AllTrim(ConfirmPassword))
	{
		alert('Password and ConfirmPassword Mismatch');
		document.getElementById("ConfirmPassword").focus();
		return false;
	}
	
		var Country = document.getElementById("Country").options[document.getElementById("Country").selectedIndex].value;
//		if(Country=='')
//		{
//			alert('Please Select A Country');
//			document.getElementById("Country").focus();
//			return false;
//		}
		
//		var State = document.getElementById("State").options[document.getElementById("State").selectedIndex].value;
//		if(State=='')
//		{
//			alert('Please Select A State');
//			document.getElementById("State").focus();
//			return false;
//		}
	
//		var City = document.getElementById("City").options[document.getElementById("City").selectedIndex].value;
//		if(City=='')
//		{
//			alert('Please Select A City');
//			document.getElementById("City").focus();
//			return false;
//		}
	
		document.getElementById("CountryID").value = Country;
//		document.getElementById("StateID").value = State;
//		document.getElementById("CityID").value = City;
	
	var Name = document.getElementById("Name").value;
	if(AllTrim(Name)=='')
	{
		alert('Please Enter Name');
		document.getElementById("Name").focus();
		return false;
	}
	
	var LastName = document.getElementById("LastName").value;
	if(AllTrim(LastName)=='')
	{
		alert('Please Enter LastName');
		document.getElementById("LastName").focus();
		return false;
	}
	
	var Address1 = document.getElementById("Address1").value;
//	if(AllTrim(Address1)=='')
//	{
//		alert('Please Enter Address1');
//		document.getElementById("Address1").focus();
//		return false;
//	}
	
//	var Address2 = document.getElementById("Address2").value;
//	if(AllTrim(Address2)=='')
//	{
//		alert('Please Enter Address2');
//		document.getElementById("Address2").focus();
//		return false;
//	}
	

	
	var Zip = document.getElementById("Zip").value;
//	if(AllTrim(Zip)=='')
//	{
//		alert('Please Put Your Zip');
//		document.getElementById("Zip").focus();
//		return false;
//	}
	
	var UID = document.getElementById("UserID").value;
	var TermCond = document.getElementById("TermCond");
	if(UID == '')
	{
		if(TermCond.checked != true)
		{
			alert('Please Check The Terms and Condition.');
			document.getElementById("TermCond").focus();
			return false;
		}
	}
	
}

function ValidateEditPassword()
{
	var todoStatus = trim(document.getElementById('todo').value);
		
	var Password = document.getElementById("Password").value;
	if(AllTrim(Password)=='')
	{
		alert('Please Set Password');
		document.getElementById("Password").focus();
		return false;
	}

	var ConfirmPassword = document.getElementById("ConfirmPassword").value;
	if(AllTrim(ConfirmPassword)=='')
	{
		alert('Please Retype ConfirmPassword');
		document.getElementById("ConfirmPassword").focus();
		return false;
	}

	if(AllTrim(Password) !='' && AllTrim(ConfirmPassword) !='' && AllTrim(Password) != AllTrim(ConfirmPassword))
	{
		alert('Password and ConfirmPassword Mismatch');
		document.getElementById("ConfirmPassword").focus();
		return false;
	}

	var UID = document.getElementById("UserID").value;
	var TermCond = document.getElementById("TermCond");
	if(UID == '')
	{
		if(TermCond.checked != true)
		{
			alert('Please Check The Terms and Condition.');
			document.getElementById("TermCond").focus();
			return false;
		}
	}
	
}

function ValidateEditProfile()
{
	var todoStatus = trim(document.getElementById('todo').value);
	
	if(todoStatus == 'add')
	{
		var Email = trim(document.getElementById('Email').value);
	
		if(Email == "")
		{
			alert("Please Enter your Email ID");
			document.getElementById('Email').focus();
			return false;
		}
		if(!ChkEmail(Email))
		{
			document.getElementById('Email').focus();
			return false;
		}
	
		var DisplayName = document.getElementById("DisplayName").value;
		if(AllTrim(DisplayName)=='')
		{
			alert('Please Enter DisplayName');
			document.getElementById("DisplayName").focus();
			return false;
		}
	}

	
		var Country = document.getElementById("Country").options[document.getElementById("Country").selectedIndex].value;
//		if(Country=='')
//		{
//			alert('Please Select A Country');
//			document.getElementById("Country").focus();
//			return false;
//		}
		
//		var State = document.getElementById("State").options[document.getElementById("State").selectedIndex].value;
//		if(State=='')
//		{
//			alert('Please Select A State');
//			document.getElementById("State").focus();
//			return false;
//		}
	
//		var City = document.getElementById("City").options[document.getElementById("City").selectedIndex].value;
//		if(City=='')
//		{
//			alert('Please Select A City');
//			document.getElementById("City").focus();
//			return false;
//		}
	
		document.getElementById("CountryID").value = Country;
//		document.getElementById("StateID").value = State;
//		document.getElementById("CityID").value = City;
	
	var Name = document.getElementById("Name").value;
	if(AllTrim(Name)=='')
	{
		alert('Please Enter Name');
		document.getElementById("Name").focus();
		return false;
	}
	
	var LastName = document.getElementById("LastName").value;
	if(AllTrim(LastName)=='')
	{
		alert('Please Enter LastName');
		document.getElementById("LastName").focus();
		return false;
	}
	
	var Address1 = document.getElementById("Address1").value;
//	if(AllTrim(Address1)=='')
//	{
//		alert('Please Enter Address1');
//		document.getElementById("Address1").focus();
//		return false;
//	}
	
//	var Address2 = document.getElementById("Address2").value;
//	if(AllTrim(Address2)=='')
//	{
//		alert('Please Enter Address2');
//		document.getElementById("Address2").focus();
//		return false;
//	}
	

	
	var Zip = document.getElementById("Zip").value;
//	if(AllTrim(Zip)=='')
//	{
//		alert('Please Put Your Zip');
//		document.getElementById("Zip").focus();
//		return false;
//	}
	
	var UID = document.getElementById("UserID").value;
	var TermCond = document.getElementById("TermCond");
	if(UID == '')
	{
		if(TermCond.checked != true)
		{
			alert('Please Check The Terms and Condition.');
			document.getElementById("TermCond").focus();
			return false;
		}
	}
	
}


function CheckAvailabity(Obj)
{
	var FieldName = Obj.id;
	var FieldVal = Obj.value;
	if(AllTrim(FieldVal) != '')
	{
		var DisplayDiv = 'Div'+FieldName;
		document.getElementById(DisplayDiv).innerHTML = '<img src="images/ajax-loader.gif" border="0" height="17" />';
		
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		var url = 'CheckAvailabity.php?FieldName='+FieldName+'&FieldVal='+FieldVal ;
		//alert(url);
		ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function() { CompleteCheckAvailabity(ajaxIndex,FieldName); } ;	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
}
function CompleteCheckAvailabity(index,FieldName)
{
	//alert(ajaxObjects[index].response);
	var DisplayDiv = 'Div'+FieldName;
	document.getElementById(DisplayDiv).innerHTML = ajaxObjects[index].response;
}



function LoginValidateForm()
{
	var Email = trim(document.getElementById('Email').value);

	if(Email == "")
	{
		alert("Please Enter your Email ID");
		document.getElementById('Email').focus();
		return false;
	}
	if(!ChkEmail(Email))
	{
		document.getElementById('Email').focus();
		return false;
	}

	var Password = document.getElementById("Password").value;
	if(AllTrim(Password)=='')
	{
		alert('Please Set Password');
		document.getElementById("Password").focus();
		return false;
	}

}


function AdUploadForm()
{
	var todoStatus = trim(document.getElementById('todo').value);
	
	
	var CompanyName = document.getElementById("CompanyName").value;
	if(AllTrim(CompanyName)=='')
	{
		alert('Please Set CompanyName');
		document.getElementById("CompanyName").focus();
		return false;
	}

	var CompanyUrl = document.getElementById("CompanyUrl").value;
	if(AllTrim(CompanyUrl)=='')
	{
		alert('Please Retype Company Url');
		document.getElementById("CompanyUrl").focus();
		return false;
	}

	var AdDesc = document.getElementById("AdDesc").value;
	if(AllTrim(AdDesc)=='')
	{
		alert('Please Enter Description');
		document.getElementById("AdDesc").focus();
		return false;
	}
	
	
	var AttachedFile = document.getElementById("AttachedFile").value;
	if(AllTrim(AttachedFile)=='' && todoStatus == 'add')
	{
		alert('Please Select a file to upload');
		document.getElementById("AttachedFile").focus();
		return false;
	}
	
}









function ForgotPasswordValidateForm()
{
	var Email = trim(document.getElementById('Email').value);

	if(Email == "")
	{
		alert("Please Enter your Email ID");
		document.getElementById('Email').focus();
		return false;
	}
	if(!ChkEmail(Email))
	{
		document.getElementById('Email').focus();
		return false;
	}
}
