function LTrim( value ) 
{
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) 
{
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) 
{
	
	return LTrim(RTrim(value));
	
}

function checkURL(value) 
	{
		var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
		if (tomatch.test(value))
		{
			
				return true;
		}
		else
		{
			 
			return false; 
		}
	
	}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function isValidImage(imagename)
{
	
	imagefile_value = imagename;
	var checkimg = imagefile_value.toLowerCase();
	if (!checkimg.match(/(\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG|\.jpeg|\.JPEG)$/))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function isValidPdfExtension(pdfname){
	pdffile_value = pdfname;
	var checkimg = pdffile_value.toLowerCase();
	if (!checkimg.match(/(\.pdf)$/)){
		return false;
	}else{
		return true;
	}
}

function isValidFlash(flashname)
{

	flashfile_value = flashname;
	var checkflash = flashfile_value.toLowerCase();
	if (!checkflash.match(/(\.swf|\.SWF)$/))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function chkSearch(thisform)
{

	with(thisform)
	{
		if((trim(ArticleSearch.value) == "Enter Keyword here") || (trim(ArticleSearch.value) == ""))
		{
			alert("Please enter search criteria");
			ArticleSearch.value ="";
			ArticleSearch.focus();
			return false;
		}
		
	}
	return true;
}
function chkAdminLogin(thisform)
{

	with(thisform)
	{
		if(trim(txtLoginName.value) == "")
		{
			alert("Login field left blank");
			txtLoginName.focus();
			return false;
		}
		if(trim(txtPassword.value) == "")
		{
			alert("Password field left blank");
			txtPassword.focus();
			return false;
		}
		
		
	}
	return true;
}

function chkcontact(thisform){
	with(thisform){
		if(trim(txtname.value) == ""){
			alert("Name field left blank");
			txtname.focus();
			return false;
		}
		if(trim(txtemail.value) == ""){
			alert("Email field left blank");
			txtemail.focus();
			return false;
		}else{
			//Check for '@' and '.' in Field Email
			if(txtemail.value.indexOf("@")<1 || txtemail.value.indexOf(".")<1){	
					alert("Email Address is Invalid");
					txtemail.value="";
					txtemail.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((txtemail.value.lastIndexOf(".")-(txtemail.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					txtemail.value="";
					txtemail.focus();
					return false;
				}
			 }


		if(trim(txtphnno.value) == ""){
			alert("Phone No left blank");
			txtphnno.focus();
			return false;
		}else{
			if(!IsNumeric(trim(txtphnno.value))) {
				alert("Phone field Invalid");
				txtphnno.focus();
				return false;
			}
		}
		if(trim(txtenquiry.value) == "")
		{
			alert("Enquiry left blank");
			txtenquiry.focus();
			return false;
		}
		
		
	}
	return true;
}

function chkAddSection(thisform)
{

	with(thisform)
	{
		if(trim(txtSectionName.value) == "")
		{
			alert("Section Name field left blank");
			txtSectionName.focus();
			return false;
		}
	}
	return true;
}

function chkAddSubSection(thisform)
{

	with(thisform)
	{
		if(trim(txtSectionName.value) == "")
		{
			alert("Sub-Section Name field left blank");
			txtSectionName.focus();
			return false;
		}
	}
	return true;
}

function chkAddArticle(thisform)
{
	
	with(thisform)
	{
		if(selSection.value == "0")
		{
			alert("Please Select Section");
			selSection.focus();
			return false;
		}
		if(document.getElementById("selCategory")!= null)
		{
		if(selCategory.value == "")
		{
			alert("Please Select Category");
			selCategory.focus();
			return false;
		}
		}
		if(trim(ArticleHeading.value) == "")
		{
			alert("Article heading cannot be left blank");
			ArticleHeading.focus();
			return false;
		}
		if(trim(ArticleSubHeading.value) == "")
		{
			alert("Article Sub-heading cannot be left blank");
			ArticleSubHeading.focus();
			return false;
		}
		if((selAuthor.value == "0") && (trim(AuthorName.value) == ""))
		{
			alert("Please select Author");
			selAuthor.focus();
			return false;
		}
		if(trim(file.value) == "")
		{
			alert("Please upload an article image");
			file.focus();
			return false;
		}
		if(!isValidImage(file.value)){
			alert("Invalid image");
			file.focus();
			return false;
		}

		if(trim(ArticlePublishDate.value) == "")
		{
			alert("Article Publish date cannot be left blank");
			selAuthor.focus();
			return false;
		}
		if(trim(ArticleSummary.value) == "")
		{
			alert("Article Summary cannot be left blank");
			ArticleSummary.focus();
			return false;
		}
		if(trim(ArticleDescription.value) == "")
		{
			alert("Article Desription cannot be left blank");
			ArticleDescription.focus();
			return false;
		}
		
		var oEditor = FCKeditorAPI.GetInstance('ArticleText');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			alert("Article Text cannot be left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(articlePdf.value) !=""){
			if(!isValidPdfExtension(articlePdf.value)){
				alert("Invalid file. Please upload pdf file.");
				articlePdf.focus();
				return false;
			}
		}
		if(trim(ArticlePoint1.value) == "")
		{
			alert("Article Point 1 cannot be left blank");
			ArticlePoint1.focus();
			return false;
		}
		if(trim(ArticlePoint2.value) == "")
		{
			alert("Article Point 2 cannot be left blank");
			ArticlePoint2.focus();
			return false;
		}
		if(trim(ArticlePoint3.value) == "")
		{
			alert("Article Point 3 cannot be left blank");
			ArticlePoint3.focus();
			return false;
		}
		if(trim(ArticlePoint4.value) == "")
		{
			alert("Article Point 4 cannot be left blank");
			ArticlePoint4.focus();
			return false;
		}
		if(trim(ArticlePoint5.value) == "")
		{
			alert("Article Point 5 cannot be left blank");
			ArticlePoint5.focus();
			return false;
		}
		if(trim(ArticleTags.value) == "")
		{
			alert("Article Tags cannot be left blank");
			ArticlePoint5.focus();
			return false;
		}
		if(trim(title.value) == "")
		{
			alert("Title cannot be left blank");
			title.focus();
			return false;
		}
		if(trim(keywords.value) == "")
		{
			alert("Keywords cannot be left blank");
			keywords.focus();
			return false;
		}
		if(trim(description.value) == "")
		{
			alert("Description cannot be left blank");
			description.focus();
			return false;
		}

	}
	return true;
}

function chkAddIssue(thisform)
{
	with(thisform)
	{
		if(trim(file.value) != "")
		{
			if(!isValidImage(file.value))
			{
			alert("Invalid image");
			file.focus();
			return false;
			}
		}
	}
	return true;
}

function chkEditArticle(thisform)
{

	with(thisform)
	{
		if(selSection.value == "0")
		{
			alert("Please Select Section");
			selSection.focus();
			return false;
		}
		if(document.getElementById("selCategory")!= null)
		{
		if(selCategory.value == "")
		{
			alert("Please Select Category");
			selCategory.focus();
			return false;
		}
		}
		if(trim(ArticleHeading.value) == "")
		{
			alert("Article heading cannot be left blank");
			ArticleHeading.focus();
			return false;
		}
		if(trim(ArticleSubHeading.value) == "")
		{
			alert("Article Sub-heading cannot be left blank");
			ArticleSubHeading.focus();
			return false;
		}
		if((selAuthor.value == "0") && (trim(AuthorName.value) == ""))
		{
			alert("Please select Author");
			selAuthor.focus();
			return false;
		}
		
		if(trim(ArticlePublishDate.value) == "")
		{
			alert("Article Publish date cannot be left blank");
			selAuthor.focus();
			return false;
		}
		if(trim(ArticleSummary.value) == "")
		{
			alert("Article Summary cannot be left blank");
			ArticleSummary.focus();
			return false;
		}
		if(trim(ArticleDescription.value) == "")
		{
			alert("Article Desription cannot be left blank");
			ArticleDescription.focus();
			return false;
		}
		
		var oEditor = FCKeditorAPI.GetInstance('ArticleText');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			alert("Article Text cannot be left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(articlePdf.value) !=""){
			if(!isValidPdfExtension(articlePdf.value)){
				alert("Invalid file. Please upload pdf file.");
				articlePdf.focus();
				return false;
			}
		}
		if(trim(ArticlePoint1.value) == "")
		{
			alert("Article Point 1 cannot be left blank");
			ArticlePoint1.focus();
			return false;
		}
		if(trim(ArticlePoint2.value) == "")
		{
			alert("Article Point 2 cannot be left blank");
			ArticlePoint2.focus();
			return false;
		}
		if(trim(ArticlePoint3.value) == "")
		{
			alert("Article Point 3 cannot be left blank");
			ArticlePoint3.focus();
			return false;
		}
		if(trim(ArticlePoint4.value) == "")
		{
			alert("Article Point 4 cannot be left blank");
			ArticlePoint4.focus();
			return false;
		}
		if(trim(ArticlePoint5.value) == "")
		{
			alert("Article Point 5 cannot be left blank");
			ArticlePoint5.focus();
			return false;
		}
		if(trim(ArticleTags.value) == "")
		{
			alert("Article Tags cannot be left blank");
			ArticlePoint5.focus();
			return false;
		}
		if(trim(title.value) == "")
		{
			alert("Title cannot be left blank");
			title.focus();
			return false;
		}
		if(trim(keywords.value) == "")
		{
			alert("Keywords cannot be left blank");
			keywords.focus();
			return false;
		}
		if(trim(description.value) == "")
		{
			alert("Description cannot be left blank");
			description.focus();
			return false;
		}

	}
	return true;
}

function chkAddAuthor(thisform)
{

	with(thisform)
	{
		if(trim(txtAuthorName.value) == "")
		{
			alert("Author Name field left blank");
			txtAuthorName.focus();
			return false;
		}
	}
	return true;
}

function chkAddEditor(thisform)
{
with(thisform)
	{
		if(trim(txtEditorName.value) == "")
		{
			alert("Editor Name field left blank");
			txtEditorName.focus();
			return false;
		}
		if(trim(txtEditorEmail.value) == "")
		{
			alert("Editor Email field left blank");
			txtEditorEmail.focus();
			return false;
		}
		else
			 {
				//Check for '@' and '.' in Field Email
				if(txtEditorEmail.value.indexOf("@")<1 || txtEditorEmail.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					txtEditorEmail.value="";
					txtEditorEmail.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((txtEditorEmail.value.lastIndexOf(".")-(txtEditorEmail.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					txtEditorEmail.value="";
					txtEditorEmail.focus();
					return false;
				}
			 }
		if(trim(txtEditorUname.value) == "")
		{
			alert("Editor Username field left blank");
			txtEditorUname.focus();
			return false;
		}
		else 
		{	
			if(txtEditorUname.value.length < 6){
			alert("Editor Username should contain 6 charaters");
			txtEditorUname.focus();
			return false;
			}
		}
		if(trim(txtEditorPassword.value) == "")
		{
			alert("Editor Password field left blank");
			txtEditorPassword.focus();
			return false;
		}
		else 
		{
			if(txtEditorPassword.value.length < 6){
			alert("Editor password should contain 6 charaters");
			txtEditorPassword.focus();
			return false;
			}
		}
		if(trim(radRole.value) == "")
		{
			alert("Please select the Role");
			radRole.focus();
			return false;
		}
	}
	return true;
}

function insertPageBreak()
{
	
	 var articleText ;

	 articleText = document.getElementById("ArticleText").value;
	
	 appendString = "<pageBreak>";
	 article = articleText+appendString;
	 
	 document.getElementById("ArticleText").value = article;
}

function chkAddReview(thisForm)
{
	with(thisForm)
	{
		if(selCategory.value == "0")
		{
			alert("Please Select Category");
			selCategory.focus();
			return false;
		}
		if(trim(reviewTitle.value) == "")
		{
			alert("Review title field left blank");
			reviewTitle.focus();
			return false;
		}
		if(trim(AuthorName.value) == "")
		{
			alert("Author field left blank");
			AuthorName.focus();
			return false;
		}
		if(trim(publisher.value) == "")
		{
			alert("Publisher field left blank");
			publisher.focus();
			return false;
		}
		/*if(trim(price.value) == "")
		{
			alert("Price field left blank");
			price.focus();
			return false;
		}*/
		if(trim(ArticlePublishDate.value) == "")
		{
			alert("Please select the publish date");
			ArticlePublishDate.focus();
			return false;
		}
		if(trim(file.value) == "")
		{
			alert("Please upload the image");
			file.focus();
			return false;
		}
		if(trim(reviewSummary.value) == "")
		{
			alert("summary field left blank");
			reviewSummary.focus();
			return false;
		}
		if(trim(review.value) == "")
		{
			alert("Review field left blank");
			review.focus();
			return false;
		}
		
	}
}

function chkEditReview(thisForm)
{
	with(thisForm)
	{
		if(selCategory.value == "0")
		{
			alert("Please Select Category");
			selCategory.focus();
			return false;
		}
		if(trim(reviewTitle.value) == "")
		{
			alert("Review title field left blank");
			reviewTitle.focus();
			return false;
		}
		if(trim(AuthorName.value) == "")
		{
			alert("Author field left blank");
			AuthorName.focus();
			return false;
		}
		if(trim(publisher.value) == "")
		{
			alert("Publisher field left blank");
			publisher.focus();
			return false;
		}
	/*	if(trim(price.value) == "")
		{
			alert("Price field left blank");
			price.focus();
			return false;
		}*/
		if(trim(ArticlePublishDate.value) == "")
		{
			alert("Please select the publish date");
			ArticlePublishDate.focus();
			return false;
		}
		if(trim(reviewSummary.value) == "")
		{
			alert("summary field left blank");
			reviewSummary.focus();
			return false;
		}
		if(trim(review.value) == "")
		{
			alert("Review field left blank");
			review.focus();
			return false;
		}
		
	}
}

function chkAddNews(thisForm)
{
	with(thisForm)
	{
		if(trim(NewsTitle.value) == "")
		{
			alert("News title field left blank");
			NewsTitle.focus();
			return false;
		}
		if(trim(file.value) == "")
		{
			alert("Please upload the image");
			file.focus();
			return false;
		}
		
		if(trim(NewsSummary.value) == "")
		{
			alert("Summary field left blank");
			NewsSummary.focus();
			return false;
		}
		if(trim(NewsDesc.value) == "")
		{
			alert("News field left blank");
			NewsDesc.focus();
			return false;
		}
		if(trim(NewsPublishDate.value) == "")
		{
			alert("Please select the publish date");
			NewsPublishDate.focus();
			return false;
		}
		
	}
}

function chkEditNews(thisForm)
{
	with(thisForm)
	{
		if(trim(NewsTitle.value) == "")
		{
			alert("News title field left blank");
			NewsTitle.focus();
			return false;
		}
		if(trim(NewsSummary.value) == "")
		{
			alert("Summary field left blank");
			NewsSummary.focus();
			return false;
		}
		if(trim(NewsDesc.value) == "")
		{
			alert("News field left blank");
			NewsDesc.focus();
			return false;
		}
		if(trim(NewsPublishDate.value) == "")
		{
			alert("Please select the publish date");
			NewsPublishDate.focus();
			return false;
		}
		
	}
}

function chkEditHoroscope(thisForm)
{
	with(thisForm)
	{
		if(trim(HoroSummary.value) == "")
		{
			alert("Summary field left blank");
			HoroSummary.focus();
			return false;
		}
		if(trim(HoroDesc.value) == "")
		{
			alert("Description field left blank");
			HoroDesc.focus();
			return false;
		}
		
	}
}

function chkAddAdPartner(thisForm)
{
	with(thisForm)
	{
		if(trim(companyName.value) == "")
		{
			alert("Company Name field left blank");
			companyName.focus();
			return false;
		}
		/*if(trim(address.value) == "")
		{
			alert("Address field left blank");
			address.focus();
			return false;
		}*/
		if(trim(website.value) == "")
		{
			alert("Website field left blank");
			website.focus();
			return false;
		}
		/*if(trim(phone.value) == "")
		{
			alert("Phone field left blank");
			website.focus();
			return false;
		}
		if(trim(email.value) == "")
		{
			alert("email field left blank");
			email.focus();
			return false;
		}
		*/
		if(trim(file.value) == "")
		{
			alert("Please upload the image");
			file.focus();
			return false;
		}
		
		if(trim(ArticleSummary.value) == "")
		{
			alert("Summary field left blank");
			ArticleSummary.focus();
			return false;
		}
		if(trim(ArticleText.value) == "")
		{
			alert("Text field left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(adStartDate.value) == "")
		{
			alert("Please select the start date");
			adStartDate.focus();
			return false;
		}
		if(trim(adEnddate.value) == "")
		{
			alert("Please select the end date");
			adEnddate.focus();
			return false;
		}
			
	}
}

function chkEditAdPartner(thisForm)
{
	with(thisForm)
	{
		if(trim(companyName.value) == "")
		{
			alert("Company Name field left blank");
			companyName.focus();
			return false;
		}
		/*if(trim(address.value) == "")
		{
			alert("Address field left blank");
			address.focus();
			return false;
		}*/
		if(trim(website.value) == "")
		{
			alert("Website field left blank");
			website.focus();
			return false;
		}
	/*	if(trim(phone.value) == "")
		{
			alert("Phone field left blank");
			website.focus();
			return false;
		}
		if(trim(email.value) == "")
		{
			alert("email field left blank");
			email.focus();
			return false;
		}*/
		if(trim(ArticleSummary.value) == "")
		{
			alert("Summary field left blank");
			ArticleSummary.focus();
			return false;
		}
		if(trim(ArticleText.value) == "")
		{
			alert("Text field left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(adStartDate.value) == "")
		{
			alert("Please select the start date");
			adStartDate.focus();
			return false;
		}
		if(trim(adEnddate.value) == "")
		{
			alert("Please select the end date");
			adEnddate.focus();
			return false;
		}
			
	}
}
function chkAddEvent(thisForm)
{
	with(thisForm)
	{
		if(trim(eventTitle.value) == "")
		{
			alert("Event title field left blank");
			eventTitle.focus();
			return false;
		}
		/*if(trim(file.value) == "")
		{
			alert("Please upload the image");
			file.focus();
			return false;
		}*/
		
		if(trim(eventSummary.value) == "")
		{
			alert("Summary field left blank");
			eventSummary.focus();
			return false;
		}
		if(trim(ArticleText.value) == "")
		{
			alert("Text field left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(eventLocation.value) == "")
		{
			alert("Event location field left blank");
			eventLocation.focus();
			return false;
		}
		if(trim(eventStartDate.value) == "")
		{
			alert("Please select the start date");
			eventStartDate.focus();
			return false;
		}
		if(trim(eventEndDate.value) == "")
		{
			alert("Please select the end date");
			eventEndDate.focus();
			return false;
		}
		if(trim(eventStartTime.value) != "")
		{
			if(selStartTime.value == "0")
			{
				alert("Please select the time");
				selStartTime.focus();
				return false;
			}
			
		}
		if(trim(eventEndTime.value) != "")
		{
			if(selEndTime.value == "0")
			{
				alert("Please select the time");
				selEndTime.focus();
				return false;
			}
			
		}
		
	}
}

function chkEditEvent(thisForm)
{
	with(thisForm)
	{
		if(trim(eventTitle.value) == "")
		{
			alert("Event title field left blank");
			eventTitle.focus();
			return false;
		}
		if(trim(eventSummary.value) == "")
		{
			alert("Summary field left blank");
			eventSummary.focus();
			return false;
		}
		if(trim(ArticleText.value) == "")
		{
			alert("Text field left blank");
			ArticleText.focus();
			return false;
		}
		if(trim(eventLocation.value) == "")
		{
			alert("Event location field left blank");
			eventLocation.focus();
			return false;
		}
		if(trim(eventStartDate.value) == "")
		{
			alert("Please select the start date");
			eventStartDate.focus();
			return false;
		}
		if(trim(eventEndDate.value) == "")
		{
			alert("Please select the end date");
			eventEndDate.focus();
			return false;
		}
		if(trim(eventStartTime.value) != "")
		{
			if(selStartTime.value == "0")
			{
				alert("Please select the time");
				selStartTime.focus();
				return false;
			}
			
		}
		if(trim(eventEndTime.value) != "")
		{
			if(selEndTime.value == "0")
			{
				alert("Please select the time");
				selEndTime.focus();
				return false;
			}
			
		}
		
	}
}
function enableImpressions(str)
{
	
	if(document.getElementById("unlimited").checked == true)
	{
		document.getElementById("unlimited").disabled =false;
		document.getElementById("impressions").disabled = true;
	}
	else
	{
		document.getElementById("unlimited").disabled =false;
		document.getElementById("impressions").disabled = false;
	}
}
function chkAddBanner(thisForm)
{
	with(thisForm)
	{
		if(trim(bannerName.value) == "")
		{
			alert("Name field left blank");
			bannerName.focus();
			return false;
		}
		if(selSection.value == "")
		{
			alert("Please Select Section");
			selSection.focus();
			return false;
		}
		if(selPosition.value == "0")
		{
			alert("Please Select Position");
			selPosition.focus();
			return false;
		}
		if(selType.value == "")
		{
			alert("Please Select Type");
			selType.focus();
			return false;
		}
		if(selType.value == "js")
			{
				if(trim(jsCode.value) == "")
				{
					alert("Code cannot be left blank");
					jsCode.focus();
					return false;
				}
			}
			else if(selType.value == "image")
				{
					if(trim(file.value) == "")
					{
						alert("Please upload the image");
						file.focus();
						return false;
					}
					else
					{

						if(isValidImage(trim(file.value)) == false)
						{
							alert("Please upload image in right format.");
							file.focus();
							return false;
						}
					}

					if(checkURL(trim(bannerUrl.value)) == false)
				{
						alert("Invalid Url");
						bannerUrl.focus();
						return false;
				}
				} 
				else if(selType.value == "image")
					{
						if(trim(file.value) == "")
						{
							alert("Please upload the image");
							file.focus();
							return false;
						}
						else
						{
							if(isValidFlash(trim(file.value)) == false)
							{
								alert("Please upload flash file in right format.");
								file.focus();
								return false;
							}
						}

						if(checkURL(trim(bannerUrl.value)) == false)
						{
							alert("Invalid Url");
							bannerUrl.focus();
							return false;
						}

					}
				else {}
		
		
		if(unlimited.checked == false)
		{
			
			if(IsNumeric(impressions) ==false)
			{
				alert("Invalid Impressions");
				impressions.focus();
				return false;
			}
		}
		if(trim(bannerStartDate.value) == "")
		{
			alert("Please select the start date");
			bannerStartDate.focus();
			return false;
		}
		if(trim(bannerEndDate.value) == "")
		{
			alert("Please select the Expiry date");
			bannerEndDate.focus();
			return false;
		}
		
	}
}

function chkEditBanner(thisForm)
{
	with(thisForm)
	{
		if(trim(bannerName.value) == "")
		{
			alert("Name field left blank");
			bannerName.focus();
			return false;
		}
		if(selSection.value == "")
		{
			alert("Please Select Section");
			selSection.focus();
			return false;
		}
		if(selPosition.value == "0")
		{
			alert("Please Select Position");
			selPosition.focus();
			return false;
		}
		if(selType.value == "")
		{
			alert("Please Select Type");
			selType.focus();
			return false;
		}
		if(selType.value == "js")
			{
				if(trim(jsCode.value) == "")
				{
					alert("Code cannot be left blank");
					jsCode.focus();
					return false;
				}
			}
			else if(selType.value == "image")
				{
					if(isValidImage(trim(file.value)) == false)
						{
							alert("Please upload image in right format.");
							file.focus();
							return false;
						}
					
				} 
				else if(selType.value == "image")
					{
					if(isValidFlash(trim(file.value)) == false)
							{
								alert("Please upload flash file in right format.");
								file.focus();
								return false;
							}
						

					}
				else {}
		
		if(checkURL(trim(bannerUrl.value)) == false)
		{
			alert("Invalid Url");
			bannerUrl.focus();
			return false;
		}
		if(unlimited.checked == false)
		{
			
			if(IsNumeric(impressions) ==false)
			{
				alert("Invalid Impressions");
				impressions.focus();
				return false;
			}
		}
		if(trim(bannerStartDate.value) == "")
		{
			alert("Please select the start date");
			bannerStartDate.focus();
			return false;
		}
		if(trim(bannerEndDate.value) == "")
		{
			alert("Please select the Expiry date");
			bannerEndDate.focus();
			return false;
		}
		
	}
}

function sectionblock()
{
	var sectionName = document.getElementById("secName").value;
	content = '<table border="0"><tr><td colspan="4">Publish this article to the '+sectionName+'  Homepage?&nbsp;<select name="selsectionBlock"><option value="0">No</option><option value="1">Main Block</option><option value="2">Block 1</option><option value="3">Block 2</option><option value="4">Block 3</option><option value="5">Block 4</option></select></tr></table>';
	document.getElementById("homeDiv").innerHTML=content;
}
function myPopup2(email,listid,businessName) {
url =  "http://www.wellbeing.com.au/php/popup.php?email="+email+"&id="+listid+"&bn="+businessName;
window.open(url, "Send_The_Business_Email", "status = 1, height = 300, width = 350, resizable = 0" )
}
function chksendmail1(thisForm)
{
	
	with(thisForm)
	{
		if(trim(send_name.value) == "")
		{
			alert("Sender Name is left blank");
			send_name.focus();
			return false;
		}
		if(trim(send_email.value) == "")
		{
			alert("Sender Email is left blank");
			send_email.focus();
			return false;
		}
		else
			 {
				//Check for '@' and '.' in Field Email
				if(send_email.value.indexOf("@")<1 || send_email.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					send_email.value="";
					send_email.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((send_email.value.lastIndexOf(".")-(send_email.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					send_email.value="";
					send_email.focus();
					return false;
				}
			 }
		if(trim(send_phone.value) == "")
		{
			alert("Sender Phone is left blank");
			send_phone.focus();
			return false;
		}
		if(trim(txtMessage.value) == "")
		{
			alert("Message is left blank");
			txtMessage.focus();
			return false;
		}
		sendername = send_name.value;
		senderEmail = send_email.value;
		senderPhone = send_phone.value;
		sendermessage = txtMessage.value;
		toE = toEmail.value;
		listingId = businessListingId.value;
		funcall1(sendername,senderEmail,senderPhone,sendermessage,toE,listingId);
		return false;
	}
}
function chksendmail(thisForm)
{
	with(thisForm)
	{
		if(trim(send_name.value) == "")
		{
			alert("Sender Name is left blank");
			send_name.focus();
			return false;
		}
		if(trim(send_email.value) == "")
		{
			alert("Sender Email is left blank");
			send_email.focus();
			return false;
		}
		else
			 {
				//Check for '@' and '.' in Field Email
				if(send_email.value.indexOf("@")<1 || send_email.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					send_email.value="";
					send_email.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((send_email.value.lastIndexOf(".")-(send_email.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					send_email.value="";
					send_email.focus();
					return false;
				}
			 }
		if(trim(send_phone.value) == "")
		{
			alert("Sender Phone is left blank");
			send_phone.focus();
			return false;
		}
		if(trim(txtMessage.value) == "")
		{
			alert("Message is left blank");
			txtMessage.focus();
			return false;
		}
		sendername = send_name.value;
		senderEmail = send_email.value;
		senderPhone = send_phone.value;
		sendermessage = txtMessage.value;
		toE = toEmail.value;
		listingId = businessListingId.value;
		funcall(sendername,senderEmail,senderPhone,sendermessage,toE,listingId);
		return false;
	}
}
function funcall1(name,email,phone,msg,toE,listingId)
{
	xmlHttp=GetXmlHttpObject();
	var url="http://www.wellbeing.com.au/sendmail.php";
	url=url+"?name="+name+"&email="+email+"&phone="+phone+"&msg="+msg+"&toE="+toE+"&id="+listingId;
	xmlHttp.onreadystatechange=MsgContent;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return false;
	
}
function MsgContent()
{
	
	document.getElementById("send1").innerHTML = "Thank you for sending an email.<a href='#' onclick='window.close();'>Close</a>";
}
function funcall(name,email,phone,msg,toE,listingId)
{
	xmlHttp=GetXmlHttpObject();
	var url="http://www.wellbeing.com.au/sendmail.php";
	url=url+"?name="+name+"&email="+email+"&phone="+phone+"&msg="+msg+"&toE="+toE+"&id="+listingId;
	
	xmlHttp.onreadystatechange=test;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return false;
}
function test()
{
	document.frmmail.send_name.value="";
	document.frmmail.send_email.value="";
	document.frmmail.send_phone.value="";
	document.frmmail.txtMessage.value="";
	url =  "http://www.wellbeing.com.au/php/thanksPopup.php";
	window.open(url, "Send The Business Email", "status = 1, height = 300, width = 350, resizable = 0" )
	
}
// GetXmlHttpObject 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;
	}
function chkLogin(thisform)
{

	with(thisform)
	{
		if(trim(email.value) == "")
		{
			alert("Please enter your email address");
			email.focus();
			return false;
		}
		else
			 {
				//Check for '@' and '.' in Field Email
				if(email.value.indexOf("@")<1 || email.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					email.value="";
					email.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((email.value.lastIndexOf(".")-(email.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					email.value="";
					email.focus();
					return false;
				}
			 }
		if(trim(password.value) == "")
		{
			alert("Password field left blank");
			password.focus();
			return false;
		}
		
		
	}
	return true;
}
function validateUser(thisForm)
{
	with(thisForm)
	{
		if(trim(forename.value) == "")
		{
			alert("FirstName field left blank");
			forename.focus();
			return false;
		}
		if(trim(surname.value) == "")
		{
			alert("Surname field left blank");
			surname.focus();
			return false;
		}
		if(trim(email.value) == "")
		{
			alert("Email field left blank");
			email.focus();
			return false;
		}
		else
			 {
				//Check for '@' and '.' in Field Email
				if(email.value.indexOf("@")<1 || email.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					email.value="";
					email.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((email.value.lastIndexOf(".")-(email.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					email.value="";
					email.focus();
					return false;
				}
			 }
		 if(trim(password.value) == "")
		{
			alert("Password field left blank");
			password.focus();
			return false;
		}
		else 
		{
			if(password.value.length < 6){
			alert("Password should contain 6 charaters");
			password.focus();
			return false;
			}
		}
		if(trim(confirm.value) == "")
		{
			alert("Confirm Password field left blank");
			confirm.focus();
			return false;
		}

		if(trim(confirm.value) != trim(password.value))
		{
			alert("Confirm password should match");
			confirm.focus();
			return false;
		}
		if(trim(business_name.value) == "")
		{
			alert("Business Name field left blank");
			business_name.focus();
			return false;
		}
		if(trim(address1.value) == "")
		{
			alert("Address field left blank");
			address1.focus();
			return false;
		}
		if(trim(town.value) == "")
		{
			alert("Town field left blank");
			town.focus();
			return false;
		}
		if(trim(postcode.value) == "")
		{
			alert("PostCode field left blank");
			postcode.focus();
			return false;
		}
		if(trim(tel.value) == "")
		{
			alert("Telephone field left blank");
			tel.focus();
			return false;
		}
		if(trim(mobile.value) == "")
		{
			alert("Mobile field left blank");
			mobile.focus();
			return false;
		}
		if(terms.checked == false)
		{
			alert("Please Read & accept Terms & conditions");
			terms.focus();
			return false;
		}
	
	}
}
function openChangeDiv(divId)
{
	if(document.getElementById(divId).style.visibility == "hidden"){
	document.getElementById(divId).style.visibility="visible";
	document.getElementById(divId).style.display="block";
	}else{
	document.getElementById(divId).style.visibility="hidden";
	document.getElementById(divId).style.display="none";
	}

}

function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 250) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
   }
  function citydisplay(state,divid)
{
	for(c=0;c<city.length;c=c+2)
	{
		//alert(city);
		if(city[c+1] == state)
		{
			var cityOptions = cityOptions+"<option value='"+city[c]+"'>"+city[c]+"</option>";
		}
	}
	//alert(cityOptions);
	var citySelect = '<select name=\'bus_city\' style="width:135px">'+cityOptions+'</select>';
	document.getElementById(divid).innerHTML = citySelect;

}

 function citySubscriptionDisplay(state,divid)
{
	for(c=0;c<city.length;c=c+2)
	{
		//alert(city);
		if(city[c+1] == state)
		{			
			var cityOptions = cityOptions+"<option value='"+city[c]+"'>"+city[c]+"</option>";
		}
	}
	//alert(cityOptions);
	var citySelect = '<select name=\'bus_subcity\' style="width:135px">'+cityOptions+'</select>';
	document.getElementById(divid).innerHTML = citySelect;

}

function addElement() {
  var ni = document.getElementById('businessAddress');
  var numi = document.getElementById('theValue');
  var num = (document.getElementById('theValue').value -1)+2;

  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'business'+num;
  newdiv.setAttribute('id',divIdName);
  
  for(j=0;j<country.length;j=j+2)
	{
	  if(country[j] == "AU")
		{
		  var selectoption = "selected";
		}
		else
		{
			var selectoption = "";
		}
	  var countryOptions = countryOptions+"<option value='"+country[j]+"' "+selectoption+">"+country[j+1]+"</option>";
	 
	}
	stateOptions = "<option value=''>Select State</option>"
	for(s=0;s<state.length;s++)
	{

	  var stateOptions = stateOptions+"<option value='"+state[s]+"'>"+state[s]+"</option>";
	 
	}
	
	var cityid = 'bus_city'+num;
  newdiv.innerHTML = '<table style="margin-top:20px"><tr><td>Title:</td><td><input name=\'bus_title'+num+'\' type="text" value="" />e.g. Sydney Office</td></tr><tr><td>Address:</td><td><input name=\'bus_address'+num+'\' type="text" /></td></tr><tr><td>Postcode:</td><td><input name=\'bus_postcode'+num+'\' type="text" size="4" maxlength="4" /></td></tr><tr><td>Country:</td><td><select name=\'bus_country'+num+'\' style="width:135px">'+countryOptions+'</select></td></tr><tr><td>State:</td><td><select name=\'bus_state'+num+'\' style="width:135px" onchange=\'citydisplay1(this.value,"'+cityid+'","'+num+'");\'>'+stateOptions+'</select></td></tr><tr><td>City:</td><td id="bus_city'+num+'"><select name=\'bus_city'+num+'\' style="width:135px"><option value="">Select City</option></select></td></tr><tr><td>Daytime telephone: </td><td><input name=\'bus_phone'+num+'\' type="text" /></td></tr> <tr><td>Mobile telephone: </td><td><input name=\'bus_mobile'+num+'\' type="text" /></td></tr><tr><td>Fax: </td><td><input name=\'bus_fax'+num+'\' type="text" /></td></tr><tr><td>Email Address:</td><td><input name=\'email_addr'+num+'\' type="text" /></td></tr><tr><td colspan="2"><p class="edit_btn"><a href=\'#\' onclick=\'removeElement("'+divIdName+'")\'>Delete</a></p></td></tr></table>';
  ni.appendChild(newdiv);
}
function citydisplay1(state,divid,num)
{
	//alert(city);
	
	for(c=0;c<city.length;c=c+2)
	{
		
		if(city[c+1] == state)
		{
			var cityOptions = cityOptions+"<option value='"+city[c]+"'>"+city[c]+"</option>";
		}
	}
	//alert(cityOptions);
	var citySelect = '<select name=\'bus_city'+num+'\' id=\'bus_city'+num+'\' style="width:135px">'+cityOptions+'</select>';
	//alert(citySelect);
	document.getElementById(divid).innerHTML = citySelect;

}

function citydisplaySubscription(state,divid,num)
{
	//alert(city);
	
	for(c=0;c<city.length;c=c+2)
	{
		
		if(city[c+1] == state)
		{
			var cityOptions = cityOptions+"<option value='"+city[c]+"'>"+city[c]+"</option>";
		}
	}
	//alert(cityOptions);
	var citySelect = '<select name="bus_subcity" id="bus_subcity" style="width:135px">'+cityOptions+'</select>';
	//alert(citySelect);
	document.getElementById(divid).innerHTML = citySelect;

}

function citydisplay2(state,divid,cityval)
{
	//alert(city);
	//alert(cityval);
	for(c=0;c<city.length;c=c+2)
	{
		//alert(city);
		if(city[c+1] == state)
		{
			if(cityval == city[c])
			{
				var citySelect = "selected";
			}
			else
			{
				var citySelect = "";
			}
			var cityOptions = cityOptions+"<option value='"+city[c]+"' "+citySelect+">"+city[c]+"</option>";
		}
	}
	//alert(cityOptions);
	var citySelect = '<select name="bus_subcity" style="width:135px">'+cityOptions+'</select>';
	document.getElementById(divid).innerHTML = citySelect;

}

function removeElement(divNum) {
	
  var d = document.getElementById('businessAddress');
  var olddiv = document.getElementById(divNum);
 d.removeChild(olddiv);
}
function checkOnlineBusiness()
{
	
	if(document.getElementById("online_bus").checked == true)
	{
		document.getElementById("businessAddress").style.display = "none";
	}
	else
	{
		document.getElementById("businessAddress").style.display = "block";
	}
	
}

function openPractitionerDiv(catId)
{
	if(catId ==4)
	{
	document.getElementById('practitionersDiv').style.visibility = "visible";
	document.getElementById('practitionersDiv').style.display = "block";
	}
}

function showProdSearch(catId){
	document.getElementById('prodsearch').style.display = "none";
	document.getElementById('retailersearch').style.display = "none";
	document.getElementById('coursesearch').style.display = "none";
	document.getElementById('spasearch').style.display = "none";
	document.getElementById('prodinviDiv').style.display = "block";
	if(catId == 116){
		document.getElementById('prodsearch').style.visibility = "visible";
		document.getElementById('prodsearch').style.display = "block";
		document.getElementById('prodinviDiv').style.visibility = "hidden";
		document.getElementById('prodinviDiv').style.display = "none";

	}else if(catId == 3){
		document.getElementById('coursesearch').style.visibility = "visible";
		document.getElementById('coursesearch').style.display = "block";
	}else if(catId == 2){
		document.getElementById('retailersearch').style.visibility = "visible";
		document.getElementById('retailersearch').style.display = "block";
	}else if(catId == 1){
		document.getElementById('spasearch').style.visibility = "visible";
		document.getElementById('spasearch').style.display = "block";
	}else{
		document.getElementById('prodsearch').style.display = "none";
		document.getElementById('retailersearch').style.display = "none";
		document.getElementById('coursesearch').style.display = "none";
		document.getElementById('spasearch').style.display = "none";
	}
}

function openDiv()
{
	var ni = document.getElementById('practitionersDiv');
	var numi = document.getElementById('PracValue');
	var num = (document.getElementById('PracValue').value -1)+2;

	numi.value = num;
	var newdiv = document.createElement('div');
	var divIdName = 'practitioner'+num;
	newdiv.setAttribute('id',divIdName);
  
	
  newdiv.innerHTML = '<table width="42%" border="0" cellspacing="0" cellpadding="0"><tr><td>Practitioners Name/Personal</td><td><input type="text" name=\'txtpractitioner'+num+'\' value=""></td></tr><tr><td>Qualification</td><td><input type="text" name=\'txtQualification'+num+'\' value=""></td></tr><tr><td colspan="2"><p class="edit_btn"><a href=\'#\' onclick=\'removePractitionerDiv("'+divIdName+'")\'>Delete</a></p></td></tr></table>';
  ni.appendChild(newdiv);
	
}

function removePractitionerDiv(divNum) {
	
  var d = document.getElementById('practitionersDiv');
  var olddiv = document.getElementById(divNum);
 d.removeChild(olddiv);
}
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}

function fckTextCounter(field,cntfield,maxlimit) {
//		  alert ("Field"+field+" ..... ");
		  if(field.split(' ').length>maxlimit)
//if (field.length > maxlimit) // if too long...trim it!
				field = field.substring(0, maxlimit);
// otherwise, update 'characters left' counter
		else
				cntfield.value = maxlimit - field.split(' ').length;
}

function chkPaidListing(thisForm)
{
	with(thisForm)
	{
		if(subscription.checked == true)
		{
			if(trim(txtClientName.value) == "")
		{
			alert("Client Name field cannot be left blank");
			txtClientName.focus();
			return false;
		}
		}
		if(promotional.checked == true)
		{
			if(trim(txtClientName.value) == "")
		{
			alert("Client Name field cannot be left blank");
			txtClientName.focus();
			return false;
		}
		}
	}
}
function chk_subscription()
{
	if(document.getElementById("subscription").checked == true)
	{
		document.getElementById("subscriptionbox").style.display = "block";	
	}
	else
	{
		
		document.getElementById("subscriptionbox").style.display = "none";
	}
}

function chkUniversalNews(thisForm){
	with(thisForm){
		document.getElementById("categoryError").style.display='none';
		document.getElementById("headlineError").style.display='none';
		document.getElementById("descriptionError").style.display='none';
		document.getElementById("articleLinkError").style.display='none';
		//document.getElementById("imageError").style.display='none';
		
		document.getElementById("cmbCategory").style.border='1px solid #81adae';
		document.getElementById("headline").style.border='1px solid #81adae';
		document.getElementById("description").style.border='1px solid #81adae';
		document.getElementById("articleLink").style.border='1px solid #81adae';
		//document.getElementById("newimg").style.border='1px solid #81adae';
		
		if(cmbCategory.selectedIndex<1){
			document.getElementById("categoryError").style.display='';
			document.getElementById("cmbCategory").style.border='1px solid red';
			cmbCategory.focus();
			return false;
		}
		if(headline.value==""){
			document.getElementById("headlineError").style.display='';
			document.getElementById("headline").style.border='1px solid red';
			headline.focus();
			return false;
		}
		var oEditor = FCKeditorAPI.GetInstance('description');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			document.getElementById("descriptionError").style.display='';
			document.getElementById("description").style.border='1px solid red';
			description.focus();
			return false;
		}

		/*if(htmlValue.split(' ').length>150){
			document.getElementById("descriptionError").style.display='';
			document.getElementById("description").style.border='1px solid red';
			document.getElementById("descriptionError").innerHTML="Description should not be greater than 150 words";
			description.focus();
			return false;
		}*/

		if(articleLink.value==""){
			document.getElementById("articleLinkError").style.display='';
			document.getElementById("articleLink").style.border='1px solid red';
			articleLink.focus();
			return false;
		}
		/*if(newimg.value==""){
			document.getElementById("imageError").style.display='';
			document.getElementById("newimg").style.border='1px solid red';
			newimg.focus();
			return false;
		}*/
	
		return true;
	}
}

function chkEditUniversalNews(thisForm){
	with(thisForm){
		
		document.getElementById("categoryError").style.display='none';
		document.getElementById("headlineError").style.display='none';
		document.getElementById("descriptionError").style.display='none';
		document.getElementById("articleLinkError").style.display='none';
		
		document.getElementById("cmbCategory").style.border='1px solid #81adae';
		document.getElementById("headline").style.border='1px solid #81adae';
		document.getElementById("description").style.border='1px solid #81adae';
		document.getElementById("articleLink").style.border='1px solid #81adae';
		
		if(cmbCategory.selectedIndex<1){
			document.getElementById("categoryError").style.display='';
			document.getElementById("cmbCategory").style.border='1px solid red';
			cmbCategory.focus();
			return false;
		}
		
		if(headline.value==""){
			document.getElementById("headlineError").style.display='';
			document.getElementById("headline").style.border='1px solid red';
			headline.focus();
			return false;
		}

		var oEditor = FCKeditorAPI.GetInstance('description');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			document.getElementById("descriptionError").style.display='';
			document.getElementById("description").style.border='1px solid red';
			description.focus();
			return false;
		}

		/*if(description.value.split(' ').length>150){
			document.getElementById("descriptionError").style.display='';
			document.getElementById("description").style.border='1px solid red';
			document.getElementById("descriptionError").innerHTML="Description should not be greater than 150 words";
			description.focus();
			return false;
		}*/

		if(articleLink.value==""){
			document.getElementById("articleLinkError").style.display='';
			document.getElementById("articleLink").style.border='1px solid red';
			articleLink.focus();
			return false;
		}
			
		return true;
	}
}

function chkUniversalUser(thisForm){
	with(thisForm){
		
		document.getElementById("userNameError").style.display='none';
		document.getElementById("otherEmailError").style.display='none';
		
		/*
		document.getElementById("nameError").style.display='none';
		document.getElementById("addressError").style.display='none';
		document.getElementById("phoneError").style.display='none';
		document.getElementById("mobileError").style.display='none';
		document.getElementById("dateError").style.display='none';
		document.getElementById("monthError").style.display='none';
		document.getElementById("yearError").style.display='none';
		document.getElementById("userImageError").style.display='none';
		document.getElementById("postalCodeError").style.display='none';
		document.getElementById("countryError").style.display='none';*/

		document.getElementById("userprofile").style.border='1px solid #81adae';
		/*document.getElementById("name").style.border='1px solid #81adae';
		document.getElementById("address").style.border='1px solid #81adae';
		document.getElementById("phone").style.border='1px solid #81adae';
		document.getElementById("mobile").style.border='1px solid #81adae';
		document.getElementById("month").style.border='1px solid #81adae';
		document.getElementById("date").style.border='1px solid #81adae';
		document.getElementById("year").style.border='1px solid #81adae';
		document.getElementById("userImage").style.border='1px solid #81adae';
		document.getElementById("postcode").style.border='1px solid #81adae';
		document.getElementById("country").style.border='1px solid #81adae';*/

		function checkmail(field)
			{
		with(field)
		{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if(apos<1||dotpos-apos<2||(value.length-1)<=dotpos)
		 {return false;}
		else {return true;}
		}
		}
		if(userprofile.value==""){
			document.getElementById("userNameError").style.display='';
			document.getElementById("userprofile").style.border='1px solid red';
			userprofile.focus();
			return false;
		}
		if(email.value==""){
			document.getElementById("otherEmailError").style.display='';
			document.getElementById("email").style.border='1px solid red';
			email.focus();
			return false;
		}
		if(checkmail(email)==false)
		{	document.getElementById("otherError").style.display='';
			document.getElementById("email").style.border='1px solid red';
			email.focus();
			return false;
		}

		

		/*if(name.value==""){
			document.getElementById("nameError").style.display='';
			document.getElementById("name").style.border='1px solid red';
			name.focus();
			return false;
		}
		if(address.value==""){
			document.getElementById("addressError").style.display='';
			document.getElementById("address").style.border='1px solid red';
			address.focus();
			return false;
		}
		if(phone.value==""){
			document.getElementById("phoneError").style.display='';
			document.getElementById("phone").style.border='1px solid red';
			phone.focus();
			return false;
		}
		if(isNaN(phone.value)){
			document.getElementById("phoneError").style.display='';
			document.getElementById("phone").style.border='1px solid red';
			phone.focus();
			return false;
		}
		if(mobile.value==""){
			document.getElementById("mobileError").style.display='';
			document.getElementById("mobile").style.border='1px solid red';
			mobile.focus();
			return false;
		}
		//email regular expression
		//^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$
		
		if(month.selectedIndex<1){
			document.getElementById("monthError").style.display='';
			document.getElementById("month").style.border='1px solid red';
			month.focus();
			return false;
		}
		if(date.selectedIndex<1){
			document.getElementById("dateError").style.display='';
			document.getElementById("date").style.border='1px solid red';
			date.focus();
			return false;
		}
		if(year.selectedIndex<1){
			document.getElementById("yearError").style.display='';
			document.getElementById("year").style.border='1px solid red';
			year.focus();
			return false;
		}
		if(userImage.value==""){
			document.getElementById("userImageError").style.display='';
			document.getElementById("userImage").style.border='1px solid red';
			userImage.focus();
			return false;
		}
		if(postcode.value==""){
			document.getElementById("postalCodeError").style.display='';
			document.getElementById("postcode").style.border='1px solid red';
			postcode.focus();
			return false;
		}
		if(country.selectedIndex<1){
			document.getElementById("countryError").style.display='';
			document.getElementById("country").style.border='1px solid red';
			country.focus();
			return false;
		}*/
		return true;
	}
}

//community section
var xml_http;
function getRateCount(newsid,userid,rateCount,cid){
	try{
		// Firefox, Opera 8.0+, Safari
		xml_http=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xml_http=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			xml_http=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	var url="http://www.wellbeing.com.au/getRateCount.php";
	url=url+"?news_id="+newsid+"&user_id="+userid+"&rateCount="+rateCount+"&CID="+cid+"&page=community";
	xml_http.onreadystatechange=setOutPut;
	xml_http.open("GET",url,true);
	xml_http.send(null);
	return false;
}

function setOutPut(){
	
	if (xml_http.readyState==4){
		if(xml_http.responseText!=""){
			var responseSubString=xml_http.responseText.substring(0,4);
			if("http"==responseSubString){
				window.location=xml_http.responseText;
			}else{
				alert(xml_http.responseText);
			}
			return false;
		}
	}
	return false;
	//document.getElementById("rateCountMessage").style.display="block";
	//document.getElementById("rateCountMessage").innerHTML=xmlHttp.responseText;
	//return false;
}

//popular community section
var XMLHTTP;
function getPopularRateCount(newsid,userid,rateCount){
	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");
		}
	}
	
	var url="http://www.wellbeing.com.au/getRateCount.php";
	url=url+"?news_id="+newsid+"&user_id="+userid+"&rateCount="+rateCount;
	XMLHTTP.onreadystatechange=displayOutPut;
	XMLHTTP.open("GET",url,true);
	XMLHTTP.send(null);
	return false;
}

function displayOutPut(){
	if (XMLHTTP.readyState==4){
		if(XMLHTTP.responseText!=""){
			var responseSubString=XMLHTTP.responseText.substring(0,4);
			if("http"==responseSubString){
				window.location=XMLHTTP.responseText;
			}else{
				alert(XMLHTTP.responseText);
			}
			return false;
		}
	}
	return false;
	//document.getElementById("rateCountMessage").style.display="block";
	//document.getElementById("rateCountMessage").innerHTML=xmlHttp.responseText;
	//return false;
}

//popular community section
var xmlhttp;
function getDetailRateCount(newsid,userid,rateCount){
	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");
		}
	}
	
	var url="http://www.wellbeing.com.au/getRateCount.php";
	url=url+"?news_id="+newsid+"&user_id="+userid+"&rateCount="+rateCount+"&page=detail";
	xmlhttp.onreadystatechange=displayDetailOutPut;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	return false;
}

function displayDetailOutPut(){
	if (xmlhttp.readyState==4){
		if(xmlhttp.responseText!=""){
			var responseSubString=xmlhttp.responseText.substring(0,4);
			if("http"==responseSubString){
				window.location=xmlhttp.responseText;
			}else{
				alert(xmlhttp.responseText);
			}
			return false;
		}
	}
	return false;
	//document.getElementById("rateCountMessage").style.display="block";
	//document.getElementById("rateCountMessage").innerHTML=xmlHttp.responseText;
	//return false;
}

//admin add glossary

function chkaddGlossary(thisform)
{

	with(thisform)
	{
		if(trim(term.value) == "")
		{
			alert("Term Name field left blank");
			term.focus();
			return false;
		}

		var oEditor = FCKeditorAPI.GetInstance('definition');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			alert("Definition field left blank");
			definition.focus();
			return false;
		}

		if(trim(keywords.value) == "")
		{
			alert("Keywords field left blank");
			keywords.focus();
			return false;
		}

		/*if(trim(video.value) == "")
		{
			alert("video field left blank");
			video.focus();
			return false;
		}*/

	}
	return true;
}


function chkeditGlossary(thisform)
{

	with(thisform)
	{
		if(trim(term.value) == "")
		{
			alert("Term Name field left blank");
			term.focus();
			return false;
		}

		var oEditor = FCKeditorAPI.GetInstance('definition');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			alert("Definition field left blank");
			definition.focus();
			return false;
		}

		if(trim(keywords.value) == "")
		{
			alert("Keywords field left blank");
			keywords.focus();
			return false;
		}

		/*if(trim(video.value) == "")
		{
			alert("video field left blank");
			video.focus();
			return false;
		}*/

	}
	return true;
}

//admin add competition
function chkaddCompetition(thisForm){
	with(thisForm)	{
		if(trim(heading.value) == ""){
			alert("Heading left blank");
			heading.focus();
			return false;
		}
		if(!isValidImage(trim(comImg.value))){
			alert("Invalid Image");
			return false;
		}

		var oEditor = FCKeditorAPI.GetInstance('details');
		var htmlValue=oEditor.GetXHTML(true);
		
		if(htmlValue==""){
			alert("Details field left blank");
			details.focus();
			return false;
		}

	}
}


function chkCompetition_Registration(thisForm)
{
	with(thisForm)
	{
		if(trim(name.value) == "")
		{
			alert("Name field left blank");
			name.focus();
			return false;
		}
		if(trim(address.value) == "")
		{
			alert("Address field left blank");
			address.focus();
			return false;
		}

		if(!IsNumeric(trim(phone_number.value))) {
			alert("Phone field Invalid");
			phone_number.focus();
			return false;
		}

		if(trim(email.value) == "")
		{
			alert("Email field left blank");
			email.focus();
			return false;
		}

		if(TandC.checked == false)
		{
			alert("You have to Read the Terms & Condition");
			TandC.focus();
			return false;
		}

		if(trim(answer.value) == "")
		{
			alert("Answer field left blank");
			email.focus();
			return false;
		}
	}
}


var xml_http;
function getAuthorCheck(authorName){
	//alert(authorName);
	try{
		// Firefox, Opera 8.0+, Safari
		xml_http=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xml_http=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			xml_http=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	var url="http://www.wellbeing.com.au/admin/checkAuthor.php";
	url=url+"?author="+authorName;
	xml_http.onreadystatechange=setAuthorOutput;
	xml_http.open("GET",url,true);
	xml_http.send(null);
	//return false;
}

function setAuthorOutput(){
	
	if (xml_http.readyState==4){
		if(xml_http.responseText!=""){
			document.getElementById("authorDiv").style.display="block";
			document.getElementById("AuthorName").value='';
			//document.getElementById("authorDiv").innerHTML=xml_http.responseText;
		}else{
			document.getElementById("authorDiv").style.display="none";
		}
	}
	//return false;
	//document.getElementById("rateCountMessage").style.display="block";
	//document.getElementById("rateCountMessage").innerHTML=xmlHttp.responseText;
	//return false;
}
