function isnullspace4login(doc)
{
    var len = doc.length;
    if(len>0){
    var err=0;
    for(i=0; i<len; i++) {
    var nch=doc.charAt(i);
     if(nch=="" || nch==" "){err=1;}
    }
    if(err==1)
        return false;
    else
        return true;
    } else {
       isnullspace(doc)
    }    
}
function showCalendar()
    {
      
      showCalendarControlOld(document.report.fromDate);
     }
     
function changefrom(){
    var dateVal = document.demoform.tempName.value;
    var dateArr = dateval.split("/");
    alert(dateArr[2]+"-"+dateArr[0]+"-"+dateArr[1]);
    document.demoform.dc.value = dateArr[2]+"-"+dateArr[1]+"-"+dateArr[0];
}     
     
function isnullspace(doc)
{
	if(doc==""){return false;}
	return true;
}
function isalphabet(fdoc) 
{ 
	var len=fdoc.length;
	var i;
	for(i=0; i<len; i++)
	{
		var ch=fdoc.charAt(i);
		if(!(((ch>='a') && (ch<='z'))|| ((ch>='A') && (ch<='Z')))){return false;}
	}
	return true;
}
function isnumber(ndoc) 
{ 
	var nlen=ndoc.length;
	var i;
	for(i=0; i<nlen; i++)
	{
		var nch=ndoc.charAt(i);
		if(!((nch>='0') && (nch<='9'))){return false;}
	}
	return true;
}
function issplcharacter(fdoc) 
{ 
	var len=fdoc.length;
	var i;
	for(i=0; i<len; i++)
	{
		var ch=fdoc.charAt(i);
		if(!(((ch>='a') && (ch<='z'))|| ((ch>='A') && (ch<='Z')) || ((ch>='0') && (ch<='9')))){return false;}
	}
	return true;
}
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){ return false;}
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     return false;}
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    return false;}
        if (str.indexOf(at,(lat+1))!=-1){ return false; }
        if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    return false ;}
        if (str.indexOf(dot,(lat+2))==-1){return false;}
    if (str.indexOf(" ")!=-1){return false;}
        return true;                    
}

function listquery1(status1){
    var state1=status1;
    var all = "popup.php?status="+state1;                                            
    myWin= open(all, "Affected_Records","height=300,width=500,toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no");

}

function selectMailLst(val){
   // alert(val);
    document.createcamp.id.value=val;
   // alert(document.createcamp.id.value);
    document.createcamp.submit(true);
}
function add(productid)
{
    alert(productid);
    var result = document.importform.upload_file.options[document.importform.upload_file.selectedIndex].text;
    document.importform["list1"].options[document.importform["list1"].length]= new Option(result);
    var x=document.importform.upload_file;
    x.remove(x.selectedIndex);
    return false;
}

function alertfun(){
    alert("No subscribers for this Mailing list.");
    return false;
}

function remove(pq)
{
    var accountfield=document.myForm.displaycmb.options[document.myForm.displaycmb.selectedIndex].text;
    var plength = accountfield.lastIndexOf("-->");
    var productname = accountfield.substring(0,plength);
    document.myForm["productcmb"].options[document.myForm["productcmb"].length]= new Option(productname);
    var x=document.myForm.displaycmb;
    x.remove(x.selectedIndex);
    return false;
}
  function createcmp() {
     var cmp = document.createcamp.campname.value;
    if(!isnullspace(cmp)){
        alert("Please enter Campaign name");
       document.createcamp.campname.focus();
       return false; 
    }
    return true; 
}
  
        function moove(fbox, tbox) {
             var fboxtext = new Array();
            var tboxtext = new Array();
            var i;

            for (i = 0; i < tbox.options.length; i++) {
                tboxtext[i] = tbox.options[i].text;
            }

            var fLength = 0;
            var tLength = tboxtext.length;

            for(i = 0; i < fbox.options.length; i++) {
                if (fbox.options[i].selected) {
                    if(fbox.options[i].text == "emailid"){
                        alert("Email is mandatory");
                        return false;
                    }

                    tboxtext[tLength] = fbox.options[i].text;
                    tLength++;
                }else {
                    fboxtext[fLength] = fbox.options[i].text;
                    fLength++;
                }
            }

            fbox.length = 0;
            tbox.length = 0;
            var c;

            for(c = 0; c < fboxtext.length; c++) {
                var no = new Option();
                no.text = fboxtext[c];
                no.value = fboxtext[c];
                fbox[c] = no;
            }

            for(c = 0; c < tboxtext.length; c++) {
                var no = new Option();
                no.text = tboxtext[c];
                tbox[c] = no;
                tbox[c].selected = true;
            }
        }

  function importcheck(){
    var ext;
   ext = document.importform.upload_file.value;
    ext = ext.split(".");
  
    if(ext[1]=="csv" || ext[1]=="CSV") {
            var aa= document.importform.import_fields;
        txt="";
       for (i=0; i<aa.length; i++)
        {
                
            if(document.importform.import_fields[i].selected)
            { 
                //alert("hello"+document.importform.import_fields.options[i].text);
                if(txt=="")
                {
                    txt = document.importform.import_fields.options[i].text;
                }
                else
                {
                    txt = txt+","+document.importform.import_fields.options[i].text+"";
                }
                
            }
        }
        //alert(txt);
        document.importform.act.value=txt ;
          return true;

    } else {
        alert("Please import csv file only");
        document.importform.upload_file.value="";
        document.importform.upload_file.focus();
        return false;
    }
}
   
function testFile1()
{   
   var ext;
       ext = document.importform.upload_file.value;
    ext = ext.split(".");
    var aa= document.forms[0].import_fields;
    var txt;
    txt="";
    for ( var i=0; i<aa.length; i++)
    {
        if(document.forms[0].import_fields[i].selected)
        { 
            if(txt=="")
            {
                txt = txt+""+document.forms[0].import_fields[i].value+"";
            }
            else
            {
                txt = txt+","+document.forms[0].import_fields[i].value+"";
            }
        }
    }
    
    document.forms[0].act.value=txt ;
    alert(txt);
    return true;
	
	
	 

}

function chckRptDate(){
    var err=1;
    if(document.report.fromDate.value==""){
        err=2;
    }
    if(document.report.toDate.value==""){
        err=2;
    }
    if(err==2){
        alert("Please select the date");
        return false;
    }
    else
        return true;
}

function Adminpage(pageNo){
    document.reportView.strt.value=pageNo;
    document.reportView.submit(true);
}
    
function checkEmail(){
   var val = document.insSubsciber.email.value;  

   if(!isnullspace(val)) {
        alert("EmailID cannot be null");
        document.insSubsciber.email.focus();
        return false;
   }
   if(!echeck(val)) {
        alert("Please enter a valid EmailID");
        document.insSubsciber.email.value="";
        document.insSubsciber.email.focus();
        return false;
   }
   var err='';
   var totaltype=document.insSubsciber.checktype.value;
   if(totaltype) {
   var totalfield = document.insSubsciber.fieldName.value;
   var fieldArray= totalfield.split(',');
   var typeArray= totaltype.split(',');
  for(i=0; i<typeArray.length; i++) {
        var fldType = typeArray[i].split('(');
       var fieldType = fldType[1].split(')');
        var fname = document.getElementById(fieldArray[i]).value;
          if(fldType[0]=="tinyint" || fldType[0]=="smallint" || fldType[0]=="mediumint" || fldType[0]=="int" || fldType[0]=="bigint" || fldType[0]=="float" || fldType[0]=="double" || fldType[0]=="decimal"){
           if(!isnumber(fname)){
              if(err)
                err=err+","+fieldArray[i];
              else
                err=fieldArray[i];     
           } 
        }          
        
  }
   if(err.length>1){
        alert("Please enter Only Numbers in "+err);
        return false;
   }
   } 
}

function updatevalidate(){
    var val = document.updateSubsciber.eval.value;
   for(i=0; i<val; i++){
      var ename = document.getElementById("emailid"+i).value;
      if(!echeck(ename)) {
        alert("Please enter a valid EmailID");
        document.getElementById("emailid"+i).value="";
        document.getElementById("emailid"+i).focus();
        return false;
   }
     
 }
 return true;
}

function display(){

	var username  = document.login.uname.value;
	var password  = document.login.pword.value;
	var compname  = document.login.companyname.value;	
   
    if(!companyEmpty(compname))
	{
		document.getElementById("displaycname").innerHTML="Enter Company name";
	}
	if(!userEmpty(username))
	{
		document.getElementById("displayuname").innerHTML="Enter the Username";
	}
	if(!passwordEmpty(password))
	{
		document.getElementById("displaypass").innerHTML="Enter the Password";
	}
    if((companyEmpty(compname))&&(userEmpty(username))&&(passwordEmpty(password)))
	{
        return true;
	}
	else
	{
		return false;
	}	

}
  function aa() {
    alert("I am here");
    return false;
  }
function dispall() {
    window.location.href="ShowSubscriber.php";
}

function passdisplay(){
	var oldpass  = document.forms[0].oldpass.value;
	var newpass  = document.forms[0].newpass.value;
	var rtypass  = document.forms[0].retypepass.value;	
	if(!companyEmpty(oldpass))
	{
		document.getElementById("displaycname").innerHTML="Enter the Old Password";
	}
	if(!userEmpty(newpass))
	{
		document.getElementById("displayuname").innerHTML="Enter the New Password";
	}
	if(!passwordEmpty(rtypass))
	{
		document.getElementById("displaypass").innerHTML="Retype the New Password";
	}
	
	if((companyEmpty(oldpass))&&(userEmpty(newpass))&&(passwordEmpty(rtypass))&&(checkpass(newpass,rtypass)))
	{
		return true;
	}
	else
	{
		return false;
	}	

}
function admindisplay()
{
	var username  = document.login.uname.value;
	var password  = document.login.pword.value;
	if(!userEmpty(username))
	{
		document.getElementById("displayuname").innerHTML="Enter the Username";
	}
	if(!passwordEmpty(password))
	{
		document.getElementById("displaypass").innerHTML="Enter the Password";
	}
	if((userEmpty(username))&&(passwordEmpty(password)))
	{
		return true;
	}
	else
	{
		return false;
	}	
}

function submitsub() {
    var txt='';
    var order='';
    var val = document.subscriber.fields;
    for(i=0; i<val.length; i++) {
        if(document.subscriber.fields[i].selected) {
            if(txt)
                txt = txt+','+document.subscriber.fields[i].value;
            else
                txt = document.subscriber.fields[i].value;    
        }
       if(document.subscriber.order[i].selected) {
            if(order)
                order =order+','+document.subscriber.order[i].value;
            else
                order = document.subscriber.order[i].value;    
        }
  }
    document.subscriber.fDisplay.value=txt;
    document.subscriber.orderBy.value=order;
    return true;    
}

    function val(j)
    {
     if(j==1)
     {
         if(document.subscriber.form_op_val1.value=="LIKE" || document.subscriber.form_op_val1.value=="NOT LIKE")
             document.subscriber.form_text_val1.value=document.subscriber.form_text_val1.value + "%";
         else
             document.subscriber.form_text_val1.value="";
     }    
     if(j==2)
     {
          if(document.subscriber.form_op_val2.value=="LIKE" || document.subscriber.form_op_val2.value=="NOT LIKE")
             document.subscriber.form_text_val2.value=document.subscriber.form_text_val2.value + "%";
         else
             document.subscriber.form_text_val2.value="";
     }
     if(j==3)
     {
          if(document.subscriber.form_op_val3.value=="LIKE" || document.subscriber.form_op_val3.value=="NOT LIKE")
             document.subscriber.form_text_val3.value=document.subscriber.form_text_val3.value + "%";
         else
             document.subscriber.form_text_val3.value="";       
     }
     if(j==4)
     {
          if(document.subscriber.form_op_val4.value=="LIKE" || document.subscriber.form_op_val4.value=="NOT LIKE")
             document.subscriber.form_text_val4.value=document.subscriber.form_text_val4.value + "%";
         else
             document.subscriber.form_text_val4.value="";     
     }       
    
    }

function Updateval(j)
{
     if(j==1)
     {
         if(document.updateSubsciber.update_op_val1.value=="LIKE" || document.updateSubsciber.update_op_val1.value=="NOT LIKE")
             document.updateSubsciber.update_text_val1.value=document.updateSubsciber.update_text_val1.value + "%";
         else
             document.updateSubsciber.update_text_val1.value="";
     }    
     if(j==2)
     {
          if(document.updateSubsciber.update_op_val2.value=="LIKE" || document.updateSubsciber.update_op_val2.value=="NOT LIKE")
             document.updateSubsciber.update_text_val2.value=document.updateSubsciber.update_text_val2.value + "%";
         else
             document.updateSubsciber.update_text_val2.value="";
     }
     if(j==3)
     {
          if(document.updateSubsciber.update_op_val3.value=="LIKE" || document.updateSubsciber.update_op_val3.value=="NOT LIKE")
             document.updateSubsciber.update_text_val3.value=document.updateSubsciber.update_text_val3.value + "%";
         else
             document.updateSubsciber.update_text_val3.value="";       
     }
     if(j==4)
     {
          if(document.updateSubsciber.update_op_val4.value=="LIKE" || document.updateSubsciber.update_op_val4.value=="NOT LIKE")
             document.updateSubsciber.update_text_val4.value=document.updateSubsciber.update_text_val4.value + "%";
         else
             document.updateSubsciber.update_text_val4.value="";     
     }       
    
    }
    
 function checkValue() {
     if((document.updateSubsciber.textvalue1.value=="") && (document.updateSubsciber.textvalue2.value=="") && (document.updateSubsciber.textvalue3.value=="")) {
        alert("Please enter value to update");
        return false;
    }
    else
        return true;
  return false;
 }   

  function getbrowzer(){
    var xmlHttpReq = false;
    var self = this;
    //var xmlHttp;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
            self.xmlHttpReq = new XMLHttpRequest();
            return self.xmlHttpReq;
    }
    // IE
    else if (window.ActiveXObject) {
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            return self.xmlHttpReq;
    }

}

function checkdate() {
var radioval =  document.repo.act;
var err="1";
for(i=0; i<radioval.length; i++) {
    if(radioval[i].checked) {
        if(radioval[i].value=="sentdate") {
            if(document.repo.Datevalue2.value=="" || document.repo.Datevalue3.value==""){
                alert("Please select a date from calender");
                err="2";

            }
        } 
        if(radioval[i].value=="opendate") {
            if(document.repo.Datevalue4.value=="" || document.repo.Datevalue5.value==""){
                alert("Please select a date from calender");
               err="2";

            }
        } 
    }    
}

if(err=="1")
    return true;
else
    return false;    
}
  function getdetails(value)
{
   
    var from1 = document.frmpost.from1.value;
    var from2 = document.frmpost.from2.value;
    var result=from1+"@"+from2;
    document.frmpost.replyto.value=result;
    var url="BounceTrack.php";
    url=url+"?sname="+value;

    var yestext = "Bounce mail can be tracked";
    var notext = "Bounce mail cannot be tracked";
    self.xmlHttpReq = getbrowzer();
    self.xmlHttpReq.onreadystatechange = function()
    {
        if(self.xmlHttpReq.readyState==4)
        {

            if(self.xmlHttpReq.responseText==1){
                document.getElementById("bounce").innerHTML=yestext;
            }
            else if(self.xmlHttpReq.responseText==0){
                document.getElementById("bounce").innerHTML=notext;
            }
            else{
            document.getElementById("bounce").innerHTML="";
            }
        }
    }
        self.xmlHttpReq.open("GET",url,true);
        self.xmlHttpReq.send(null);
        return true;
    checkmailbox();

}

function checkmailbox()
{
    var from1 = document.frmpost.from1.value;
    var from2 = document.frmpost.from2.value;
    var result=from1+"@"+from2;
    document.frmpost.replyto.value=result;
    var url="shell.php";
    url=url+"?mbname="+result;
    
//alert("url")
    //var yestext = "Bounce mail can be tracked";
    //var notext = "Bounce mail cannot be tracked";
    self.xmlHttpReq = getbrowzer();
    self.xmlHttpReq.onreadystatechange = function()
    {
        if(self.xmlHttpReq.readyState==4)
        {
        	//alert(self.xmlHttpReq.responseText);

            if(self.xmlHttpReq.responseText==1){
                //document.getElementById("bounce").innerHTML=yestext;
                //alert("Done");
            }
            else if(self.xmlHttpReq.responseText==0){
                //document.getElementById("bounce").innerHTML=notext;
                alert("Mailbox "+result+" Already Exist")
            }
            
        }
    }
        self.xmlHttpReq.open("GET",url,true);
        self.xmlHttpReq.send(null);
        return true;
        
}
 
function advdisplay(){

	var advname  = document.content.advname.value;
	var username  = document.content.uname.value;
        var password  = document.content.pword.value;
        var numuser  = document.content.numuser.value;        
        
        var len = numuser.length;
        
	document.content.advname.focus();
	if(!companyEmpty(advname))
	{
		document.getElementById("displaycname").innerHTML="Enter Advertiser Name";
		document.content.advname.focus();
	}
	if(!userEmpty(username))
	{
		document.getElementById("displayuname").innerHTML="Enter the Username";
		document.content.uname.focus();
	}
	if(!passwordEmpty(password))
	{
		document.getElementById("displaypass").innerHTML="Enter the Password";
		document.content.pword.focus();
	}
	
	if(!numuserEmpty(numuser))
	{
	      alert("gg");
		document.getElementById("displaynumuser").innerHTML="Enter the Number of Users";
		document.content.numuser.focus();
	}
	
	 if (len >0)   
          {
		
	if(!checknumuser(numuser))
	{
			document.getElementById("displaynumuser").innerHTML="Enter the Numbers Only";
			document.content.numuser.focus();
	}
          }  	
	
	if((companyEmpty(advname))&&(userEmpty(username)) && (passwordEmpty(password))&&(numuserEmpty(numuser)))
	{
		return true;
	}
	else
	{
		document.content.advname.focus(); 
        return false;
	}	

}
function companydisplay(){
//alert("hai");
 
	var compname  = document.content.compname.value;
	var username  = document.content.uname.value;
	var password  = document.content.pword.value;
	var numuser  = document.content.numuser.value;
	document.content.compname.focus();
   // alert(compname+username+password+numuser) 
   	if(!companyEmpty(compname))
	{
		document.getElementById("displaycname").innerHTML="Enter Company Name";
		document.content.compname.focus();
	}
	if(!userEmpty(username))
	{
		document.getElementById("displayuname").innerHTML="Enter the Username";
		document.content.uname.focus();
	}
	if(!passwordEmpty(password))
	{
		document.getElementById("displaypass").innerHTML="Enter the Password";
		document.content.pword.focus();
	}
	if(!numuserEmpty(numuser))
	{
		document.getElementById("displaynumuser").innerHTML="Enter the Number of Users";
		document.content.numuser.focus();
	}
	if((companyEmpty(compname))&&(userEmpty(username)) && (passwordEmpty(password))&&(numuserEmpty(numuser))&&(checknumuser(numuser)))
	{
		return true;
	}
	else
	{
		document.content.compname.focus(); 
        return false;
	}	
   
}
function clientdisplay(){
        var clientname  = document.content.clientname.value;
	var username  = document.content.username.value;
	var password  = document.content.password.value;
	var numuser  = document.content.numuser.value;
	document.content.clientname.focus();
	
	if(!companyEmpty(clientname))
	{
		document.getElementById("displaycname").innerHTML="Enter Client Name";
		document.content.clientname.focus();
	}
	if(!userEmpty(username))
	{
		document.getElementById("displayuname").innerHTML="Enter the Username";
		document.content.username.focus();
	}
	if(!passwordEmpty(password))
	{
		document.getElementById("displaypass").innerHTML="Enter the Password";
		document.content.password.focus();
	}
	if(!numuserEmpty(numuser))
	{
		document.getElementById("displaynumuser").innerHTML="Enter the Number of Users";
		document.content.numuser.focus();
	}
	if((companyEmpty(clientname))&&(userEmpty(username)) && (passwordEmpty(password))&&(numuserEmpty(numuser))&&(checknumuser(numuser)))
	{
		return true;
	}
	else
	{
		return false;
	}		
}



function clientdisp()
{

  alert("testtt");  
}

function companyEmpty(value){
	if(!isnullspace4login(value))
	{
         return false;
	}
	else 
	{
        document.getElementById("displaycname").innerHTML="";
		return true;
	}
}
function userEmpty(value){
	if(!isnullspace4login(value))
	{
		return false;
	}
	else 
	{
		document.getElementById("displayuname").innerHTML="";
		return true;
	}
}
function passwordEmpty(value){
	if(!isnullspace4login(value))
	{
		return false;
	}
	else 
	{
		document.getElementById("displaypass").innerHTML="";
		return true;
	}
}

function numuserEmpty(value){
	if(!isnullspace(value))
	{
		return false;
	}
	else 
	{
		document.getElementById("displaynumuser").innerHTML="";
		return true;
	}
}
function checknumuser(value){
	if (!isnumber(value))
	{
	    document.getElementById("displaynumuser").innerHTML=" Enter only Numbers";
	    document.forms[0].numuser.value="";
	    document.forms[0].numuser.focus();
	    return false;
	}
  	else
  	{
  		document.getElementById("displaynumuser").innerHTML="";
  		return true;
  	}
}

function checkpass(value1,value2){
	
	if (value1 != value2)
	{
	    document.getElementById("displaypass").innerHTML="Password Doesn't match, Retype";
	    document.forms[0].retypepass.value="";
	    document.forms[0].retypepass.focus();
	    return false;
	}
  	else
  	{
  		document.getElementById("displaypass").innerHTML="";
  		return true;
  	}

}
function showdiv(value)    
    {
    	 
	 document.getElementById(value).style.display = 'block';	 	 
    }
function opentemplat()
{
window.open("Template.php");
}
function myopen() 
{
    popupWindow=open('addbook.jsp','windowName','resizable=no,scrollbars=yes,width=900,height=900');
    if (popupWindow.opener == null) popupWindow.opener = self;
}
function opentemplate() 
{
    my=window.open("Template_San.php","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600");
    my.opener;
}
function checkmailcontent() 
{
    my=window.open("CheckMailcontent.php","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=600, height=400");
    my.opener;
}
function editorpopup() 
{
//Template.php
    var a=confirm("The Html Content will be lost");
    if(a==true)
    {
        my=window.open("./editor/index.php","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")
        my.opener
    }
    else
    return false;
}

function write(a)
{
//var hvalue = document.getElementById("htmlmessage").value;
    document.location.href="HtmlWrite.php?htmlvalue="+a;
//return;
}
function pagepreview(hvalue) 
{
    //alert("Page Preview BOSS");
    my=window.open("HtmlPreview.php","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600");
    my.opener;
}
function spamcheck()
{
    // alert("hai") ;
//my=window.open("http://10.0.0.2:90/cgi-bin/CatapultV7/v5/spamcheck.cgi","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")

    my=window.open("../../cgi-bin/CatapultV8/v5/SpamCheckV10.cgi", "Spam_Check","height=400,width=400,toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no");
    my.opener;
}
function unsub()
{
    
//my=window.open("http://10.0.0.2:90/cgi-bin/CatapultV7/v5/spamcheck.cgi","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")

 my=window.open("Unsubscribe.php", "Unsubscribe","toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no , width=800, height=350");
 my.opener;
}

function htmleditor()
{
//my=window.open("http://10.0.0.2:90/cgi-bin/CatapultV7/v5/spamcheck.cgi","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")
    var a=confirm("The Values will get lost");
    if(a==true)
    {
        my=window.open("test.php", "HTML Editor","toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no , width=800, height=350");
        my.opener;
    }
    else
    return false;
}

function testcampaign()
{
	document.entry1.action ="http://massmailsoftware.in/cgi-bin/CatapultV8/v5/CmLaunchTestMail.cgi";
	document.entry1.target="targetName";
	document.entry1.submit();
}
function complete()
{
	alert("hai");
	document.entry1.action ="http://massmailsoftware.in/cgi-bin/CatapultV8/v5/CmLaunchMail_test.cgi";
	document.entry1.target="_self";
	document.entry1.submit();
}
function compcampaign()
{
	//alert("campaign");
	var camp = document.entry1.camptype.value
	//alert(camp)
	var date = document.entry1.date.value
	//alert(date)
	var month = document.entry1.month.value;
	var month = month - 1;
	//alert(month)
	var year = document.entry1.year.value
	//alert(year)
	var hour = document.entry1.hour.value
	var min = document.entry1.min.value
	var sec = document.entry1.sec.value
	
	var ipval = document.entry1.ownip.value;
	var abb = document.entry1.ipvalue.value;
	/*if( abb==2)
	{
		IPvalue = document.entry1.ownip.value;
		document.entry1.ownip.focus(); 
		alert(IPvalue)
		if(IPvalue =="")
		{
			alert("IPaddress should not be empty");
		}
		else
		{
			errorString = "";
			theName = "IPaddress";

			var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
			var ipArray = IPvalue.match(ipPattern);

			if (IPvalue == "0.0.0.0")
			errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
			else if (IPvalue == "255.255.255.255")
			errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
			if (ipArray == null)
			errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
			else 
			{
				for (i = 0; i < 4; i++) 
				{
					thisSegment = ipArray[i];
					if (thisSegment > 255) 
					{
						errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
						i = 4;
					}
					if ((i == 0) && (thisSegment > 255)) 
					{
						errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
						i = 4;
					}
				}
			}
		}
		extensionLength = 3;
		if (errorString == "")
		{
		//alert ("That is a valid IP address.");
		return true;
		}
		else
		{
			alert (errorString);
			document.entry1.ownip.value = "";
			document.entry1.ownip.focus();
			return false;
		}
	}
	else
	{
		alert("IPaddress should not be empty");
		document.entry1.ownip.focus();
		return false;
	}
	*/
	var myDate = new Date;
	myDate.setDate(date);
	myDate.setMonth(month); // January = 0
	myDate.setFullYear(year); 
	var today = new Date;
	
	var sysTime = new Date;
	sysTime.getHours();
	sysTime.getMinutes(); // January = 0
	sysTime.getSeconds(); 
	//alert(sysTime)
	var myTime = new Date;
	myTime.setHours(hour);
	myTime.setMinutes(min); // January = 0
	myTime.setSeconds(sec); 
	//alert(myTime)
	radioval = document.entry1.camptype;
	//alert(radioval.length)
	
	if(radioval[1].checked)
	{
		//alert(myDate);
		//alert(today);
		if (myDate >= today)
		{
			//alert('correct');
			if(myTime > sysTime || myDate > today)
			{
				var usrTime = new Date;
				usrTime.setDate(date);
				usrTime.setMonth(month); // January = 0
				usrTime.setFullYear(year); 
				usrTime.setHours(hour);
				usrTime.setMinutes(min); // January = 0
				var getHour = usrTime.getHours();
				var getMin  = usrTime.getMinutes(); 
				
				//alert(usrTime);
				getHour = getHour - 12;
				getMin  = getMin - 40;

				usrTime.setHours(getHour);
				usrTime.setMinutes(getMin); // January = 0

				getDay  = usrTime.getDay()
				getDate = usrTime.getDate()
				getMon  = usrTime.getMonth()
				getYear = usrTime.getFullYear()
				getNHr  = usrTime.getHours()
				getNMn  = usrTime.getMinutes()
				
				if(getDay == 0) day = "Sun";
				if(getDay == 1) day = "Mon";
				if(getDay == 2) day = "Tue";
				if(getDay == 3) day = "Wed";
				if(getDay == 4) day = "Thu";
				if(getDay == 5) day = "Fri";
				if(getDay == 6) day = "Sat";
				
				if(getMon == 0) month = "Jan";
				if(getMon == 1) month = "Feb";
				if(getMon == 2) month = "Mar";
				if(getMon == 3) month = "Apr";
				if(getMon == 4) month = "May";
				if(getMon == 5) month = "Jun";
				if(getMon == 6) month = "Jul";
				if(getMon == 7) month = "Aug";
				if(getMon == 8) month = "Sep";
				if(getMon == 9) month = "Oct";
				if(getMon == 10)month = "Nov";
				if(getMon == 11)month = "Dec";
				
				if(getNHr == 0) getNHr = "00";
				if(getNHr == 1) getNHr = "01";
				if(getNHr == 2) getNHr = "02";
				if(getNHr == 3) getNHr = "03";
				if(getNHr == 4) getNHr = "04";
				if(getNHr == 5) getNHr = "05";
				if(getNHr == 6) getNHr = "06";
				if(getNHr == 7) getNHr = "07";
				if(getNHr == 8) getNHr = "08";
				if(getNHr == 9) getNHr = "09";
				
				if(getNMn == 0) getNMn = "00";
				if(getNMn == 1) getNMn = "01";
				if(getNMn == 2) getNMn = "02";
				if(getNMn == 3) getNMn = "03";
				if(getNMn == 4) getNMn = "04";
				if(getNMn == 5) getNMn = "05";
				if(getNMn == 6) getNMn = "06";
				if(getNMn == 7) getNMn = "07";
				if(getNMn == 8) getNMn = "08";
				if(getNMn == 9) getNMn = "09";
				
				var final = day+" "+ month +" "+ getDate +" "+ getNHr +":"+ getNMn
				//alert(final)
				document.entry1.schdate.value = final;
				document.entry1.smin.value = getNMn;
				document.entry1.shour.value = getNHr;
				document.entry1.sdate.value = getDate;
				document.entry1.smonth.value = getMon + 1;
				
				document.entry1.action ="http://massmailsoftware.in/cgi-bin/CatapultV8/v5/CmLaunchMail_test.cgi";
				document.entry1.target="_self";
					//window.location.href="http://61.95.162.151/cgi-bin/Catapult/v5/CmLaunchMail_test.cgi";
				document.entry1.submit();
			}
			else if( myTime < sysTime )
			{
				alert('Campaign can not be scheduled for Past Time');
				return false;
			}
			else
			{
				//alert("ELSE")
				var usrTime = new Date;
				usrTime.setDate(date);
				usrTime.setMonth(month); // January = 0
				usrTime.setFullYear(year); 
				usrTime.setHours(hour);
				usrTime.setMinutes(min); // January = 0
				var getHour = usrTime.getHours();
				var getMin  = usrTime.getMinutes(); 

				//alert(usrTime);
				getHour = getHour - 12;
				getMin  = getMin - 40;

				usrTime.setHours(getHour);
				usrTime.setMinutes(getMin); // January = 0

				getDay  = usrTime.getDay()
				getDate = usrTime.getDate()
				getMon  = usrTime.getMonth()
				getYear = usrTime.getFullYear()
				getNHr  = usrTime.getHours()
				getNMn  = usrTime.getMinutes()

				if(getDay == 0) day = "Sun";
				if(getDay == 1) day = "Mon";
				if(getDay == 2) day = "Tue";
				if(getDay == 3) day = "Wed";
				if(getDay == 4) day = "Thu";
				if(getDay == 5) day = "Fri";
				if(getDay == 6) day = "Sat";

				if(getMon == 0) month = "Jan";
				if(getMon == 1) month = "Feb";
				if(getMon == 2) month = "Mar";
				if(getMon == 3) month = "Apr";
				if(getMon == 4) month = "May";
				if(getMon == 5) month = "Jun";
				if(getMon == 6) month = "Jul";
				if(getMon == 7) month = "Aug";
				if(getMon == 8) month = "Sep";
				if(getMon == 9) month = "Oct";
				if(getMon == 10)month = "Nov";
				if(getMon == 11)month = "Dec";

				if(getNHr == 0) getNHr = "00";
				if(getNHr == 1) getNHr = "01";
				if(getNHr == 2) getNHr = "02";
				if(getNHr == 3) getNHr = "03";
				if(getNHr == 4) getNHr = "04";
				if(getNHr == 5) getNHr = "05";
				if(getNHr == 6) getNHr = "06";
				if(getNHr == 7) getNHr = "07";
				if(getNHr == 8) getNHr = "08";
				if(getNHr == 9) getNHr = "09";

				if(getNMn == 0) getNMn = "00";
				if(getNMn == 1) getNMn = "01";
				if(getNMn == 2) getNMn = "02";
				if(getNMn == 3) getNMn = "03";
				if(getNMn == 4) getNMn = "04";
				if(getNMn == 5) getNMn = "05";
				if(getNMn == 6) getNMn = "06";
				if(getNMn == 7) getNMn = "07";
				if(getNMn == 8) getNMn = "08";
				if(getNMn == 9) getNMn = "09";

				var final = day+" "+ month +" "+ getDate +" "+ getNHr +":"+ getNMn
				//alert(final)
				document.entry1.schdate.value = final;
				document.entry1.smin.value = getNMn;
				document.entry1.shour.value = getNHr;
				document.entry1.sdate.value = getDate;
				document.entry1.smonth.value = getMon + 1;
				
				document.entry1.action ="http://massmailsoftware.in/cgi-bin/CatapultV8/v5/CmLaunchMail_test.cgi";
				document.entry1.target="_self";
					//window.location.href="http://61.95.162.151/cgi-bin/Catapult/v5/CmLaunchMail_test.cgi";
				document.entry1.submit();
			}
		}
		else 
		{
			alert('Campaign can not be scheduled for Past Date');
			return false;
		}
	}
	else
	{
		//alert('Last Else');return false;
		document.entry1.action ="http://massmailsoftware.in/cgi-bin/CatapultV8/v5/CmLaunchMail_test.cgi";
		document.entry1.target="_self";
			//window.location.href="http://61.95.162.151/cgi-bin/Catapult/v5/CmLaunchMail_test.cgi";
		document.entry1.submit();
	}
	
}
function ipchange()
{
  //alert("hello")
  var ip = document.entry1.ipadd.value
  //alert(ip)
  if(ip == "chooseownip")
  {
  	document.getElementById("displayip").style.visibility="visible";
  	var ab = document.entry1.ipvalue.value;
  	//alert(ab);
  	document.entry1.ipvalue.value = 2;
  	//var abb = document.entry1.ipvalue.value;
  	//alert(abb);
  }
  else
  	document.getElementById("displayip").style.visibility="hidden";
}

function verifyIP () 
{
	IPvalue = document.entry1.ownip.value;
	document.entry1.ownip.focus(); 
	alert(IPvalue)
	if(IPvalue =="")
	{
		alert("IPaddress should not be empty");
	}
	else
	{
		errorString = "";
		theName = "IPaddress";

		var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
		var ipArray = IPvalue.match(ipPattern);

		if (IPvalue == "0.0.0.0")
		errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
		else if (IPvalue == "255.255.255.255")
		errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
		if (ipArray == null)
		errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
		else 
		{
			for (i = 0; i < 4; i++) 
			{
				thisSegment = ipArray[i];
				if (thisSegment > 255) 
				{
					errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
					i = 4;
				}
				if ((i == 0) && (thisSegment > 255)) 
				{
					errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
					i = 4;
				}
			}
		}
	}
	extensionLength = 3;
	if (errorString == "")
	{
	//alert ("That is a valid IP address.");
	}
	else
	{
		alert (errorString);
		document.entry1.ownip.value = "";
		document.entry1.ownip.focus()
	}
}

function startcampaign()
{

    var mail_type = document.frmpost.mail_type.value;
    //alert(mail_type);
    if(mail_type == "text" || mail_type == "mixedtext")
    {
    	var pagetodisplay = "startCampaign";
    	//alert(pagetodisplay);
    }
    else{
    	var pagetodisplay = "linkstoTrack";
    	//alert(pagetodisplay);
    }
    
    var aa= document.frmpost.sub.length;
    var from = document.frmpost.from.value;
    var from1 = document.frmpost.from1.value;
    var from2 = document.frmpost.from2.value;
    var replyto = document.frmpost.replyto.value;  
    var sub = document.frmpost.sub.value;  
   
    var mailtype =  document.frmpost.mailtype.value;
    
    if(!isnullspace(from) || from=="Display Name")
    {  
            alert("Enter From Name ");
            document.frmpost.from.value=" ";
            document.frmpost.from.focus();
            return false;
    }
    if(!isnullspace(from1) || from1=="UserName")
    {            
            alert("Enter From Addresss");
            document.frmpost.from1.value=" "; 
            document.frmpost.from1.focus();
            return false;
    }
   if(!isnullspace(from2) || from2=="DomainName")
    {                       
            alert("please note that you can't track bounced email if you use domain name. Contact Bharatplanet administrator for list of domain names which you can use for tracking.");
            document.frmpost.from2.value=" "; 
            document.frmpost.from2.focus();
            return false;
    }
    if(!isnullspace(replyto) || !echeck(replyto))
    {                                 
            alert("Enter To Address Correctly");
            document.frmpost.replyto.value=" "; 
            document.frmpost.replyto.focus();
            return false;
    }
    if(!isnullspace(sub))
    {
    alert(sub);
            alert("Subject should not be Null");
            document.frmpost.sub.focus();
            return false;
    }
    if(sub.length >=80)
       {
        
        var r=confirm("Subject exceets 80 characters")
    	 if (r==true)
    	 {
    	 document.frmpost.submit(true);
    	 }else
    	 {
    	 document.frmpost.sub.focus();
         return false;
    	 }
    	 
    }
    //alert(mailtype);
    if(mailtype == "html")
    {  //alert(mailtype);
    var editorval = document.frmpost.htmmessage.value;
    editorval = editorval.replace(/\"/g, "");
    document.frmpost.editor.value = editorval;
    //return false;
    }
    if(mailtype == "text")
    {   //alert(mailtype);
     var editorval = document.frmpost.txtmessage.value;
    // alert(editorval)
    editorval = editorval.replace(/\"/g, "");
    document.frmpost.editor.value = editorval;
   // return false;
    } 
    if (isnullspace(from) && isnullspace(from1) && isnullspace(from2) && isnullspace(replyto) && isnullspace(sub) && echeck(replyto))
    {
        //return true;
        //alert("http://massmailsoftware.in/CatapultMail/index.php?action="+pagetodisplay);
        document.frmpost.action ="http://massmailsoftware.in/CatapultMail/index.php?action="+pagetodisplay;
    }
    else
    {
        return false;
    }
    
    
}

function gopage(val) {
    document.invMail.strt.value=val;
    document.invMail.submit(true);
}

function changepageRpt(){
    document.invMail.strt.value=document.invMail.pages.value;
    document.invMail.submit(true);   
}

function orderbysub(ordby) {
   document.showsub.orderBy.value=ordby;
       document.showsub.submit(true); 
}
function gopagesub(pgno) {
	
    document.showsub.pageno.value=pgno;
    document.showsub.submit(true); 
} 
function gopagesub1(pgno) 
{
    txtpgno = document.showsub.page.value;	
    if(!isnullspace(txtpgno))
    {
     	alert("Enter the Page Number");
        document.showsub.page.focus();
        return false;
    } 
    else
    {
    	if (!isnumber(txtpgno))
	{
		alert("Enter only Numbers")
		document.showsub.page.value="";
		document.showsub.page.focus();
	    	return false;
	}
	else
	{
		if(txtpgno > pgno || txtpgno==0)
    		{
    			inc = pgno + 1;
    			alert("Kindly enter the Page Number between 1 - "+pgno)
    			document.showsub.page.value="";
			document.showsub.page.focus();
    			return false;	
    		}
    		else
    		{
    			document.showsub.pageno.value=pgno;
    			document.showsub.submit(true); 
    		}	
    	}
    }
    
} 
function dispsub(pgno) {

	
	document.showsub.pageno.value=pgno;
    	document.showsub.submit(true); 
  }        
function dispsub1(pgno) {

	//alert(pgno);
	document.createcamp.pageno.value=pgno;
    	document.createcamp.action="index.php?action=emailList"
        document.createcamp.submit(true); 
  }        
function connect()
{
    var from1 = document.forms[0].from1.value;
    var from2 = document.forms[0].from2.value;
    var result=from1+"@"+from2;
    document.forms[0].replyto.value=result;

}
function showmenu(elmnt)
{
    document.getElementById(elmnt).style.visibility="visible";
}
function hidemenu(elmnt)
{
    document.getElementById(elmnt).style.visibility="hidden";
}
function displayinsert(value)
{
    var distext = "#INSERT_"+value+"_HERE#";
    document.frmpost.sub.value += distext;
}
function displayinsertfrm(value)
{
    var distext = "#INSERT_"+value+"_HERE#";
    document.frmpost.from.value += distext;
}
function displayinserttext(value)
{
    var distext = "#INSERT_"+value+"_HERE#";
    document.frmpost.htmmessage.value += distext;
}
function Fileattach()
{

//my=window.open("http://10.0.0.2:90/cgi-bin/CatapultV7/v5/spamcheck.cgi","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")
my=window.open("FilePopup.php", "Unsubscribe","toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no , width=800, height=350");
my.opener;
}
function Fileattach1()
{

//my=window.open("http://10.0.0.2:90/cgi-bin/CatapultV7/v5/spamcheck.cgi","_blank","toolbar=no,location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=no,copyhistory=no, width=800, height=600")
my=window.open("FilePopup_Imag.php", "Unsubscribe","toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,dependent=yes,status=yes,directories=no , width=800, height=350");
my.opener;
}
function deletefile(fname)
{
    //alert("hello");
    //alert(fname)
    //vv=document.getElementById("attachfiles").value;
    //alert(vv)
    filearr=document.getElementById("files").value.split("|");
    var a = filearr.length;
    //alert(a)
    var Dellist="";
    filename = fname;
    
    var Dellist="";
    var Htmlstr="<table>";
    for(i=0;i<filearr.length;i++)
    {
        if(filearr[i]!=filename)
        {
            if(Dellist=="")
            {
                Dellist=filearr[i];
            }
            else
            {
                Dellist=Dellist+"|"+filearr[i];
            }
            Htmlstr=Htmlstr+"<tr><td>"+filearr[i]+"</td><td><a href='#' onclick=";
            Htmlstr=Htmlstr+"deletefile('"+filearr[i]+"')>Remove</a></td></tr>";
        }
    }
    Htmlstr=Htmlstr+"</table>";
    document.frmpost.files.value=Dellist;
    document.getElementById("display").innerHTML=Htmlstr;
}

 var curMessage = "null";        
        function commonInsert(temVal)
        {   
        
             var tempVal = "#INSERT_"+temVal+"_HERE#"; 
             
            if (curMessage != "null")
            {   
              smileyInsert(curMessage,tempVal);
            }
            
            return false;
        }
function smileyInsert(textEl, smileyType)
        {   
         //alert("hai")
           if (textEl.createTextRange && textEl.caretPos)
           {
           //alert("hai2");
             var caretPos = textEl.caretPos;
                       
             caretPos.text = caretPos.text.charAt[caretPos.text.length - 1] == ' ' ? smileyType : smileyType;
                         textEl.focus();
                         //document.getElementById("new").style.visibility="hidden"; 
             document.frmpost.htmmessage.focus();  
           }
          return false;   
        }         
function getActiveText(textEl)
        {   
          curMessage = textEl;  
          if (textEl.createTextRange)
          textEl.caretPos = document.selection.createRange().duplicate();
          textE1 = (document.all) ? document.selection.createRange().text : document.getSelection();
          
        }
function insertAtCursor(myField, myValue) {

	//alert(myField+myValue)
	var myValue = "#INSERT_"+myValue+"_HERE#";
	if (document.selection) 
	{
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	} 
	else 
	{
		myField.value += myValue;
	}

}
function selectall()
{
    for (var i=0;i<document.frmpost.elements.length;i++)
    {
        var e=document.frmpost.elements[i];
        if ((e.type=='checkbox'))
        {
            if(!document.frmpost.elements[i].checked)
            {
                document.frmpost.elements[i].checked = true;
            }
        }
    } 
}
function deselectall()
{
    for (var i=0;i<document.frmpost.elements.length;i++)
    {
        var e=document.frmpost.elements[i];
        if ((e.type=='checkbox'))
        {
            if(document.frmpost.elements[i].checked)
            {
                document.frmpost.elements[i].checked = false;
            }
        }
    }
}

function pastcamp()
{
	var pastcampval = document.getElementById("selectpastcamp").value;
	//alert(pastcampval);
	if(pastcampval == "none")
	{
		alert("Kindly select a Past Campaign");
		return false;
	}
	else
	{
		//return true;
		document.selSubscribers.submit();
	}
}
function delsub(){
    //alert("HELLO");
    var aa= document.selSubscribers.delbox;
    var addORrem = document.getElementById("op").value;
    //alert(addORrem);
    txt="";
    var text  = aa.length;
    if(text > 1)
    {
        for ( var i=0; i<aa.length; i++)
        {
            if(document.selSubscribers.delbox[i].checked)
            { 
                if(txt=="")
                {
                    txt = txt+""+document.selSubscribers.delbox[i].value+"";
                }
                else
                {
                    txt = txt+","+document.selSubscribers.delbox[i].value+"";
                }
            }
        }
        document.selSubscribers.tableexist.value = 1;
        document.selSubscribers.delrecord.value=txt ;
        document.getElementById("op").value = "remove";
       
        //alert(txt);
        // document.getElementById("addindel").value = 1;
        //var addORrem = document.getElementById("op").value;
        //alert(addORrem);
    }
    else {
    document.getElementById("tableexist").value = 0;
    document.selSubscribers.tableexist.value = 0;
    document.getElementById("op").value = "remove";
   // alert(document.selSubscribers.tableexist.value);
    }
    //document.getElementById("addinde").value = 1;
   // document.selSubscribers.action="./index.php?action=targetEmail";
    //document.selSubscribers.submit();
}
function pageRedrt() {
 document.getElementById("op").value = "remove";
 document.getElementById("tableexist").value = 0; 
}

function addlink()
{   

    var aa= document.frmpost.chk;
    txt="";
    //alert("hi");
    
    checklength = aa.length;
    //alert(checklength)
    if(checklength>0)
    {
    for ( var i=0; i<aa.length; i++)
    {
        //alert(i)
        if(document.frmpost.chk[i].checked)
        { 
           // alert(document.frmpost.chk[i].value);
            if(txt=="")
            {
                txt = document.frmpost.chk[i].value;
            }
            else
            {
                txt = txt+","+document.frmpost.chk[i].value+"";
            }
        }
    }
    }
    else
    {
    	if(document.frmpost.chk.checked)
        {
         txt = document.frmpost.chk.value;
        }
        
        
    }
    //alert(txt);
    document.frmpost.addlinks.value=txt ;

                var radioval =  document.frmpost.radiobut;
        if(radioval.length>0) {
            for(i=0; i<radioval.length; i++) {
                if(radioval[i].checked) {
                    document.frmpost.imageselected.value=radioval[i].value;
                }
        }
           // alert(radioval.length+" this is for testing");
        } else  {
           // alert("I am here");    
             document.frmpost.imageselected.value=radioval.value;
        }    
       
    return true;
    
}
function radio()
{
    
    var radioval =  document.frmpost.radiobut;   
        if(radioval.length>0) {
            for(i=0; i<radioval.length; i++) {
                if(radioval[i].checked) {
                    document.frmpost.imageselected.value=radioval[i].value;
                }
        }
           // alert(radioval.length+" this is for testing");
        } else  {
           // alert("I am here");    
             document.frmpost.imageselected.value=radioval.value;
        }   
}
function jumpfinal(ip)
{
//alert(ip);

var r=confirm("Links can't be Tracked")
    if (r==true)
    {
    	var radioval =  document.frmpost.radiobut;   
        if(radioval.length>0) 
        {
           for(i=0; i<radioval.length; i++) 
           {
              if(radioval[i].checked) 
              {
                 document.frmpost.imageselected.value=radioval[i].value;
              }
            }
               // alert(radioval.length+" this is for testing");
        } 
        else  
        {
           // alert("I am here");    
           document.frmpost.imageselected.value=radioval.value;
        }
        document.frmpost.jumptofinal.value = 1;
        document.frmpost.action = ip +"/index.php?action=jumptoFinal";
        document.frmpost.submit();
        return false;
    }
    else
    {
     return false;
    }
 
}
function jumpfinalnl(ip)
{
//alert(ip);

   	var radioval =  document.frmpost.radiobut;   
        if(radioval.length>0) 
        {
           for(i=0; i<radioval.length; i++) 
           {
              if(radioval[i].checked) 
              {
                 document.frmpost.imageselected.value=radioval[i].value;
              }
            }
               // alert(radioval.length+" this is for testing");
        } 
        else  
        {
           // alert("I am here");    
           document.frmpost.imageselected.value=radioval.value;
        }
        document.frmpost.jumptofinal.value = 1;
        document.frmpost.action = ip +"/index.php?action=jumptoFinal";
        document.frmpost.submit();
        return false;

}
function updateprofile()
{   

    var aa= document.raj.pro_field;
    txt="";
    for ( var i=0; i<aa.length; i++)
    {
        if(document.raj.pro_field[i].checked)
        { 
            if(txt=="")
            {
                txt = txt+""+document.raj.pro_field[i].value+"";
            }
            else
            {
                txt = txt+","+document.raj.pro_field[i].value+"";
            }
        }
    }
    
    document.raj.act.value=txt ;
    
    return true;
}


function condition()
{
    var pro_split = document.getElementById("profield").value.split("|");
    var pro_length= pro_split.length;
    //alert(pro_length);
    document.getElementById("postval").value=1;   
    var aa = document.getElementById("postval").value;
   // alert(aa);
     var finalcomment = pro_split.length-1;    
    for(var i=0; i<pro_split.length; i++)
    {
    var totalvalue ="";
        var x = document.getElementById(pro_split[i]);    
        if(x.options[0].selected)
        {
           totalvalue = "-1";
        }
        else
        {
            for(var j=0; j<x.length; j++)
            {                            
                if(x.options[j].selected && x.options[j].value != -1) 
                {
                   if(totalvalue=="")
                   {
                      totalvalue =  "`" + x.options[j].value + "`";
                   }
                   else 
                   {
                      totalvalue = totalvalue + "," + "`" + x.options[j].value + "`";
                   }
                }
            }
        }
        
        document.getElementById(i).value= totalvalue;
      //  if(i!=finalcomment)
        {
      //      totalvalue = totalvalue + "|";
        } 
    } 
    document.getElementById("postval").value=1;   
    var aa = document.getElementById("postval").value;
    //alert(aa);
    document.getElementById("profieldvalue").value = finalcomment;
   // document.frmGeneral.action = ./index.php?action=targetEmail;
}
function optin(listid,ip)
{
   //alert(ip)
   //http://massmailsoftware.in/CatapultMail/CampaignManager/Optin.php 
    var optinlink = "Click here to <a title=\"Unsub\" href=\""+ip+"/Optin.php?oid=1&lid="+listid+"\" >Subscribe</a>";
    document.getElementById("htmlmessage").value += optinlink;
                                                                   
}
function doubleoptin(listid,ip)
{
    //alert(ip)
    var optinlink = "Click here to <a title=\"Unsub\" href=\""+ip+"/Optin.php?oid=2&lid="+listid+"\" >Subscribe</a>";
    document.getElementById("htmlmessage").value += optinlink;
}
function textoptin(listid,ip)
{
    //alert(ip)
    //var optinlink = "Click here to <a title=\"Unsub\" href=\"http://"+ip+"/testing/CatapultMail/report/popupwin.php?oid=1&lid="+listid+"\" >Subscribe</a>";
    var optinlink = "Copy the following link and past it in the Browzer inorder to Subscribe \""+ip+"/Optin.php?oid=1&lid="+listid+"\"";
    document.frmpost.txtmessage.value += optinlink;

}
function textdoubleoptin(listid,ip)
{
    //alert(ip)
    //var optinlink = "Click here to <a title=\"Unsub\"  >Subscribe</a>";
    var optinlink = "Copy the following link and past it in the Browzer inorder to Subscribe \""+ip+"/Optin.php?oid=2&lid="+listid+"\"";
    document.frmpost.txtmessage.value += optinlink;
}
var txtpopwin;
        function replace(string,text,by) {
        // Replaces text with by in string
            var strLength = string.length, txtLength = text.length;
            if ((strLength == 0) || (txtLength == 0)) return string;

            var i = string.indexOf(text);
            if ((!i) && (text != string.substring(0,txtLength))) return string;
            if (i == -1) return string;

            var newstr = string.substring(0,i) + by;

            if (i+txtLength < strLength)
                newstr += replace(string.substring(i+txtLength,strLength),text,by);

            return newstr;
        }
    function txtpreview()
        {
          if (!txtpopwin || txtpopwin.closed)
          {
          }
          else
          {
            txtpopwin.window.close();
          }
          var txtcontent = document.frmpost.txtmessage.value;
          txtcontent = replace(txtcontent,'<',unescape('%3C'));
          txtcontent = replace(txtcontent,'>',unescape('%3E'));
          txtcontent = replace(txtcontent,"    ","        ");
          txtpopwin = window.open("","txtpopwin",",height=520,width=780,left = 5, top = 5,toolbar=no,resizable=yes,scrollbars=yes,directories=no");
          txtpopwin.document.write("<html><body><xmp>");
          txtpopwin.document.write(txtcontent);
          txtpopwin.document.write("</xmp></body></html>");
        }
      
 function getfrom(status){
 		    var state=status;	  	 
 	  	    var all = "History.php?status="+state+"";	    		    	  	              
 	  	    myWin= open(all, "From_Address_History","height=300,width=500,toolbar=no,scrollbars=yes,resizable=no,titlebar=no,dependent=yes,status=yes,directories=no");
 				  	 
	  	 }
//***nandha validation 10.09.07 ****//
	
    function submitval()
    //var Table_Exist = new Array("nandha");
    {
        //alert("haikkkkkkkkkkkkkkkkkk");
        
        //var Table_Exist = new Array("nandha","kawsik");//alert(Table_Exist);
       // var table_new	=	document.raj.tab_names.value;
        //alert(table_new);
        //var  New_Table_Name = document.raj.new_tb.value;
        var New_Table_Name = document.getElementById("totext").value;
     // alert(textvalue);
     alert(New_Table_Name);
       // var New_Table_Desc =  document.raj.tb_desc.value;
 		
	             if (New_Table_Name.length == 0)
		             {// alert(New_Table_Name);
		               alert("Table Name Cannot be NULL");
		               document.raj.new_tb.focus();
		               return false;
        		}
        		else if (!IsValid(New_Table_Name)== true){
				alert("Invalid Table/Email_List name! Allowed Characters: Alphanumeric and _ Only");
				 document.raj.new_tb.focus();
				return false;
   		 		}
			
        				 		
	             if (New_Table_Desc.length == 0)
		             {
		               alert("Description Cannot be NULL");
		               document.raj.tb_desc.focus();
		               return false;
        		}   		 		

   
   }
   function submitval2()
       {
          	var  New_Table_Name = document.raj.new_tb.value;

         var New_Table_Desc =  document.raj.tb_desc.value;
    		
   	             if (New_Table_Name.length == 0)
   		             {
   		               alert("Table Name Cannot be NULL");
   		               document.raj.new_tb.focus();
   		               return false;
           		}
           		else	if (IsNumeric(New_Table_Name) == true) 
			          {
			           alert("Enter Alpha numeric value!");
					   document.raj.new_tb.focus();
			           return false;
          				}
           		else if (!IsValid(New_Table_Name)== true){
   				alert("Invalid Table/Email_List name! Allowed Characters: Alphanumeric and _ Only");
   				 document.raj.new_tb.focus();
   				return false;
      		 		}
   			
             var tableArray = document.raj.tab_names.value;
             var tvalue = document.raj.new_tb.value;
             tvalue = tvalue.toLowerCase();
            var tArray=tableArray.split(","); 	
             for(i=0; i<tArray.length; i++){
             	if(tvalue==tArray[i])
             		{
             		alert("Table name already exixts");
             		document.raj.new_tb.focus();
             		return false;
             		}
           }
  
   	             if (New_Table_Desc.length == 0)
   		             {
   		               alert("Description Cannot be NULL");
   		               document.raj.tb_desc.focus();
   		               return false;
           		}   		 		
          		
           		return true;
      
      }
function submitval3()

       {

          	var  New_Table_Name = document.raj.new_tb.value;

    		
   	             if (New_Table_Name.length == 0)
   		             {
   		               alert("Table Name Cannot be NULL");
   		               document.raj.new_tb.focus();
   		               return false;
           		}
           		else	if (IsNumeric(New_Table_Name) == true) 
						          {
						           alert("Enter Alpha numeric value!");
								   document.raj.new_tb.focus();
			           return false;
			           }
           		else if (!IsValid(New_Table_Name)== true){
   				alert("Invalid Table/Email_List name! Allowed Characters: Alphanumeric and _ Only");
   				 document.raj.new_tb.focus();
   				return false;
      		 		}
   			
             var tableArray = document.raj.tab_names.value;
             var tvalue = document.raj.new_tb.value;
             tvalue = tvalue.toLowerCase();

            var tArray=tableArray.split(","); 	

             for(i=0; i<tArray.length; i++){
             	if(tvalue==tArray[i])
             		{
             		alert("Table name already exixts");
             		document.raj.new_tb.focus();
             		return false;
             		}
           }
  
           		return true;
      
      }
function submitval4()

       {

          	var  New_Table_Name = document.raj.new_tb.value;
   		
   	             if (New_Table_Name.length == 0)
   		             {
   		               alert("To Field Name Cannot be NULL");
   		               document.raj.new_tb.focus();
   		               return false;
           		}
           		else	if (IsNumeric(New_Table_Name) == true) 
							{
							alert("Enter Alpha numeric value!");
							 document.raj.new_tb.focus();
						           return false;
			           }
           		else if (!IsValid(New_Table_Name)== true){
   				alert("Invalid Table/Column name! Allowed Characters: Alphanumeric and _ Only");
   				 document.raj.new_tb.focus();
   				return false;
      		 		}
   			
             var tableArray = document.raj.tab_names.value;
             var tvalue = document.raj.new_tb.value;
             tvalue = tvalue.toLowerCase();
            var tArray=tableArray.split(","); 	

             for(i=0; i<tArray.length; i++){
             	if(tvalue==tArray[i])
             		{
             		alert("Table column Name already exixts");
             		document.raj.new_tb.focus();
             		return false;
             		}
           }
  
       		
           		return true;
      
      }
function submitval5()

       {

          	var  New_Table_Name = document.raj.add_col.value;

         var New_Table_Desc =  document.raj.add_col_type.value;
         var New_Table_Size =  document.raj.add_col_size.value;
         var colTyp="- - - - - - - - - - - - -";
    	 var colSize1="0";	
   	             if (New_Table_Name.length == 0)
   		             {
   		               alert("Table Column Name Cannot be NULL");
   		               document.raj.add_col.focus();
   		               return false;
           		}
			
			else	if (IsNumeric(New_Table_Name) == true) 
				{
				alert("Enter Alpha numeric value!");
				 document.raj.add_col.focus();
			           return false;
			           }
           		
           		 else	if (New_Table_Desc == colTyp ) 
			 				{
			 				alert("Please Select Data Type !");
			 				 document.raj.add_col_type.focus();
			 			           return false;
			           }
           		else if (New_Table_Size == colSize1){
							alert("Please Specify Valid Type with");
							 document.raj.add_col_size.focus();
							return false;
      		 		}
           		else if (!IsValid2(New_Table_Size)== true){
				alert("Please Specify Valid Type with");
				 document.raj.add_col_size.focus();
				return false;
      		 		}
           		else if (!IsValid1(New_Table_Size)== true){
			   				alert("Invalid Table/Column Size! Allowed Characters: numeric Only");
			   				 document.raj.add_col_size.focus();
			   				return false;
      		 		}
           		
           		else if (!IsValid(New_Table_Name)== true){
   				alert("Invalid Table/Column name! Allowed Characters: Alphanumeric and _ Only");
   				 document.raj.add_col.focus();
   				return false;
      		 		}
   			
             var tableArray = document.raj.tab_names.value;
             var tvalue = document.raj.add_col.value;
             tvalue = tvalue.toLowerCase();

            var tArray=tableArray.split(","); 	

             for(i=0; i<tArray.length; i++){
             	if(tvalue==tArray[i])
             		{
             		alert("Table Column name already exixts");
             		document.raj.add_col.focus();
             		return false;
             		}
           }
  
   	             if (New_Table_Desc.length == 0)
   		             {
   		               alert("Field Type Cannot be NULL");
   		               document.raj.add_col_type.focus();
   		               return false;
           		}
           	if (New_Table_Size.length == 0)
		   		             {
		   		               alert("Field Size Cannot be NULL");
		   		               document.raj.add_col_size.focus();
		   		               return false;
           		}   	
  
           	if (!isInteger(New_Table_Size) == true)
				    {
				 	alert("Enter only number in Size");
				   	document.raj.add_col_size.focus();
				   
				    return false;
   				 }	
           		return true;
      
      }
      
function submitval6()

    {
       
        
        
      var New_Table_Desc =  document.raj.new_desc.value;
 		
	             
			
        				 		
	             if (New_Table_Desc.length == 0)
		             {
		               alert("Description Cannot be NULL");
		               document.raj.new_desc.focus();
		               return false;
        		}   		 		
   		    	 	
        		
   
   }

function IsValid(InputString)
    {
      var strString = InputString.toLowerCase();

      var strValidChars = "abcdefghijklmnopqrstuvwxyz0123456789_";
      var strChar;
      var blnResult = true;
            for (i = 0; i < strString.length && blnResult == true; i++)
            {
                    strChar = strString.charAt(i);
                    if (strValidChars.indexOf(strChar) == -1)
                    {
                            blnResult = false;
                    }
            }
            return blnResult;
    }
    

function IsNumeric(sText)
{
   var ValidChars = "0123456789._";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   } 
   
 

    function IsValid1(InputString)
        {
          var strString = InputString;

          var strValidChars = "0123456789_";
          var strChar;
          var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {
                        strChar = strString.charAt(i);
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                        }
                }
                return blnResult;
    }
 function IsValid2(InputString)
        {
          var strString = InputString;

          var strValidChars = "0123456789";
          var strChar;
          var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {
                        strChar = strString.charAt(i);
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                        }
                }
                return blnResult;
    }   
 function isalphabet(fdoc)
  			{
  			var len=fdoc.length;
 
  			var iChars = "0!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
 
 					  for (var i = 0; i < len; i++) {
 					  	if (iChars.indexOf(fdoc.charAt(i)) != -1) {
 					  	alert (" special characters. \nThese are not allowed.\n Please remove them and try again.");
 						return false;
 					  	}
 		  }
  			return true;
 	}
function isInteger(s)
		{
		var i;
    	for (i = 0; i < s.length; i++)
    		{

    	    var c = s.charAt(i);
    	    if (((c < "0") || (c > "9"))) return false;
    		}

    	return true;
		}
function mailalert(){
	var mailtype = document.createcamp.campmail.value
	if(mailtype == "Text Mail - Plain Format" || mailtype == "Text Mail - Mixed Format")
	{
		alert("By choosing this option we can't track the mail opens and link opens")
	}

} 