function UpdateSubscriberStatus()
{
	with(document.formobject)
	{		
			updatesubscriptioinstatusflag.value="true";
	}
	document.formobject.submit();
}

//Validate Video Blog Comments
function ValidateAdminCommentsVideo()
{
		with(document.formobject)
		{		
				if(txtName.value=="")
				{
					alert("Please Enter your Name");
					txtName.focus();
					return false;
				}else if(txtEmail.value=="")
				{
					alert("Please Enter the Email");
					txtEmail.focus();
					return false;
				}else if(!(isEmail(txtEmail.value)))
				{
					alert("Please Enter the Email (abc@abc.com)");
					txtEmail.focus();
					return false;
				}
				ValidateAdminCommentsflagVideo.value="true";
		}
	return true;	
}
//Validate Article Comments
function ValidateAdminComments()
{
		with(document.formobject)
		{		
				if(txtName.value=="")
				{
					alert("Please Enter your Name");
					txtName.focus();
					return false;
				}else if(txtEmail.value=="")
				{
					alert("Please Enter the Email");
					txtEmail.focus();
					return false;
				}else if(!(isEmail(txtEmail.value)))
				{
					alert("Please Enter the Email (abc@abc.com)");
					txtEmail.focus();
					return false;
				}
				ValidateAdminCommentsflag.value="true";
		}
	return true;	
}
function LoadVideoOption(Selected)
{
	document.getElementById("TrVideoLink").style.display='none';
	document.getElementById("TrVideoFile").style.display='none';
	if(Selected==1)
	{
		document.getElementById("TrVideoLink").style.display='';
	}
	else
	{
		document.getElementById("TrVideoFile").style.display='';
	}
}
function ValidateVideoBlogs()
{
	with(document.formobject)
	{		
		if (CategoryID.value=='-1')
		{
			alert("Please Select the Category");
			CategoryID.focus();
			return false;
		}
		else if(VideoType.value=='-1')
		{
			alert("Please Select Video Type");
			VideoType.focus();
			return false;
		}
		else if(VideoType.value=='1' && VideoLink.value=='')
		{
			alert("Please Enter Video Link");
			VideoLink.focus();
			return false;
		}
		else if(VideoType.value=='2' && VideoFile.value=='')
		{
			alert("Please Select Video File (Only FLV Files Allowed)");
			VideoFile.focus();
			return false;
		}
		else if(VideoType.value=='2' && VideoFile.value!='' && CheckExtension(VideoFile.value)!='flv')
		{
			alert("Only FLV Files Allowed");
			VideoFile.focus();
			return false;
		}
		else if(VideoLanguage.value=='-1')
		{
			alert("Please Select Video Language");
			VideoLanguage.focus();
			return false;
		}
		else if (ArticleDate.value=="")
		{
			alert("Please Enter the Video Blog Publish Date");
			ArticleDate.focus();
			return false;
		}
		else if (AuthorName.value=="")
		{
			alert("Please Enter the Author Name");
			AuthorName.focus();
			return false;
		}
		else if(txtLinkTitle.value=="")
		{
			alert("Please Enter the Top Title");
			txtLinkTitle.focus();
			return false;
		}
		else if(txtPageTitle.value=="")
		{
			alert("Please Enter the Topic Page Title");
			txtPageTitle.focus();
			return false;
		}
		else if(New.value=='-1')
		{
			alert("Add In New Video Blog?");
			New.focus();
			return false;
		}
		else if(ShowHomePage.value=='-1')
		{
			alert("Show On Home Page?");
			ShowHomePage.focus();
			return false;
		}
		else if(MetaTitle.value=="")
		{
			alert("Please Enter Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(txtPageURL.value=="")
		{
			alert("Please Enter the URL Keyword");
			txtPageURL.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		else if(SendEmailToSubscribers.value=='-1')
		{
			alert("Do You Want To Send Email To All Subscribers?");
			SendEmailToSubscribers.focus();
			return false;
		}
		else if(SendEmailToSubscribers.value=='2')
		{
			if(EmailSubject.value=='')
			{
				alert("Please Enter Email Subject");
				EmailSubject.focus();
				return false;
			}
			/*if(EmailText.value=='')
			{
				alert("Please Enter Email Text");
				EmailText.focus();
				return false;
			}*/
			if(EmailPicture.value!='' 
			   && CheckExtension(EmailPicture.value)!='jpg' 
			   && CheckExtension(EmailPicture.value)!='gif' 
			   && CheckExtension(EmailPicture.value)!='png')
			{
				alert("Only jpg, gif and png images allowed");
				EmailPicture.focus();
				return false;
			}
		}
		ValidateVideoBlogflag.value="true";
	}
	return true;	
}

function LoadEmailOptions(Selected)
{
	document.getElementById("TrEmailSubject").style.display='none';
	document.getElementById("TrEmailText").style.display='none';
	document.getElementById("TrEmailPicture").style.display='none';
	if(Selected==2)
	{
		document.getElementById("TrEmailSubject").style.display='';
		document.getElementById("TrEmailText").style.display='';
		document.getElementById("TrEmailPicture").style.display='';
	}
}
function ValidateArticles()
{
	with(document.formobject)
	{		
		if (CategoryID.value=='-1')
		{
			alert("Please Select the Category");
			CategoryID.focus();
			return false;
		}
		else if (ArticleDate.value=="")
		{
			alert("Please Enter the Article Publish Date");
			ArticleDate.focus();
			return false;
		}
		else if (AuthorName.value=="")
		{
			alert("Please Enter the Author Name");
			AuthorName.focus();
			return false;
		}
		else if(txtLinkTitle.value=="")
		{
			alert("Please Enter the Top Title");
			txtLinkTitle.focus();
			return false;
		}
		else if(txtPageTitle.value=="")
		{
			alert("Please Enter the Topic Page Title");
			txtPageTitle.focus();
			return false;
		}
		else if(New.value=='-1')
		{
			alert("Add In New Articles?");
			New.focus();
			return false;
		}
		else if(ShowHomePage.value=='-1')
		{
			alert("Show On Home Page?");
			ShowHomePage.focus();
			return false;
		}
		else if(MetaTitle.value=="")
		{
			alert("Please Enter Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(txtPageURL.value=="")
		{
			alert("Please Enter the URL Keyword");
			txtPageURL.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		else if(SendEmailToSubscribers.value=='-1')
		{
			alert("Do You Want To Send Email To All Subscribers?");
			SendEmailToSubscribers.focus();
			return false;
		}
		else if(SendEmailToSubscribers.value=='2')
		{
			if(EmailSubject.value=='')
			{
				alert("Please Enter Email Subject");
				EmailSubject.focus();
				return false;
			}
			/*if(EmailText.value=='')
			{
				alert("Please Enter Email Text");
				EmailText.focus();
				return false;
			}*/
			if(EmailPicture.value!='' 
			   && CheckExtension(EmailPicture.value)!='jpg' 
			   && CheckExtension(EmailPicture.value)!='gif' 
			   && CheckExtension(EmailPicture.value)!='png')
			{
				alert("Only jpg, gif and png images allowed");
				EmailPicture.focus();
				return false;
			}
		}
		ValidateArticlesflag.value="true";
	}
	return true;	
}

function ValidateCategories()
{
	with(document.formobject)
	{		
		if(txtLinkTitle.value=="")
		{
			alert("Please Enter the Link Title");
			txtLinkTitle.focus();
			return false;
		}
		else if(txtPageTitle.value=="")
		{
			alert("Please Enter the Page Title");
			txtPageTitle.focus();
			return false;
		}
		else if(MetaTitle.value=="")
		{
			alert("Please Enter the Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(txtPageURL.value=="")
		{
			alert("Please Enter the URL Keyword");
			txtPageURL.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		ValidateCategoriesflag.value="true";
	}
	return true;	
}
function ValidateLinks()
{
	with(document.formobject)
	{		
		if(LinkTitle.value=="")
		{
			alert("Please Enter the Link Title");
			LinkTitle.focus();
			return false;
		}
		else if(URL.value=="")
		{
			alert("Please Enter the URL");
			URL.focus();
			return false;
		}
		ValidateLinksflag.value="true";
	}
	return true;	
}
function ValidatePolls()
{
	with(document.formobject)
	{
		if(txtQuestion.value=="")
		{
			alert("Please Enter the question");
			txtQuestion.focus();
			return false;
		}
		if(actionflag==0)
		{
			var i=0;
			var flag=0;
			for(i=0;i<answers.length;i++)
			{
				if(answers[i].value!="")
				{
					flag=1;
					break;
				}
			}
			if(flag==0)
			{
				alert("Please Enter the answer");
				return false;
			}
		}
		ValidatePollsflag.value="true";
	}
	return true;	
}

function ValidateTestimonials()
{
	with(document.formobject)
	{
		if(CompanyName.value=='')
		{
			alert("Please Enter Company");
			CompanyName.focus();
			return false;
		}
		else if(PersonName.value=='')
		{
			alert("Please Enter Person Name");
			PersonName.focus();
			return false;
		}
		else if(Designation.value=='')
		{
			alert("Please enter Designation");
			Designation.focus();
			return false;
		}
		else if(Message.value=='')
		{
			alert("Please Enter Message");
			Message.focus();
			return false;
		}
		ValidateTestimonialsflag.value='true';
	}
	return true;
}
function CheckPageURL(PageURL, OldURL)
{
	if(PageURL!=OldURL)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return false;
		}
		var url='checkPage.php?PageURL=' + PageURL + '&sid=' + Math.random();
		
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4)
			{
				document.getElementById("CheckPageName").value=xmlHttp.responseText;
				if(xmlHttp.responseText>0)
				{
					document.getElementById("PageMessage").innerHTML='<span style="color:#ff0000;">Page URL already Exists. Try Another</span>';
				}
				else
				{
					document.getElementById("PageMessage").innerHTML='<span style="color:#00CC66;">Page URL Available</span>';
				}
			}
		}
		xmlHttp.open("GET",url,true);		
		xmlHttp.send(null);
	}
	else
	{
		document.getElementById("CheckPageName").value=0;
	}
}

function ValidateNews()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter News Title");
			Title.focus();
			return false;
		}
		else if(Active.value=='')
		{
			alert("Active This News?");
			Active.focus();
			return false;
		}
		else if(txtPageURL.value=='')
		{
			alert("Please Enter Page URL");
			txtPageURL.focus();
			return false;
		}
		else if(MetaTitle.value=='')
		{
			alert("Please Enter Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		ValidateNewsflag.value='true';
	}
	return true;
}

function ValidateProducts()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter Product Title");
			Title.focus();
			return false;
		}
		else if(Featured.value=='')
		{
			alert("Add This Product in Featured?");
			Featured.focus();
			return false;
		}
		else if(txtPageURL.value=='')
		{
			alert("Please Enter Page URL");
			txtPageURL.focus();
			return false;
		}
		else if(MetaTitle.value=='')
		{
			alert("Please Enter Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		ValidateProductflag.value='true';
	}
	return true;
}

function ValidateServices()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter Service Title");
			Title.focus();
			return false;
		}
		else if(Featured.value=='')
		{
			alert("Add This Service in Featured?");
			Featured.focus();
			return false;
		}
		else if(txtPageURL.value=='')
		{
			alert("Please Enter Page URL");
			txtPageURL.focus();
			return false;
		}
		else if(MetaTitle.value=='')
		{
			alert("Please Enter Meta Title");
			MetaTitle.focus();
			return false;
		}
		else if(CheckPageName.value!='0')
		{
			alert("Page URL Already Exists. Please Enter Another");
			txtPageURL.focus();
			return false;
		}
		ValidateServiceflag.value='true';
	}
	return true;
}
function ValidateSubCategory()
{
	with(document.formobject)
	{
		if(CategoryID.value=='')
		{
			alert("Please Select Main Category");
			CategoryID.focus();
			return false;
		}
		else if(Title.value=='')
		{
			alert("Please Enter Sub Category Title");
			Title.focus();
			return false;
		}
		ValidateSubCategoryflag.value='true';
	}
	return true;
}

function ValidateMainCategory()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter Main Category Title");
			Title.focus();
			return false;
		}
		ValidateMainCategoryflag.value='true';
	}
	return true;
}
//Validating Login Details
function validateLoginDetails()
{
		with(document.formobject)
		{		
				if (txtUserName.value=="")
				{
					alert("Please Enter the Username");
					txtUserName.focus();
					return false;
				}else if(txtPassword.value=="")
				{
					alert("Please Enter the Password");
					txtPassword.focus();
					return false;
				}
				eventflag.value="true";
		}
	return true;
}


//Validating User Group
function ValidateUserGroup()
{
		with(document.formobject)
		{		
				if (txtGroupName.value=="")
				{
					alert("Please Enter the Group Name");
					txtGroupName.focus();
					return false;
				}
				ValidateUserGroupeventflag.value="true";
		}
	return true;
}

//Validating Group Permissions
function ValidateGrouPermissions()
{
		with(document.formobject)
		{		
				ValidateGrouPermissionsflag.value="true";
		}
	return true;
}



//Checking User Name
function checkUserName()
{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return false;
		}
		username=document.formobject.txtUserName.value;	 
		var url='CheckUserName.php';
		url=url+"?username="+username;		
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);		
		xmlHttp.send(null);
		return false;
	
}

function stateChanged() 
{ 
		if (xmlHttp.readyState==4)
		{ 	
				var result=xmlHttp.responseText;
				var resultarray=result.split("----------!!!!!!________RSI_________!!!!!!!!--------");
				if(resultarray[1]==1)
				{
					document.getElementById("usernamecheck").innerHTML="Username Available";
					document.formobject.usernamehiddencheck.value=1;
				}else
				{
					document.getElementById("usernamecheck").innerHTML="Username Unavailable";
					document.formobject.usernamehiddencheck.value=0;
				}
		}
}

//Ajax Main Function
function GetXmlHttpObject()
{
		var xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
		// Internet Explorer
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
}
//Validating System Users
function ValidateSystemUser(flag)
{
		with(document.formobject)
		{		
				if (GroupID.value=='-1')
				{
					alert("Please Select the User Group");
					GroupID.focus();
					return false;
				}else if (txtUserName.value=="")
				{
					alert("Please Enter the User Name");
					txtUserName.focus();
					return false;
				}else if(usernamehiddencheck.value==0)
				{
					alert("The Username has been Taken : Please enter another Username");
					txtUserName.focus();
					return false;
				}else if(txtFirstName.value=="")
				{
					alert("Please Enter the First Name");
					txtFirstName.focus();
					return false;
				}else if(txtLastName.value=="")
				{
					alert("Please Enter the Last Name");
					txtLastName.focus();
					return false;
				}else if(Gender.value=='-1')
				{
					alert("Please Select the Gender");
					Gender.focus();
					return false;
				}else if(txtEmail.value=="")
				{
					alert("Please Enter the Email");
					txtEmail.focus();
					return false;
				}else if(!(isEmail(txtEmail.value)))
				{
					alert("Please Enter the Email (abc@abc.com)");
					txtEmail.focus();
					return false;
				}else if(AccountStatus.value=='-1')
				{
					alert("Please Select the Account Status");
					AccountStatus.focus();
					return false;
				}else if(flag==0)
				{
						if(txtPassword.value=="")
						{
							alert("Please Enter the Password");
							txtPassword.focus();
							return false;
						}
				}
				ValidateSystemUserflag.value="true";
		}
	return true;	
}

//Validating User Permissions

function ValidateUserPermissions()
{
		with(document.formobject)
		{		
				ValidateUserPermissionsflag.value="true";
		}
	return true;
}


//Validating CMS

function ValidateCmsPage()
{
		with(document.formobject)
		{		
				if (MasterLinkID.value=='-1')
				{
					alert("Please Select the Master Link");
					MasterLinkID.focus();
					return false;
				}else if (txtLinkTitle.value=="")
				{
					alert("Please Enter the Link Title");
					txtLinkTitle.focus();
					return false;
				}else if(txtPageTitle.value=="")
				{
					alert("Please Enter the Page Title");
					txtPageTitle.focus();
					return false;
				}else if(Sequence.value=="")
				{
					alert("Please Enter the Page Sequence");
					Sequence.focus();
					return false;
				}else if(txtImage.value.length>5)
				{
						if(ImagePositionID.value=='-1')
						{
							alert("Please Select the Image Position");
							ImagePositionID.focus();
							return false;
						}
				}
				ValidateCmsPageflag.value="true";
		}
	return true;	
}



//Validating Uploads

function ValidateUploads()
{
		with(document.formobject)
		{		
				ValidateUploadsflag.value="true";
		}
	return true;		
}


//Validating CMS Data
function validateotherdata()
{
	with(document.formobject)
	{		
				otherdataflag.value="true";
	}
	return true;	
}

//Loading Other CMS Data
function loadcmscontents()
{
	document.formobject.submit();
}

//Validating Website Configuration
function ValidateWebsiteConfiguration()
{
	with(document.formobject)
	{		
				ValidateWebsiteConfigurationflag.value="true";
	}
	return true;	
}
//Validating Change Password
function ValidateChangePassword()
{
		with(document.formobject)
		{
					if(txtOldPassword.value=="")
					{
							alert("Please Enter the Old Password");
							txtOldPassword.focus();
							return false;
					}else if(txtNewPassword.value.length<8)
					{
							alert("Please Enter the New Password(Minimum 8 Characters)");
							txtNewPassword.focus();
							return false;
					}else if(txtNewPassword.value!=txtConfirmPassword.value)
					{
							alert("New Password doesnt Match , Please reconfirm");
							txtNewPassword.focus();
							return false;
					}
				
				ValidateChangePasswordflag.value="true";
	}
	return true;	
}

//Loading Controls on the Basis of Link Type selected
function loadcontrolsonLinkType2(Selected)
{
		
			if(Selected==1)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
			}else if(Selected==2)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="";
				document.getElementById("trdescription").style.display="";
				document.getElementById("trimageposition").style.display="";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="";
				document.getElementById("PageURLTr").style.display='';
				document.getElementById("MetaTitleTr").style.display='';
				document.getElementById("MetaKeywordTr").style.display='';
				document.getElementById("MetaDescriptionTr").style.display='';
			}else if(Selected==3)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="";
				document.getElementById("trurl").style.display="";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
			}else if(Selected==4)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
			}else if(Selected==5)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="";
				document.getElementById("tropeningphrase").style.display="none";
			}
		
}

//Loading Controls on the Basis of Link Type selected
function loadcontrolsonLinkType()
{
	document.getElementById("PageURLTr").style.display='none';
	document.getElementById("MetaTitleTr").style.display='none';
	document.getElementById("MetaKeywordTr").style.display='none';
	document.getElementById("MetaDescriptionTr").style.display='none';
	
		with(document.formobject)
		{		
			if(LinkType.value==1)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
			}else if(LinkType.value==2)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="";
				document.getElementById("trdescription").style.display="";
				document.getElementById("trimageposition").style.display="";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="";
				document.getElementById("PageURLTr").style.display='';
				document.getElementById("MetaTitleTr").style.display='';
				document.getElementById("MetaKeywordTr").style.display='';
				document.getElementById("MetaDescriptionTr").style.display='';
			}else if(LinkType.value==3)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="";
				document.getElementById("trurl").style.display="";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
			}else if(LinkType.value==4)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
			}else if(LinkType.value==5)
			{
				document.getElementById("trlinktitle").style.display="";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("PageURLTr").style.display="";
				document.getElementById("MetaTitleTr").style.display="";
				document.getElementById("MetaKeywordTr").style.display="";
				document.getElementById("MetaDescriptionTr").style.display="";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="";
				document.getElementById("tropeningphrase").style.display="none";
			}else if(LinkType.value=='-1')
			{
				document.getElementById("trlinktitle").style.display="none";
				document.getElementById("trpagetitle").style.display="none";
				document.getElementById("trdescription").style.display="none";
				document.getElementById("trimageposition").style.display="none";
				document.getElementById("trtarget").style.display="none";
				document.getElementById("trurl").style.display="none";
				document.getElementById("trfile").style.display="none";
				document.getElementById("trpredefinedpage").style.display="none";
				document.getElementById("tropeningphrase").style.display="none";
				alert("Please Select the Link Type");
				LinkType.focus();
			}
		}
}

//Validate Master Pages
function ValidateMasterPages()
{
	with(document.formobject)
		{		
			if(LinkType.value==1)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}
			}else if(LinkType.value==2)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(txtPageTitle.value=="")
				{
						alert("Please Enter the Page Title");
						txtPageTitle.focus();
						return false;
				}
				else if(txtPageURL.value=='')
				{
					alert("Please Enter Page URL");
					txtPageURL.focus();
					return false;
				}
				else if(MetaTitle.value=='')
				{
					alert("Please Enter Meta Title");
					MetaTitle.focus();
					return false;
				}
				else if(CheckPageName.value!='0')
				{
					alert("Page URL Already Exists. Please Enter Another");
					txtPageURL.focus();
					return false;
				}
			}else if(LinkType.value==3)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(TargetID.value=='-1')
				{
						alert("Please enter the Target");
						TargetID.focus();
						return false;
				}else if(txtExternalLink.value=="")
				{
						alert("Please Enter the External Link (For Eg http://www.abcd.com)");
						txtExternalLink.focus();
						return false;
				}
			}else if(LinkType.value==4)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(FileExists.value=='0' && FileName.value=='')
				{
						alert("Please attach a File");
						FileName.focus();
						return false;
				}
			}else if(LinkType.value==5)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(PredefinedPage.value=='-1')
				{
						alert("Please select a Predefined Page");
						PredefinedPage.focus();
						return false;
				}
				else if(txtPageURL.value=='')
				{
					alert("Please Enter Page URL");
					txtPageURL.focus();
					return false;
				}
				else if(MetaTitle.value=='')
				{
					alert("Please Enter Meta Title");
					MetaTitle.focus();
					return false;
				}
				else if(CheckPageName.value!='0')
				{
					alert("Page URL Already Exists. Please Enter Another");
					txtPageURL.focus();
					return false;
				}
			}else if(LinkType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}
			ValidateMasterPagesflag.value="true";
		}
	return true;	
}

//Validate Master Pages
function ValidateRelatedLink()
{
		with(document.formobject)
		{		
			if(LinkType.value==1)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}
			}else if(LinkType.value==2)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(txtPageTitle.value=="")
				{
						alert("Please Enter the Page Title");
						txtPageTitle.focus();
						return false;
				}
			}else if(LinkType.value==3)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(TargetID.value=='-1')
				{
						alert("Please enter the Target");
						TargetID.focus();
						return false;
				}else if(txtExternalLink.value=="")
				{
						alert("Please Enter the External Link (For Eg http://www.uaeusedcars.ae)");
						txtExternalLink.focus();
						return false;
				}
			}else if(LinkType.value==4)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(FileExists.value=='0' && FileName.value=='')
				{
						alert("Please attach a File");
						FileName.focus();
						return false;
				}
			}else if(LinkType.value==5)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(PredefinedPage.value=='-1')
				{
						alert("Please select a Predefined Page");
						PredefinedPage.focus();
						return false;
				}
			}else if(LinkType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}
			ValidateRelatedLinkflag.value="true";
		}
	return true;	
}

function ValidateLocationMasterPages()
{
		with(document.formobject)
		{	
			if(LocationID.value=='')
			{
				alert("Please Select Location");
				LocationID.focus();
				return false;
			}
			else if(LinkType.value==1)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}
			}else if(LinkType.value==2)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(txtPageTitle.value=="")
				{
						alert("Please Enter the Page Title");
						txtPageTitle.focus();
						return false;
				}
			}else if(LinkType.value==3)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(TargetID.value=='-1')
				{
						alert("Please enter the Target");
						TargetID.focus();
						return false;
				}else if(txtExternalLink.value=="")
				{
						alert("Please Enter the External Link (For Eg http://www.uaeusedcars.ae)");
						txtExternalLink.focus();
						return false;
				}
			}else if(LinkType.value==4)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(FileExists.value=='0' && FileName.value=='')
				{
						alert("Please attach a File");
						FileName.focus();
						return false;
				}
			}else if(LinkType.value==5)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(PredefinedPage.value=='-1')
				{
						alert("Please select a Predefined Page");
						PredefinedPage.focus();
						return false;
				}
			}else if(LinkType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}
			ValidateLocationMasterPagesflag.value="true";
		}
	return true;	
}


//Validate Sub Pages
function ValidateSubPages()
{
		with(document.formobject)
		{		
			if(MasterPageID.value=='-1')
			{
				alert("Please Select the Master Page");
				MasterPageID.focus();
				return false;
			}
			if(LinkType.value==1)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}
			}else if(LinkType.value==2)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(txtPageTitle.value=="")
				{
						alert("Please Enter the Page Title");
						txtPageTitle.focus();
						return false;
				}
				else if(txtPageURL.value=='')
				{
					alert("Please Enter Page URL");
					txtPageURL.focus();
					return false;
				}
				else if(MetaTitle.value=='')
				{
					alert("Please Enter Meta Title");
					MetaTitle.focus();
					return false;
				}
				else if(CheckPageName.value!='0')
				{
					alert("Page URL Already Exists. Please Enter Another");
					txtPageURL.focus();
					return false;
				}
			}else if(LinkType.value==3)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(TargetID.value=='-1')
				{
						alert("Please enter the Target");
						TargetID.focus();
						return false;
				}else if(txtExternalLink.value=="")
				{
						alert("Please Enter the External Link (For Eg http://www.uaeusedcars.ae)");
						txtExternalLink.focus();
						return false;
				}
			}else if(LinkType.value==4)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(FileExists.value=='0' && FileName.value=='')
				{
						alert("Please attach a File");
						FileName.focus();
						return false;
				}
			}else if(LinkType.value==5)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(PredefinedPage.value=='-1')
				{
						alert("Please select a Predefined Page");
						PredefinedPage.focus();
						return false;
				}
			}else if(LinkType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}
			ValidateSubPagesflag.value="true";
		}
	return true;	
}

//Validate Sub Pages
function ValidateLocationSubPages()
{
		with(document.formobject)
		{
			if(LocationID.value=='')
			{
				alert("Please Select Location");
				LocationID.focus();
				return false;
			}
			else if(MasterPageID.value=='-1')
			{
				alert("Please Select the Master Page");
				MasterPageID.focus();
				return false;
			}
			if(LinkType.value==1)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}
			}else if(LinkType.value==2)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(txtPageTitle.value=="")
				{
						alert("Please Enter the Page Title");
						txtPageTitle.focus();
						return false;
				}
			}else if(LinkType.value==3)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(TargetID.value=='-1')
				{
						alert("Please enter the Target");
						TargetID.focus();
						return false;
				}else if(txtExternalLink.value=="")
				{
						alert("Please Enter the External Link (For Eg http://www.uaeusedcars.ae)");
						txtExternalLink.focus();
						return false;
				}
			}else if(LinkType.value==4)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(FileExists.value=='0' && FileName.value=='')
				{
						alert("Please attach a File");
						FileName.focus();
						return false;
				}
			}else if(LinkType.value==5)
			{
				if(txtLinkTitle.value=="")
				{
						alert("Please Enter the Link Title");
						txtLinkTitle.focus();
						return false;
				}else if(PredefinedPage.value=='-1')
				{
						alert("Please select a Predefined Page");
						PredefinedPage.focus();
						return false;
				}
			}else if(LinkType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}
			ValidateLocationSubPagesflag.value="true";
		}
	return true;	
}


//Update Information
function UpdateInformation()
{
	with(document.formobject)
	{		
			UpdateInformationFlag.value="true";
	}
	document.formobject.submit();
}

//Update Sequence
function UpdateSequence()
{
	with(document.formobject)
	{		
			updatesequenceflag.value="true";
	}
	document.formobject.submit();
}


//Validating Contact Us Form
function ValidateContactUs()
{
		with(document.contactusform)
		{		
				if (txtName.value=="")
				{
					alert("Please Enter your Name");
					txtName.focus();
					return false;
				}else if(txtTelephone.value=="")
				{
					alert("Please Enter your Contact Number");
					txtTelephone.focus();
					return false;
				}else if(txtEmail.value=="")
				{
					alert("Please Enter the Email");
					txtEmail.focus();
					return false;
				}else if(!(isEmail(txtEmail.value)))
				{
					alert("Please Enter the Email (abc@abc.com)");
					txtEmail.focus();
					return false;
				}else if(txtSubject.value=="")
				{
					alert("Please Enter the Subject of this Inquiry");
					txtSubject.focus();
					return false;
				}else if(inquiry.value=="")
				{
					alert("Please Enter the inquiry Details");
					inquiry.focus();
					return false;
				}
				contactusformflag.value="true";
		}
	return true;	
}



function ValidateLocation()
{
	  with(document.formobject)
	  {		
		  if (Title.value=="")
		  {
			  alert("Please Enter the Location Title");
			  Title.focus();
			  return false;
		  }
		  ValidateLocationflag.value="true";
	  }
	return true;	
}

function ValidateProductCategory()
{
	  with(document.formobject)
	  {		
		  if (Title.value=="")
		  {
			  alert("Please Enter the Category Name");
			  Title.focus();
			  return false;
		  }
		  ValidateProductCategoryflag.value="true";
	  }
	return true;	
}

function ValidateProduct()
{
	  with(document.formobject)
	  {
		  if(CategoryID.value=='')
		  {
			  alert("Please Select Product Category");
			 CategoryID.focus();
			 return false;
		  }
		  else if (Title.value=="")
		  {
			  alert("Please Enter the Product Name");
			  Title.focus();
			  return false;
		  }
		  else if(AvailableQuantity.value=='')
		  {
			  alert("Please Enter Available Quantity");
			  AvailableQuantity.focus();
			  return false;
		  }
		  else if(MinimumStockLevel.value=='')
		  {
			  alert("Please Enter Minimum Stock Level");
			  MinimumStockLevel.focus();
			  return false;
		  }
		  else if(Price.value=='')
		  {
			  alert("Please Enter Price");
			  Price.focus();
			  return false;
		  }
		  ValidateProductflag.value="true";
	  }
	return true;	
}

function ValidateDivision()
{
	  with(document.formobject)
	  {		
		  if (Title.value=="")
		  {
			  alert("Please Enter the Division Title");
			  Title.focus();
			  return false;
		  }
		  ValidateDivisionflag.value="true";
	  }
	return true;	
}


//Newsletter
function noblurnewslettercontrol(control)
{
	if(control.value=="")
	{
		control.value="Subscribe to Newsletter";
	}
}

//Validating Subscriber

function ValidateSubscriber()
{
	with(document.newsletterform)
	{
		if(txtEmail.value=="")
		{
			alert("Please Enter the Email Address");
			txtEmail.focus();	
			return false;
		}else if(!(isEmail(txtEmail.value)))
		{
			alert("Please Enter the Email Address(abc@abc.com)");
			txtEmail.focus();	
			return false;
		}
		newsletterflag.value="true";
	}
	document.newsletterform.submit();
}

//Validating Newsletter
function ValidateNewsletter()
{
	with(document.formobject)
	{		
		if (txtNewsLetterTitle.value=="")
		{
			alert("Please Enter the Newsletter Title");
			txtNewsLetterTitle.focus();
			return false;
		}
		ValidateNewsletterflag.value="true";
	}
	return true;	
}


//Validating Newsletter
function ValidateSendNewsletter()
{
		with(document.formobject)
		{
			if (FromCompanyName.value=="")
			{
				alert("Please Enter the From Name");
				FromCompanyName.focus();
				return false;
			}else if(FromEmail.value=="")
			{
				alert("Please Enter the From Email Address");
				FromEmail.focus();	
				return false;
			}else if(!(isEmail(FromEmail.value)))
			{
				alert("Please Enter the  From Email Address(abc@abc.com)");
				FromEmail.focus();	
				return false;
			}else if (txtSubject.value=="")
			{
				alert("Please Enter the Subject of the Email");
				txtSubject.focus();
				return false;
			}else if(ReplyTo.value=="")
			{
				alert("Please Enter the Reply To Email Address");
				ReplyTo.focus();	
				return false;
			}else if(!(isEmail(ReplyTo.value)))
			{
				alert("Please Enter the  Reply To Email Address(abc@abc.com)");
				ReplyTo.focus();	
				return false;
			}else if (NewsletterID.value=='-1')
			{
				alert("Please Select the Newsletter to Send out");
				NewsletterID.focus();
				return false;
			}
				ValidateSendNewsletterflag.value="true";
		}
	return true;	
}

//Validate Product Category
function ValidateProductCategory()
{
		with(document.formobject)
		{		
				if (Title.value=="")
				{
					alert("Please Enter the Category Name");
					Title.focus();
					return false;
				}
				ValidateProductCategoryflag.value="true";
		}
	return true;	
}

//Validate Products



//Loading File Controls
function LoadFileControls()
{
		with(document.formobject)
		{		
			if(FileType.value==1)
			{
				document.getElementById("trfile").style.display="none";
				document.getElementById("trwidth").style.display="";
				document.getElementById("trheight").style.display="";
			}else if(FileType.value=='-1')
			{
				document.getElementById("trfile").style.display="none";
				document.getElementById("trwidth").style.display="none";
				document.getElementById("trheight").style.display="none";
				alert("Please Select the File Type");
				FileType.focus();
			}else
			{
				document.getElementById("trfile").style.display="";
				document.getElementById("trwidth").style.display="none";
				document.getElementById("trheight").style.display="none";
			}
		}
}
function ValidateFiles()
{
		with(document.formobject)
		{		
			if(FileType.value=='-1')
			{
				alert("Please Select the File Type");
				FileType.focus();
				return false;
			}
			if(FileType.value==1)
			{
				if(txtTitle.value=="")
				{
						alert("Please Enter the File Title");
						txtTitle.focus();
						return false;
				}else if(Width.value=="")
				{
						alert("Please Enter the Width");
						Width.focus();
						return false;
				}else if(Height.value=="")
				{
						alert("Please Enter the Height");
						Height.focus();
						return false;
				} 
			}else if(FileType.value=='-1')
			{
				alert("Please Select the Link Type");
				LinkType.focus();
				return false;
			}else
			{
				if(txtTitle.value=="")
				{
						alert("Please Enter the File Title");
						txtTitle.focus();
						return false;
				}else if((Trigger.value=="add") && (File.value.length<5))
				{
						alert("Please upload a File");
						return false;
				}
			}
			ValidateFilesflag.value="true";
		}
	return true;	
}

//Search Files

function SearchFiles()
{
		document.getElementById("searchresult").innerHTML='<img src=images/ajaxloader.gif>';
		with(document.formobject)
		{		
			KeywordValue=txtKeyword.value;
			FileTypeValue=FileType.value;
			PageTitleValue=PageTitle.value;
		}
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return false;
		}
		var url='SearchFiles.php';
		url=url+"?Keyword="+KeywordValue;	
		url=url+"&FileType="+FileTypeValue;	
		url=url+"&PageTitle="+PageTitleValue;	
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=SearchFilesStateChanged;
		xmlHttp.open("GET",url,true);		
		xmlHttp.send(null);
		return false;
}

function SearchFilesStateChanged() 
{ 
		if (xmlHttp.readyState==4)
		{ 	
				document.getElementById("searchresult").innerHTML=xmlHttp.responseText;
		}
}

function PopulateOfferOptions(Value)
{
	document.getElementById("LinkTypeTr").style.display='none';
	document.getElementById("LinkTextTr").style.display='none';
	
	document.getElementById("LinkTitleTr").style.display='none';
	document.getElementById("LinkDescriptionTr").style.display='none';
	document.getElementById("ImagePositionTr").style.display='none';
	
	if(Value==1)
	{
		// Show Text Editor tr
		document.getElementById("LinkTitleTr").style.display='';
		document.getElementById("LinkDescriptionTr").style.display='';
		document.getElementById("ImagePositionTr").style.display='';
	}
	
	if(Value==2)
	{
		// Show external page tr
		document.getElementById("LinkTitleTr").style.display='';
		document.getElementById("LinkTypeTr").style.display='';
		document.getElementById("LinkTextTr").style.display='';
	}
}

function ValidateOffer()
{
	with(document.formobject)
	{
		/*if(OfferBanner.value=='')
		{
			alert("Please Select Banner");
			OfferBanner.focus();
			return false;
		}
		if(CheckExtension(OfferBanner.value)!='jpg' && CheckExtension(OfferBanner.value)!='gif' && 
				CheckExtension(OfferBanner.value)!='swf' && CheckExtension(OfferBanner.value)!='png')
		{
			alert("Only swf, gif, jpg and png files allowed");
			OfferBanner.focus();
			return false;
		}*/
		
		if(LinkType.value=='')
		{
			alert("Please Select Offer Link Type");
			LinkType.focus();
			return false;
		}
		
		if(BannerType.value=='')
		{
			alert("Please Select Banner Type");
			BannerType.focus();
			return false;
		}
		
		if(LinkType.value==1)
		{
			if(LinkTitle.value=='')
			{
				alert("Please Enter Page Title");
				LinkTitle.focus();
				return false;
			}
		}
		
		if(LinkType.value==2)
		{
			if(LinkTitle.value=='')
			{
				alert("Please Enter Page Title");
				LinkTitle.focus();
				return false;
			}
			if(LinkTarget.value=='')
			{
				alert("Please Select Link Target");
				LinkTarget.focus();
				return false;
			}
			if(ExternalLink.value=='')
			{
				alert("Please Enter Link");
				ExternalLink.focus();
				return false;
			}
		}
		ValidateOfferflag.value='true';
	}
	return true;
}

function CheckExtension(filename)
{
	var parts = filename.split('.');
	var extension = parts[parts.length-1];
	return extension.toLowerCase();
}

function ValidateProperty()
{
	with(document.formobject)
	{
		if(Location.value=='')
		{
			alert("Please Select Location");
			Location.focus();
			return false;
		}
		if(Location.value!='' && Area.value=='')
		{
			alert("Please Select Area");
			Area.focus();
			return false;
		}
		else if(LocationType.value=='')
		{
			alert("Please Select Location Type");
			LocationType.focus();
			return false;
		}
		else if(NoOfBedrooms.value=='')
		{
			alert("Please Select Number Of Bedrooms");
			NoOfBedrooms.focus();
			return false;
		}
		else if(MonthlyRent.value=='')
		{
			alert("Please Enter Monthly Rent");
			MonthlyRent.focus();
			return false;
		}
		else if(Name.value=='')
		{
			alert("Please Enter Name");
			Name.focus();
			return false;
		}
		else if(Mobile.value=='')
		{
			alert("Please Enter Mobile");
			Mobile.focus();
			return false;
		}
		else if(Email.value=='')
		{
			alert("Please Enter Email Address");
			Email.focus();
			return false;
		}
		else if(isEmail(Email.value)==false)
		{
			alert("Please Enter Email Address in Correct Foramt");
			Email.focus();
			return false;
		}
		/*else if(TimeToCall.value=='')
		{
			alert("Please Enter Time To Call");
			TimeToCall.focus();
			return false;
		}*/
		ValidatePropertyflag.value='true';
	}
	return true;
}
//Email validation Function
function isEmail(theStr) 
{
	var atIndex = theStr.indexOf('@');
 	var dotIndex = theStr.indexOf('.', atIndex);
 	var flag = true;
 	theSub = theStr.substring(0, dotIndex+1)
 	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
 	{	 
 		flag = false; 
 	}
 	else 
	{ 
 		flag = true; 
 	}
 	return(flag);
}

function GetArea(Selected)
{
	document.getElementById("Spinner").style.display='';
	
	$('#ShowAreas').load("get_areas.php", {'PropertyLocation':Selected}, function() {
		document.getElementById("Spinner").style.display='none';
	});
}
function LoadSubPages(Selected)
{
	document.getElementById("PleaseWait").style.display='';
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return false;
	}
	var url='Load_SubPages.php?MasterPageID=' + Selected + '&sid=' + Math.random();
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			document.getElementById("SubLinkDropDown").innerHTML=xmlHttp.responseText;
			document.getElementById("PleaseWait").style.display='none';
		}
	}
	xmlHttp.open("GET",url,true);		
	xmlHttp.send(null);
	return false;
}

function LoadLocationSubpages(Value, Selected)
{
	document.getElementById("PleaseWait2").style.display='';
	var LocationID = document.getElementById("LocationID").value;
	//alert("LocationID = " + LocationID);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return false;
	}
	var url='Load_Location_SubPages.php?LocationID=' + LocationID + '&MasterPageID=' + Value + '&Selected=' + Selected+ '&sid=' + Math.random();
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			//alert(xmlHttp.responseText);
			document.getElementById("SubLinkDropDown").innerHTML=xmlHttp.responseText;
			document.getElementById("PleaseWait2").style.display='none';
		}
	}
	xmlHttp.open("GET",url,true);		
	xmlHttp.send(null);
}


function LoadLocationMasterPage(LocationID, Selected)
{
	document.getElementById("PleaseWait").style.display='';
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return false;
	}
	var url='Load_Location_Masterpages.php?LocationID=' + LocationID + '&Selected=' + Selected + '&sid=' + Math.random();
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			document.getElementById("LocationMasterLinkDropDown").innerHTML=xmlHttp.responseText;
			document.getElementById("PleaseWait").style.display='none';
		}
	}
	xmlHttp.open("GET",url,true);		
	xmlHttp.send(null);
	//return false;
}

function ValidateAddLink()
{
	with(document.addlinks)
	{
		if(LinkTitle.value=='')
		{
			alert("Please enter title");
			LinkTitle.focus();
			return false;
		}
		else if(Link.value=='')
		{
			alert("Please enter Link");
			Link.focus();
			return false;
		}
		else if(target.value=='')
		{
			alert("Please select Link target");
			target.focus();
			return false;
		}
		ValidateAddLinkFlag.value='true';
	}
	return true;
}

function ValidateRenting()
{
	with(document.formobject)
	{
		if(URL.value=='')
		{
			alert("Please Enter URL");
			URL.focus();
			return false;
		}
		else if(target.value=='')
		{
			alert("Please Enter URL");
			target.focus();
			return false;
		}
		ValidateRentingflag.value='true';
	}
	return true;
}

function numbersonly(e, decimal)
{
	var key;
	var keychar;
	
	if(window.event)
	{
		key = window.event.keyCode;
	}
	else if(e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	keychar = String.fromCharCode(key);
	
	if((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
	{
		return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1))
	{
		return true;
	}
	/*else if (decimal && (keychar == ".")) {*/ 
	else if (decimal)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ValidateAddServices()
{
	with(document.formobject)
	{
		if(Service.value=='')
		{
			alert("Please select service to add");
			Service.focus();
			return false;
		}
		ValidateAddServicesflag.value='true';
	}
	return true;
}

function ValidateAddServicesForDivision()
{
	with(document.formobject)
	{
		if(Service.value=='')
		{
			alert("Please select service to add");
			Service.focus();
			return false;
		}
		ValidateAddServicesForLocationflag.value='true';
	}
	return true;
}

function ValidateDocument()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter Document Title");
			Title.focus();
			return false;
		}
		else if(DocName.value=='' && DocUploaded.value=='0')
		{
			alert("Please Select Document to Upload");
			DocName.focus();
			return false;
		}
		ValidateDocumentflag.value='true';
	}
	return true;
}

function ValidateLogos()
{
	with(document.formobject)
	{
		if(Title.value=='')
		{
			alert("Please Enter Title");
			Title.focus();
			return false;
		}
		else if(LogoName.value=='' && LogoUploaded.value=='0')
		{
			alert("Please Select Logo to Upload");
			LogoName.focus();
			return false;
		}
		else if(LogoName.value!='' && CheckExtension(LogoName.value)!='jpg' && 
		CheckExtension(LogoName.value)!='png' && 
		CheckExtension(LogoName.value)!='gif')
		{
			alert("Only Jpg, Gif and Png Images Allowed");
			LogoName.focus();
			return false;
		}
		ValidateLogoflag.value='true';
	}
	return true;
}

function CheckExtension(filename)
{
	var parts = filename.split('.');
	var extension = parts[parts.length-1];
	return extension.toLowerCase();
}
