// JavaScript Document
function changeBG(thisObj,color){
//	alert(thisObj);
	if(color == '')thisObj.style.backgroundColor = '';
	else thisObj.style.backgroundColor = "#"+color;
}
function getURL(thisParent){
//	alert(thisParent.lastChild.href);
	document.location = thisParent.lastChild.href;
}
function validations()
{
	if(document.xx.title.value=="")
	{
		alert("Please Enter Title Name");
		document.xx.title.focus();
		return false;
	}
	else if(document.xx.s_title.value=="")
	{
		alert("Please Enter Sub Title");
		document.xx.s_title.focus();
		return false;
	}
	else if(document.xx.cont.value=="")
	{
		alert("Please Enter Content");
		document.xx.cont.focus();
		return false;
	}
	else if(document.xx.dt.value=="")
	{
		alert("Please Enter Date");
		document.xx.dt.focus();
		return false;
	}
	
	return true;
}
function doSubmit(){
	validations();
	return 	editor1.prepareSubmit();
}

function doSearch(){
	searchText = document.getElementById('search_text').value;
	
	if((searchText != 'Search')&&(searchText != '')){
		window.location = "index.php?search="+searchText;
	}else return;	
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.email_form.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	document.email_form.action = "add_subscriber.php";
	document.email_form.submit();
 }

function sendall()
{
if(document.ff.newsletter.value=="")
 {
    alert("Please Select Newsletter");
	document.ff.newsletter.focus();
	return false;
}
else
  {
    document.ff.action="mail_news.php?id=all&lnk=nwsl&val="+document.ff.newsletter.value;
	document.ff.submit();
   }	
}
function retrieve()
{
 /* for(i=0;i<ff.elements.length;i++)
  {
   //alert(ff.elements[i].name);
   el=ff.elements[i];
   
    if(el.type=='checkbox')
	
	{
	      var group = ff[el.name];
	      //if (group.length)
		 // {
	        var checked = false;
	       // for (var r = 0;r < group.length; r++)
	          
			  if ((checked = group[i].checked))
			  {
			   alert(el.value);
			    break;		
			 }							
	        if(!checked)
			 {
	          alert('Please Check One Of The Checkboxes');
	          el.focus();
	          return false;
	        }
		
	      }
		  }
		  }
 for(i=0;i<ff.elements.length;i++)
  {
    nm=ff.elements[i];
	
	if(nm.type='checkbox')
	{
	  //alert("hi");
	  if(nm.name.checked==true)	  
	   alert(ff.elements[i].value);
	  else
	   alert("hi"); 
	}  
}*/
if(document.ff.newsletter.value=="")
 {
    alert("Please Select Newsletter");
	document.ff.newsletter.focus();
	return false;
}
else
{
document.ff.action="mailing_list.php?lnk=nwsl&id=selected";
document.ff.submit();
} 
 }
 function subval()
{
 if(document.ff.newsletter.value=="")
 {
    alert("Please Select Newsletter");
	document.ff.newsletter.focus();
	return false;
}
else
  {
    document.ff.action="mailing_list.php?id="+document.ff.newsletter.value;
	document.ff.submit();
   }		
}

function popupPage(page,windowstyle,width,height) {
	if(width == null)width = 600;
	if(height == null)height = 700;
	
	if (windowstyle == 0) {
		windowprops = "height="+height+",width="+width+",toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,left=0,top=0";
	} else {
		windowprops = "height="+height+",width="+width+",toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,left=0,top=0";
	}
	window.open(page, "Popup", windowprops);
}