//--------------------  COMMON FUNCTION FOR WHOLE SITE ----------------------------------



	function checkmultibody(form,msg,Body,NewEditor)



	{



		if (NewEditor.GetHTML() == "")



		{



			alert("Please make sure "+msg+" field was properly completed.")



			return false;



		}



		if (NewEditor.GetHTML() == "<P>&nbsp;</P>")



		{



			alert("Please make sure "+msg+" field was properly completed.")



			return false;



		}



		Body.value = NewEditor.GetHTML();



	}	







//----------------------------------------------------------------------



	function setChecked(form,msgval)



	{



		



		len = form.elements.length;



		var i=0;



		var s = 0;



			for( i=0 ; i<len ; i++)



				if (form.elements[i].type=='checkbox')



					if (form.elements[i].checked==true)



						s = s + 1;



		if (s==0)



		{



				alert ('Please choose atleast one ' + msgval + '.');



				return false;



		}



		return true



	}







	function chkAll(form)



	{



		len = form.elements.length;



		var i=0;



		for( i=0 ; i<len ; i++)



		{



			if (form.elements[i].type=='checkbox')



			{



				if (form.elements[i].checked)



				{



					//form.elements[i].checked=false;



					//form.selectall.value='Select All'



				}else



				{



					form.elements[i].checked=true;



					//form.selectall.value='DeSelect All'



				}



			}



		}



	}



	



	function DeleteCheck(msgval,msgdata) 



	{



		var Verify=confirm("Are you sure you want to delete " + msgval + " " + msgdata + " and all related records?");



		if (Verify == true)



			return true;			



		else



			return false;			



	}



function verifyMail(obj)



{



	if(obj.value.length != 0)



    {



      var str = obj.value;



      var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid



      var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; // valid



	  if (!reg1.test(str) && reg2.test(str))



      {



		 // return true;



      }else



	  {



		 alert("\"" + str + "\" is an invalid e-mail!");



       	 obj.focus();



         return false;



	   }



	}



}







//----------- End ---------------



	function onkey()



	{



		var keyascii;



		keyascii = window.event.keyCode;



		if ((keyascii < 48) || (keyascii > 57))



		{



			window.event.keyCode = 0;



		}



		return;



	}



//-------------------------------



	function selOption(formElement,selValue)



	{



		for (var optionCounter = 0; optionCounter < formElement.length;optionCounter++)



			  if(formElement.options[optionCounter].value == selValue)



				  formElement.options[optionCounter].selected = true



	}







function checkrequired(which) 



{ 



	var pass=true; 



	if (document.images) 



	{ 



		for (i=0;i<which.length;i++) 



		{ 



			var tempobj=which.elements[i]; 



			if (tempobj.name.substring(0,8)=="required") 



			{ 



				if (( tempobj.type=="file" || tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password" ||tempobj.type.toString().charAt(0)=="s") && tempobj.value=='')



				{ 



					pass=false; 



					break; 



				} 



			} 



		} 



	} 



	if (!pass) 



	{ 



		shortFieldName=tempobj.name.substring(8,30).toUpperCase(); 



		alert("Please make sure the "+shortFieldName+" field was properly completed."); 



		tempobj.focus() ;						



		return false; 



				



	} else 



	



	return true; 



			



} 





//--------------------------------------------------------------

function checkrequiredRadio(tempobj) 

{ 



	var pass=true; 

	if (tempobj.type!="radio")

	{

		for (i=0;i<tempobj.length;i++) 

		{ 

			if (tempobj[i].checked==true)

			{ 

				pass=true; 

				break; 

			}else

			   pass=false;

		} 

		if (!pass) 

		{ 

			shortFieldName=tempobj[0].name.substring(8,30).toUpperCase(); 

			alert("Please make sure the "+shortFieldName+" field was properly completed."); 

			return false; 

					

		}else 

			return true; 

	}else

		if (tempobj.checked==false)

		{

			shortFieldName=tempobj.name.substring(8,30).toUpperCase(); 

			alert("Please make sure the "+shortFieldName+" field was properly completed."); 

			return false; 

		}else

			return true ;

} 

//-------------------------------------------------------



function chkDelNo(form,totval,delval)



{



	if (delval == 0)



	{



		



	}



	alert(form.name)



	return false;



}



//----------------------   Site Function   -----------------------



	function MemberValidation(which)



	{



		if (verifyMail(which.requiredEmail)==false) return false ;



		if (checkrequired(which) == false) return false;



		return true ;



	}	



	function selVal(formelement,val)



	{



		var optionCounter;



		for (optionCounter = 0; optionCounter < formelement.length;optionCounter++)



		{



		  if(formelement.options[optionCounter].value == val)



			  formelement.options[optionCounter].selected = true



		}



	}



	function onkeyprice(obj)



	{



		var keyascii;



		keyascii = window.event.keyCode;



	



		var str=obj.value



		if(keyascii==46)



		{ 



			if (str.indexOf(".")>0){



				return false



			}



		}



		else 



		{



			if ((keyascii < 48) || (keyascii > 57))



			{



				window.event.keyCode = 0;



			}



			return;



		}



	}



	function usernameValidation(which)



	{



		if (checkrequired(which) == false) return false;



		if (which.requiredpassword.value!=which.confirmpassword.value)



		{



				alert("Password mismatch.") ;



				which.confirmpassword.focus() ;



				return false ;



		}



		return true ;



	}



	function replaceDoubleToSingle(strLoadText)



	{



		var strText ;



		out = '"'; // replace this



		add = "'"; // with this



		strText = "" + strLoadText; // temporary holder



		while (strText.indexOf(out)>-1)



		{



			pos= strText.indexOf(out);



			strText = "" + (strText.substring(0, pos) + add + 



			strText.substring((pos + out.length), strText.length));



		}







		return strText ;



	}



  function Imageval(obj)



  {



		



	  if(obj.value!="")



	  {







		var data=obj.value;



		if (data.indexOf('%') > -1)



		{



				alert("Filename contains invalid character '%'");



				obj.focus();



				return false;



		}



		var len=data.lastIndexOf('.');



		data=data.substring(len+1);



		marray=["gif","jpg","jpe","jpeg"];



		flag=0;



		for(i=0;i<4;i++)



		  {



				data = data.toLowerCase()



				if(marray[i]==data)



				   flag=1;



		  }



		if(flag==0)



		  {



				alert("Please upload valid photo (gif - jpg - jpe - jpeg)");



				obj.focus();



				return false;



		  }



	  }



  }







	function Checkcountactus(which)



	{



		if (checkrequired(which) == false) return false;



		return true ;



	}	



	



  function PDFval(obj)



  {



		



	  if(obj.value!="")



	  {







		var data=obj.value;



		if (data.indexOf('%') > -1)



		{



				alert("Filename contains invalid character '%'");



				obj.focus();



				return false;



		}



		var len=data.lastIndexOf('.');



		data=data.substring(len+1);



		marray=["pdf"];



		flag=0;



		for(i=0;i<1;i++)



		  {



				if(marray[i]==data)



				   flag=1;



		  }



		if(flag==0)



		  {



				alert("Please upload valid photo (pdf)");



				obj.focus();



				return false;



		  }



	  }



  }



//  Popup Window ------------------------------------



	function winOpen(str,Name,Resize,Width,Height,Left,Top)



	{



		window.open(str,Name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable='+Resize+',width='+Width+',height='+Height+',left='+Left+',top='+Top)



	}



//----------------------------------------------------------------------



	function EditorOnSetClass(id)



	{



		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().text == "")



		{



			alert("Please select text") ;



			return false;



		}



		



		if (!EditorValidateMode(id))



		{



			return;



		}







			var newclass = showModalDialog("ClassSelect.php", "", "font-family:Verdana;font-size:12;dialogWidth:13em;dialogHeight:20em;status:0;resizable:1;");







		if (newclass && newclass != "")



		 {



			var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();



			//var rangeText = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();



			if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Text")



			{



				var strText = range.text	



			}	







			if(range.parentElement().outerHTML.indexOf("<SPAN")==0)



			{



				if (strText == range.parentElement().innerText)



					range.parentElement().outerHTML = ""



			}



			if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "Text")



			{



				range.pasteHTML('<span ' + newclass + '>' + strText + '</span>');



				range.select();



			}



			else



			{



				range.pasteHTML('<span ' + newclass + '>' + strText + '</span>');



				range.select();



			}



			



		}



	}



//-------------------------------------------------



//----------------------------------------------------------------------



	function replaceDoubleToSingle(strLoadText)



	{



		var strText ;



		out = '~"~'; // replace this



		add = "'"; // with this



		strText = "" + strLoadText; // temporary holder



		while (strText.indexOf(out)>-1)



		{



			pos= strText.indexOf(out);



			strText = "" + (strText.substring(0, pos) + add + 



			strText.substring((pos + out.length), strText.length));



		}







		return strText ;



	}







  //----------------------------------------------------------------------



  function ImageZipval(obj)



  {



		



	  if(obj.value!="")



	  {







		var data=obj.value;



		if (data.indexOf('%') > -1)



		{



				alert("Filename contains invalid character '%'");



				obj.focus();



				return false;



		}



		var len=data.lastIndexOf('.');



		data=data.substring(len+1);



		marray=["gif","jpg","jpe","jpeg","zip"];



		flag=0;



		for(i=0;i<5;i++)



		  {



				if(marray[i]==data)



				   flag=1;



		  }



		if(flag==0)



		  {



				alert("Please upload valid file (gif - jpg - jpe - jpeg - zip)");



				obj.focus();



				return false;



		  }



	  }



  }



  //----------------------------------------------------------------------



	function checkUploadFile(frm)



	{



		if (checkrequired(frm) == false) return false;



		



		if (ImageZipval(frm.requiredFile)== false) return false;



		



		frm.submit() ;



		return true ;



	}



//----------------------------------------------------------------------



	function ImageDeleteCheck(msgval,msgdata) 



	{



		var Verify=confirm("Are you sure you want to delete " + msgval + " " + msgdata);



		if (Verify == true)



			return true;			



		else



			return false;			



	}



//-------------------------------------------------







function Arraycheckrequired(which) 



{ 







	var pass=true; 



	if (document.images) 



	{ 



		for (i=0;i<which.length;i++) 



		{ 



			var tempobj=which.elements[i]; 



			if (tempobj.name.substring(0,8)=="required") 



			{ 







				if ((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="password" ||tempobj.type.toString().charAt(0)=="s")&&			tempobj.value=='')



				{ 



					if(tempobj.disabled==false)



					{



						pass=false; 



						break; 



					}



				} 



			} 



		} 



	} 



	if (!pass) 



	{ 



		shortFieldName=tempobj.name.substring(8,30).toUpperCase(); 



		idStartPos=tempobj.name.indexOf("-") ;



		shortFieldName=tempobj.name.substring(8,idStartPos).toUpperCase(); 



		



		alert("Please make sure the "+shortFieldName+" field was properly completed."); 



		tempobj.focus() ;						



		return false; 



				



	} else 



	



	return true; 



			



} 	



	function replaceCharToQuote(strLoadText)



	{



		var strText ;



		out = '~~'; // replace this



		add = "'"; // with this



		strText = "" + strLoadText; // temporary holder



		while (strText.indexOf(out)>-1)



		{



			pos= strText.indexOf(out);



			strText = "" + (strText.substring(0, pos) + add + 



			strText.substring((pos + out.length), strText.length));



		}







		out = '_~'; // replace this



		add = '"'; // with this



		strText = "" + strLoadText; // temporary holder



		while (strText.indexOf(out)>-1)



		{



			pos= strText.indexOf(out);



			strText = "" + (strText.substring(0, pos) + add + 



			strText.substring((pos + out.length), strText.length));



		}







		return strText ;



	}

//----------------------------------------------------------------------



	function checkGuest(frm)

	{

		if (verifyMail(frm.requiredEmail)== false) return false;

		if (checkrequired(frm) == false) return false;

		if (checkrequiredRadio(frm.requiredArticlePreference) == false) return false;

		

		frm.submit() ;

		return true ;

	}

//----------------------------------------------------------------------

	function checkGuestLogin(frm)

	{

		if (verifyMail(frm.requiredEmail)== false) return false;

		if (checkrequired(frm) == false) return false;

		return true ;

	}

//----------------------------------------------------------------------

	function checkAdv(frm)

	{

		if (verifyMail(frm.requiredEmail)== false) return false;

		if (checkrequired(frm) == false) return false;

		if (checkrequiredRadio(frm.requiredBestwaytocontact) == false) return false;

		

		frm.submit() ;

		return true ;

	}

//----------------------------------------------------------------------

