// Add By Kuo Wei on 26-6-2008 start
//--Templates-----------
function campaign_msgbody(){
          
          document.campaign_sms.ca_sms_messagebody.value=document.campaign_sms.select_template_list.value;
          textCounter(document.campaign_sms.ca_sms_optout,document.campaign_sms.ca_sms_messagebody, document.campaign_sms.charcount,document.campaign_sms.maxcharcount.value)

}

function submitButton_saveTemplate(ca_tem_id){ 
		//parameters: Form.serialize('edit_templates_form'),
    		if (document.edit_templates_form.template_name.value !='' && document.edit_templates_form.template_sms_messagebody.value !=''){
    
        		document.edit_templates_form.NextStep.disabled=true;
		
        		var ajax1;			
		    	ajax1=new Ajax.Updater('event_status','../processors/update_templates_processor.php?ca_tem_id='+ca_tem_id, {asynchronous:true, parameters: Form.serialize('edit_templates_form'),  onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
		}
    		else if(document.edit_templates_form.template_name.value==''){
    
        		alert('Please Enter Tamplate name!');
    
    		}
    		else if(document.edit_templates_form.template_sms_messagebody.value==''){
    
        		alert('Your Template Content Is Empty!');
    
    		}
	
}
	




function edit_Campaign_Template(ca_tem_id){  // retreive form to add an inividual contact
	
      		var ajax1;	//update the upload contacts div
			ajax1=new Ajax.Updater('event_status_more', '../forms/edit_templates_form.php?ca_tem_id='+ca_tem_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}), evalScripts:true  } );
			     
      		var ajax2;	//load the blue action menu	for contacts	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_campaign_templates_back.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
					
}

function delete_Campaign_Template(ca_tem_id){   //delete the selected group when clicked 
		
			var answer = confirm("Are you sure you want to delete this template?")
			if (answer){
						
				document.getElementById("indicator2").innerHTML ='Please wait... <br /><br />';    
				new Effect.Appear('indicator2');
			
				var ajax1;			
				ajax1=new Ajax.Updater('event_status_more', '../processors/delete_campaign_template_processor.php?ca_tem_id='+ca_tem_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}), evalScripts:true  } );
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
}

function template_Sort_By_Name(){

	    		var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_campaign_templates_contents.php?orderby=name', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}

function template_Sort_By_Last_Modified(){

	    		var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_campaign_templates_contents.php?orderby=modify', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}



function submitButton_addTemplate(){ 
		
    if (document.add_templates_form.template_name.value !='' && document.add_templates_form.template_sms_messagebody.value !=''){
		    
		    document.add_templates_form.NextStep.disabled=true;
		    document.getElementById("indicator").style.visibility="visible";
        	    var ajax1;			
		    ajax1=new Ajax.Updater('add_templates_status','../processors/insert_templates_processor.php', {asynchronous:true,  parameters: Form.serialize('add_templates_form'), onSuccess: new Effect.Appear('add_templates_status',{duration:1}),onFailure: new showWaitWheel('add_templates_status'), evalScripts:true  } );		
	
    }
    else if(document.add_templates_form.template_name.value==''){
    
        alert('Please Enter Tamplate name!');
    
    }
    else if(document.add_templates_form.template_sms_messagebody.value==''){
    
        alert('Your Template Content Is Empty!');
    
    }
     
}	
  
function add_New_Template(){  // shows upload form
	      		  
		  if(document.getElementById("templates_count").value>=10){
      
          		alert('You have reached template maximum, pls remove one template!');
      
      	  }
      	  else if(document.getElementById("templates_count").value<10){
			
          		document.getElementById("event_status_more").style.display="NONE";
			    
          		var ajax1;	//update the upload contacts div
			ajax1=new Ajax.Updater('event_status_more', '../forms/add_templates_form.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}), evalScripts:true  } );
			     
          		var ajax2;	//load the blue action menu	for contacts	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_campaign_templates_back.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
      	  }	
			
			//var ajax2;	
			//ajax2=new Ajax.Updater('event_status', '../processors/load_menu_campaign_templates.php?action=add', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:1}), evalScripts:true  } );
}


function initTemplates(){  
	        
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_campaign_templates_contents.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
			var ajax2;	//load the blue action menu	for contacts	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_campaign_templates.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
}

function display_use_template_link(){

      if(document.campaign_sms.select_template_list.value != ''){
  
          new Effect.Appear('use_template_link'); 
  
      }
      else if(document.campaign_sms.select_template_list.value == ''){
  
          document.getElementById("use_template_link").style.display="NONE"; 
  
      }

      /*var x=document.getElementById("select_template_list");
      
      for (i=0;i<x.length;i++){

            if(x.options[i].selected == true){

                  if(x.options[i].id=='U'){

                        document.getElementById("campaign_message_type").checked = true;

                  }
                  else  {

                        document.getElementById("campaign_message_type").checked = false;

                  }

            }
    
      }*/
   
}

//Templates Ends
// Add By Kuo Wei on 27-6-2008 ENDS
function loadUsageReport_Admin(period,email){

	 		var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_usage_reports_main_admin.php?report_period='+period+'&email='+email, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}

function initUsageReports_Admin(){  //Get Usage Reports
	        			
			var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_usage_reports_main_admin.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
			var ajax2;	//load the blue action menu	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_usage_reports_admin.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
}

function change_user_report(login_id)  {

      		var ajax1;	//			
      		ajax1=new Ajax.Updater('reports_list', '../processors/load_reports_list_processor.php?login_id='+login_id, {asynchronous:true, onSuccess: new Effect.Appear('reports_list',{duration:1}),onFailure: new showWaitWheel('wheel'), evalScripts:true  } );
				
				  var ajax2;	//load the blue action menu
			    ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=SMS', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.2}), evalScripts:true  } );
			
}
function submitButton_saveAlert(){ 
		
		    
		    document.edit_alerts_form.NextStep.disabled=true;
		    document.getElementById("indicator").style.visibility="visible";
        var ajax1;			
		    ajax1=new Ajax.Updater('edit_alerts_status','../processors/edit_alert_processor.php', {asynchronous:true,  parameters: Form.serialize('edit_alerts_form'), onSuccess: new Effect.Appear('edit_alerts_status',{duration:1}),onFailure: new showWaitWheel('edit_alerts_status'), evalScripts:true  } );		
	
    
     
}

function initAlerts(){  
	        
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../forms/edit_alerts_form.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
			
}

function reset_Password(type) { // control function for reset password submit button by Kuowei on 2007-11-13
  
      if(document.getElementById("email").value == '')  {
		  
          document.getElementById("error").innerHTML="Please enter your email address!";
          new Effect.Highlight('email');     
      }
      
      else  {   	      
            var ajax1;			
			      ajax1=new Ajax.Updater('edit_user_status','../processors/password_forgot_processor.php?type='+type, {asynchronous:true,  parameters: Form.serialize('edit_user_form'), onSuccess: new Effect.Appear('edit_user_status',{duration:1}), evalScripts:true  } );
	          //document.getElementById("forgot_password_form").style.visibility="hidden";
      }
	    
}

function submitButton_editUser(){ 
		
    if(document.edit_user_form.email.value==''){
    
        alert('Please Input Email Address!');
    
    }
    else if(document.edit_user_form.fname.value==''){
    
        alert('Please Enter First Name!');
    
    }
    else if(document.edit_user_form.timezone.value==''){
    
        alert('Please Select a Timezone!');
    
    }
    else if(document.edit_user_form.country.value==''){
    
        alert('Please Select a Country!');
    
    }
    
    else {
		    
		    document.edit_user_form.NextStep.disabled=true;
		    document.getElementById("indicator").style.visibility="visible";
        var ajax1;			
		    ajax1=new Ajax.Updater('edit_user_status','../processors/edit_user_processor.php', {asynchronous:true,  parameters: Form.serialize('edit_user_form'), onSuccess: new Effect.Appear('edit_user_status',{duration:1}),onFailure: new showWaitWheel('edit_user_status'), evalScripts:true  } );		
	
    }
     
}

function editUser(user_c_system_id){  

		document.getElementById("event_status_more").style.display="NONE";
		
		var ajax1;			ajax1=new Ajax.Updater('edit_user', '../forms/edit_user_form.php?system_id='+user_c_system_id, {asynchronous:true, onSuccess: new Effect.Appear('edit_user',{duration:1}), evalScripts:true  } );
		
		var ajax2;	//reload the blue action menu	
		ajax2=new Ajax.Updater('event_status', '../processors/load_menu_manage_users.php?type=edit', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );			
  	
}


function submitButton_addUser(){ 
		
    if(document.add_user_form.email.value==''){
    
        alert('Please Input Email Address!');
    
    }
    else if(document.add_user_form.fname.value==''){
    
        alert('Please Enter First Name!');
    
    }
    else if(document.add_user_form.timezone.value==''){
    
        alert('Please Select a Timezone!');
    
    }
    else if(document.add_user_form.country.value==''){
    
        alert('Please Select a Country!');
    
    }
    
    else {
		    document.add_user_form.NextStep.disabled=true;
		    document.getElementById("indicator").style.visibility="visible";
        	
        	var ajax1;			
		    ajax1=new Ajax.Updater('add_user_status','../processors/insert_user_processor.php', {asynchronous:true,  parameters: Form.serialize('add_user_form'), onSuccess: new Effect.Appear('add_user_status',{duration:1}),onFailure: new showWaitWheel('add_user_status'), evalScripts:true  } );	
    }
     
}

function closeEditUserForm(){

      new Effect.SwitchOff('edit_user');
      
      var ajax1;			
	  ajax1=new Ajax.Updater('event_status_more', '../processors/load_manage_users.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	

}

function closeAddUserForm(){

      new Effect.SwitchOff('add_user');
      var ajax1;			
	  ajax1=new Ajax.Updater('event_status_more', '../processors/load_manage_users.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );

}


function addUser(){  // shows add user form. To Do:User limit hard set to 20
	      		  
		  if(document.getElementById("user_count").value>=20){
      
          alert('You have reached your limit for the number of users allowed. Please contact us if you require more!');
      
      }
      else if(document.getElementById("user_count").value<20){
			 	
			 	document.getElementById("event_status_more").style.display="NONE";
			    
			    var ajax1;	
			    ajax1=new Ajax.Updater('add_user', '../forms/add_user_form.php', {asynchronous:true, onSuccess: new Effect.Appear('add_user',{duration:1}), evalScripts:true  } );
				
				var ajax2;	//reload the blue action menu	
				ajax2=new Ajax.Updater('event_status', '../processors/load_menu_manage_users.php?type=edit', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );			
      }	
			
}


function deleteUser(user_c_system_id){   //delete the selected group when clicked 
		
			var answer = confirm("Are you sure you want to delete this user?")
			if (answer){
						
				document.getElementById("indicator2").innerHTML ='Please wait... <br /><br />';    
				new Effect.Appear('indicator2');
			
				var ajax1;			
				ajax1=new Ajax.Updater('event_status_more', '../processors/delete_user_processor.php?user_c_system_id='+user_c_system_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}), evalScripts:true  } );
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
}

function user_Sort_By_Name(){

	    var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_manage_users.php?orderby=name', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}

function user_Sort_By_Last_Modified(){

	    var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_manage_users.php?orderby=modify', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}





function initManageUsers(){  //Manage Users for Administrators only
	        
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_manage_users.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
			var ajax2;	//load the blue action menu	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_manage_users.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
}


function initUsageReports(){  //Get Usage Reports
	        			
			var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_usage_reports_main.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
			var ajax2;	//load the blue action menu	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_usage_reports.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
}



function loadUsageReport(period,email){

	 		var ajax1;			
			ajax1=new Ajax.Updater('event_status_more', '../processors/load_usage_reports_main.php?report_period='+period+'&email='+email, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}),onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );
	
}


function ContactsGroupSortByName(){

	    var ajax1;			
			ajax1=new Ajax.Updater('contacts', '../processors/load_groups_processor.php?orderby=name', {asynchronous:true, onSuccess: new Effect.Appear('contacts',{duration:1}),onFailure: new showWaitWheel('contacts'), evalScripts:true  } );
	
			//new Ajax.Updater('event_status', '../processors/load_menu_groups.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
}

function ContactsGroupSortByLastModified(){

    var ajax1;			
		ajax1=new Ajax.Updater('contacts', '../processors/load_groups_processor.php?orderby=modify', {asynchronous:true, onSuccess: new Effect.Appear('contacts',{duration:1}),onFailure: new showWaitWheel('contacts'), evalScripts:true  } );
	

}

function display_recipients(list_id)  {

      		var ajax1;	//			
      		ajax1=new Ajax.Updater('quicksend_sms_recipients_drag', '../includes/quicksend_sms_recipients.inc.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('quicksend_sms_recipients_drag',{duration:1}),onFailure: new showWaitWheel('wheel'), evalScripts:true  } );
				
}

function clear_quicksend_recipients(list_id)  {

      		var ajax1;	//			
      		ajax1=new Ajax.Updater('quicksend_sms_recipients_drag', '../includes/quicksend_sms_recipients.inc.php?list_id='+list_id, {asynchronous:true, onFailure: new showWaitWheel('wheel'), evalScripts:true  } );
				
}

function show_sms_recipients_select_group(){ 
		
		document.getElementById("show_sms_recipients_select_group_link").innerHTML='<br /><a href="#" onclick="hide_sms_recipients_select_group(); return false;">Hide Recipients Select Group</a><br />';				
		new Effect.SlideDown('sms_recipients_select_group'); 
						
}

function hide_sms_recipients_freetext(){ 
		
    		//document.getElementById("show_sms_recipients_freetext_link").innerHTML='<br /><a href="#" onclick="show_sms_recipients_freetext(); return false;">Enter Numbers Manually</a><br />';
    		//new Effect.SlideUp('sms_recipients_freetext'); 
    		document.getElementById("sms_recipients_freetext").style.display="none";
		document.quicksend.mobile_numbers.value = 'Enter Mobile Numbers';					
}

function hide_sms_recipients_select_group(){ 
		
    		//document.getElementById("show_sms_recipients_select_group_link").innerHTML='<br /><a href="#" onclick="show_sms_recipients_select_group(); return false;">Show Recipients Select Group</a><br />';
    		new Effect.SlideUp('sms_recipients_select_group'); 
		document.getElementById('select_sms_list').value='NONE';
    		display_recipients('NONE');				
}

function show_sms_recipients_freetext(){ 
		
		//document.getElementById("show_sms_recipients_freetext_link").innerHTML='<br /><a href="#" onclick="hide_sms_recipients_freetext(); return false;">Hide Manul Numbers Entry</a><br />';				
		new Effect.SlideUp('quicksend_sms_recipients_drag');
		document.getElementById('select_sms_list').value='NONE';
    		display_recipients('NONE');
    		new Effect.SlideDown('sms_recipients_freetext'); 
					
}


function show_duplicateNumber(list_id){   //load the individual contacts in a group when clicked 
	        
			document.getElementById("search_contacts").style.display="none";
			//document.getElementById("contacts").style.display="none";	
			
			//new Effect.Appear('contacts_individual'); //new
      
      var ajax1;		
			//ajax1=new Ajax.Updater('contacts_individual', '../processors/load_groups_contents_processor.php?list_id='+list_id, {asynchronous:true , onComplete: new Effect.Appear('contacts_individual') , evalScripts:true} );
			//onSuccess: document.getElementById("indicator2_text").innerHTML =""
			
			ajax1=new Ajax.Updater('contacts', '../processors/load_groups_contents_duplicate_processor.php?list_id='+list_id, {asynchronous:true , onSuccess: new Effect.Fade('indicator2') ,onFailure: new showWaitWheel('contacts'), evalScripts:true} );
	
				
			var ajax2;	//load the blue action menu	for contacts in a group
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_group_contents_duplicate.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:1}),evalScripts:true  } );
				
	}

function reset_recipients() { //pagination added by Kuo Wei on 25-2-2008
			
			//document.getElementById("api_report").style.display="none";	
		  
			var ajax1;		
			ajax1=new Ajax.Updater('campaign_sms_recepients', '../includes_campaign/campaign_sms_recipients.inc.php', {asynchronous:true , onComplete: new Effect.SlideDown('campaign_sms_recepients'), onFailure: new showWaitWheel('campaign_sms_recepients') , evalScripts:true} );
	
}

function show_date_filter(){ 
		document.getElementById("show_date_filter").innerHTML='<br /><a href="#" onclick="hide_date_filter(); return false;">Hide date filter</a><br />';				
		new Effect.SlideDown('date_filter'); 
						
}

function hide_date_filter(){ 
		document.getElementById("show_date_filter").innerHTML='<br /><a href="#" onclick="show_date_filter(); return false;">Show date filter</a><br />';				
		new Effect.SlideUp('date_filter'); 
						
}

function view_SMS_Report(ca_id,ca_type,from_date,to_date){   //load the SMS sent log details within a SMS Campaign Report
	
			//new Effect.ScrollTo('menu_blue');
	        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_sms_report.php?ca_id='+ca_id+'&ca_type='+ca_type+'&from_date='+from_date+'&to_date='+to_date, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
			var ajax2;	//load the blue action menu 			
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=LogsSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
}	
function load_report_next_page(div_id,file_path,page,from_date,to_date) { //pagination added by Kuo Wei on 25-2-2008
			
			//document.getElementById("api_report").style.display="none";	
		  
			var ajax1;		
			ajax1=new Ajax.Updater(div_id, file_path+'?page='+page+'&from_date='+from_date+'&to_date='+to_date, {asynchronous:true , onComplete: new Effect.SlideDown(div_id), onFailure: new showWaitWheel(div_id) , evalScripts:true} );
	
}
function show_link(num){
			new Effect.Appear('reset_recipients'); 
			var id="show_select_options"+num;
      var select_list="select_sms_list"+num;
      num=num+1
      var select_id="select"+num;
      if(document.getElementById(select_id).style.visibility=="visible"){
      
          if(document.getElementById(select_list).options[0].selected || document.getElementById(select_list).options[1].selected){
          document.getElementById(id).style.visibility="hidden";
          }
      }
      else {
          //new Effect.Appear("show_select_options1");
          document.getElementById(id).style.visibility="visible";
          
      }
			
}		

function hide_link(num){
			 
			if(num <5) {
        var id="show_select_options"+num;
        document.getElementById(id).style.visibility="hidden";
        
      }
    
			
}	

function show_select_options(i){
			 
			
      var id="show_select_options"+i;
      document.getElementById(id).style.visibility="hidden";
      
			i=i+1;
			var select_id="select"+i;
			document.getElementById(select_id).style.visibility="visible";
      	
}	

function check_recipient_group(group_count) {
		
	    for(var i = 2 ; i <=group_count+1 ; i++)   {
	    	      
	         var select_name1="select_sms_list1";
	         var select_name2="select_sms_list2";
	         var select_name3="select_sms_list3";
	         var select_name4="select_sms_list4";
	         var select_name5="select_sms_list5";
	         
	       if(document.getElementById(select_name1).options[i].selected || document.getElementById(select_name2).options[i].selected || document.getElementById(select_name3).options[i].selected || document.getElementById(select_name4).options[i].selected || document.getElementById(select_name5).options[i].selected) {
             
              for(var j = 1 ; j <=5 ; j++)   {  
            
                  var select_name="select_sms_list"+j;
                      
                      if(document.getElementById(select_name).options[i].selected) {
              
                           document.getElementById(select_name).options[i].disabled=false;
                           	document.getElementById(select_name).disabled=true;
				        //document.getElementById(select_name).disabled=false;
              
                      }
                      else  {
                       //alert("haha");
                       var block_id=j+"_"+i;
                      document.getElementById(select_name).options[i].value="NONE";
              	      document.getElementById(select_name).options[i].innerHTML="USED";
              	      //document.getElementById(select_name).disabled=true;
                      }
              }  
        }
        else {
              
              for(var k = 1 ; k <=5 ; k++)   {  
            
                  var select_name="select_sms_list"+k;  
                  document.getElementById(select_name).options[i].disabled=false;
              }
         
        }
        
    }
      
}
	
	function loadNextPage_api_report(ext_app_id,page,from_date,to_date) { //pagination added by Kuo Wei on 25-2-2008
			
			//document.getElementById("api_report").style.display="none";	
		  
			var ajax1;		
			ajax1=new Ajax.Updater('api_report', '../processors/load_report_api.php?ext_app_id='+ext_app_id+'&page='+page+'&from_date='+from_date+'&to_date='+to_date, {asynchronous:true , onComplete: new Effect.SlideDown('api_report'), onFailure: new showWaitWheel('api_report') , evalScripts:true} );
	
	}
	
	function loadNextPage_quicksend_sms_report(system_id,page) { //this is to support pagination 2007-07
			
			//document.getElementById("quicksend_sms_report").style.display="none";	
		
			var ajax1;		
			ajax1=new Ajax.Updater('quicksend_sms_report', '../processors/load_quicksend_sms_report.php?system_id='+system_id+'&page='+page, {asynchronous:true , onComplete: new Effect.SlideDown('quicksend_sms_report'), onFailure: new showWaitWheel('quicksend_sms_report') , evalScripts:true} );
	
	}
	
	
	
	
	

//Main Pages Navigation	
//-----------------------------------------------
	function goTo(page){
			
			//document.getElementById("indicator_top").innerHTML ='<span style="background-color:#CCCCCC; color:#FFFFFF; font-size:11px; margin-right:8px; margin-top:2px;" >Loading...</span>'; 
			 
			// new Effect.Appear('indicator_top',{duration:3});
			 document.getElementById("indicator_top").style.visibility="visible";
			 window.location.href=page;	
	}	
	
	
	
	function logOut(){
			 
			 document.getElementById("indicator_top_text").innerHTML="Logging out now...";
			 document.getElementById("indicator_top").style.visibility="visible";
			 window.location.href='../processors/logout_processor.php';	
	}	


 
  function setExistsEmail(email) {   //generate email for registered user

		document.getElementById("contact_email").value= email ;
		new Effect.Highlight('contact_email');
		
	}
	
  function contact_us(){  //control function for contact us by Kuowei on 2007-11-13 
 	
	//new Effect.SlideUp('contact_us_result');
	//new Effect.ScrollTo('contact_us');
	
	//new Effect.MoveBy( this.parentNode, 110, 0 , {duration: 0.3,  transition: Effect.Transitions.slowstop});
    //new Effect.MoveBy( 'contact_us', -100, 0 , {duration: 0.5});
  
	ajax1=new Ajax.Updater('contact_us','../forms/contactus_form.php', {asynchronous:true, onSuccess: new Effect.Appear('contact_us',{duration:1}), evalScripts:true  } );
  
  }
  
  function submit_contact_us()  {
		
      if(document.getElementById("contact_email").value == '') {
		  
          document.getElementById("contact_email").value="Please enter your email address!";
          //alert("Please enter your email address!");
          new Effect.Highlight('contact_email');
      
      }
	  else if (document.getElementById("contact_message").value == '')  {
		  
          document.getElementById("contact_message").value="Please enter your message!";
          new Effect.Highlight('contact_message');     
      }
      
      else {
        var ajax1;			
	    ajax1=new Ajax.Updater('contact_us_result','../processors/contact_us_processor.php', {asynchronous:true,  parameters: Form.serialize('contact_us_form'), onSuccess: new Effect.Appear('contact_us_result',{duration:2}), evalScripts:true  } );
		
		new Effect.Fade('contact_us');
	  }
  }
	
	function submit_contact_us_cancel(){ 
		
		new Effect.SwitchOff('contact_us');
	
	}


  function submitResetPassword() { // control function for reset password submit button by Kuowei on 2007-11-13
  
      if(document.getElementById("email").value == '')  {
		  
          document.getElementById("error").innerHTML="Please enter your email address!";
          new Effect.Highlight('email');     
      }
      
      else  {   	      
            var ajax1;			
			      ajax1=new Ajax.Updater('forgot_password_result','../processors/password_forgot_processor.php', {asynchronous:true,  parameters: Form.serialize('forgot_password_form'), onSuccess: new Effect.Appear('forgot_password_result',{duration:1}), evalScripts:true  } );
	          //document.getElementById("forgot_password_form").style.visibility="hidden";
      }
	    
}


	
//-------------------------
//Purchase



	function buyCredit(system_id) {  //credit_purchase_form
		
		     var ajax1;			
						
			 ajax1=new Ajax.Updater('dash_activity','../payments/paypal_processor.php', {asynchronous:true,  parameters: Form.serialize('credit_purchase_form'), onSuccess: new Effect.Appear('dash_activity',{duration:1}), evalScripts:true  } );

		
	}



//----------------------
//Main functions
	function loadActionMenu(){  // shows actionMenu for contacts
	        
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('action_menu', '../headers/action_menu-contacts.php', {asynchronous:true, onSuccess: new Effect.Appear('action_menu')  } );
	
	}	
	
		
	function initFinalStep(){  // shows body of final campaign step        
			//alert(pg);
			 new Effect.Appear('final_step',{duration:0.5});
			
	}
	
	function finalStep(){  // shows body of final campaign step        
			//alert(pg);
			 new Effect.Appear('final_preview');
			 document.campaign4.campaign4Next.disabled=false;
			 new Effect.Highlight('final_preview',{duration:0.5});
	}
	


	function initContacts(pg){  // shows contacts groups on body onload
	        
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('contacts', '../processors/load_groups_processor.php', {asynchronous:true, method:'POST', postBody: 'page='+pg, onSuccess: new Effect.Appear('contacts',{duration:1}),onFailure: new showWaitWheel('contacts'), evalScripts:true  } );
	
			var ajax2;	//load the blue action menu	for contacts	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_groups.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
	}
	
	
	function initCampaignsList() {//shows the lst of campaigns
			
			//alert(pg);
			var ajax1;			
			ajax1=new Ajax.Updater('campaigns_list', '../processors/load_campaigns_list_processor.php', {asynchronous:true, onSuccess: new Effect.Appear('campaigns_list',{duration:1}),onFailure: new showWaitWheel('campaigns_list'), evalScripts:true  } );
	
	
	}
	
	
	function initDash(system_id){  // shows body of dashboard
			 
			 new Effect.Appear('dash_col-A');
			 
			 //new Effect.Appear('recent_campaigns',{duration:2});
			 //new Effect.Appear('recent_contacts',{duration:3});
			 //new Effect.Appear('recent_news',{duration:4});	
			
			var ajax1;			
			ajax1=new Ajax.Updater('dash_main', '../processors/load_dash_summary_processor.php', {asynchronous:true, onSuccess: new Effect.Appear('dash_main',{duration:1}),onFailure: new showWaitWheel('dash_main')  } );
			//var ajax2;			
			//ajax2=new Ajax.Updater('dash_col-A', '../widgets/widget_set.php', {asynchronous:true, onSuccess: new Effect.Appear('dash_col-A',{duration:1}),onFailure: new showWaitWheel('dash_col-A')  } );
			
	}
	
	
	function initDash_payment(credit_type){  // shows body of dashboard
			 
			//new Effect.Appear('dash_activity');
	
			var ajax1;			
			ajax1=new Ajax.Updater('dash_activity', '../processors/load_buy_credit_processor.php?credit_type='+credit_type, {asynchronous:true, onSuccess: new Effect.Appear('dash_activity',{duration:1}),onFailure: new showWaitWheel('dash_activity')  } );
			
			//new Effect.ScrollTo('dash_activity');
			
	}
	
	
	
	function initAccount(){  // shows body of account profile
	
			 new Effect.Appear('personal_info');
			// new Effect.Appear('api_info');
			 new Effect.Appear('coy_info',{duration:3});
	}

	
	
	function initAPI() {
		
			var ajax2;	//load the blue action menu	for Web API	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_api.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
			new Effect.Appear('api_info');
			new Effect.Fade('api_report');
	
	}



  
	function returnAjaxError(div) {
		
		 document.getElementById(div).innerHTML='<br /><br /><span class="body_box_alert">It seems like your Internet Connection is not active. Please get online to continue using this application.</span><br /><br />';

	}
	
	
	function showWaitWheel(div) {
		
		 document.getElementById(div).innerHTML='<br /><br /><img name="indicator2" id="indicator2_image" class="indicator2" src="../images/indicator2.gif"/><br /><br />';
	
	}

// Functions for Account page---------------------------------------
//===================================================================

    
  
  function loadChangePassword(link,div,form) { // Kuowei 2007-11-01 to display change password form
      document.getElementById(link).style.visibility="hidden";
      
	  var ajax1;
	 ajax1=new Ajax.Updater(div,form, {asynchronous:true, onSuccess: new Effect.Appear(div,{duration:1}), evalScripts:true  } );
      
	  
  }
  
  
  
  function close_ChangePassword(password2_tab,div,password1,password2,link) {
      
      //new Effect.Appear('changePassword_link');
	  
	  document.getElementById(password2_tab).style.display="none";
	  document.getElementById(div).style.display="none";
      //new Effect.Fade('changePassword');
	  
	  document.getElementById(password1).value='';
	  document.getElementById(password2).value='';
	  
	  document.getElementById(link).style.visibility="visible";
	  
  }
  
 
  function changePasswordAgain(password1,password1_prompt,password2_tab) {  //control function for password change input field by Kuowei on 2007-11-01
  			
		if ( (document.getElementById(password1).value.length) < 4 ) {
			
				document.getElementById(password1_prompt).innerHTML='<br /><font color="#999999">6 or more characters please</font>';
			 
							
		}
		
		else if ( (document.getElementById(password1).value.length) > 4 ) {
			
				
				document.getElementById(password1_prompt).innerHTML="";
				
				
				new Effect.Appear(password2_tab);
				
	 }
}
  
 function submitChangePassword(password1,password2,div,processor,form_id,link) { // control function for password change submit button by Kuowei on 2007-11-01
  
      if(document.getElementById(password1).value == '')
      {
          alert("Both Passwords must be filled in!");
          
      
      }
      
      else if(document.getElementById(password2).value == '')
      {
          alert("Both Passwords must be filled in!");
          
      
      }
      else if ( (document.getElementById(password1).value.length) < 6 )
      {
          alert("6 or more characters please");
      }
      else if ( (document.getElementById(password2).value.length) < 6 )
      {
          alert("6 or more characters please");
      }
      
      else if ( document.getElementById(password1).value == document.getElementById(password2).value )
      {
    	
            var ajax1;			
			      ajax1=new Ajax.Updater(div,processor, {asynchronous:true,  parameters: Form.serialize(form_id), onSuccess: new Effect.Appear(div,{duration:5}),onFailure: new showWaitWheel(div), evalScripts:true  } );
	           document.getElementById(link).style.visibility="visible";
      }
	    
      else 
	    {
	          var returnval;
            alert("Your chosen passwords do not match, please try again!");
			     	//document.signup_form.password2.focus();
				
				    new Effect.Highlight(password2);
				  
				    returnval = false;
				    return returnval;
			}
			
			 
       
}
 ////////////////////////////////////Modify Ends here////////////////////////////////////////////// 

//===================================================================






	
// Functions for Contacts---------------------------------------------
//==================================================================

		
	
	function loadUploadContacts(list_id){  // shows upload form
	      		  
			//document.getElementById("event_status").style.display="none";	
			//new Effect.SlideUp('contacts');
			
			//new Effect.Fade('contacts');
			document.getElementById("contacts").style.display="none";	

			new Effect.Appear('upload_contacts');
			
			var ajax1;	//update the upload contacts div
			ajax1=new Ajax.Updater('upload_contacts', '../forms/upload_contacts_form.php', {asynchronous:true, onSuccess: new Effect.Appear('upload_contacts',{duration:1}), evalScripts:true  } );
				
			
			var ajax2;	//load the blue action menu	for upload contacts page
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_group_contents.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:1}), evalScripts:true  } );
				
	}
	
		
	function loadUploadContacts_group(list_id){  // shows upload form
	      		  
			document.getElementById("contacts").style.display="none";	
			document.getElementById("add_contact").style.display="none";	
			

			new Effect.Appear('upload_contacts');
			
			var ajax1;	//update the upload contacts div
			ajax1=new Ajax.Updater('upload_contacts', '../forms/upload_contacts_form.php?mode=in_group&list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('upload_contacts',{duration:1}), evalScripts:true  } );
			
				
	}
	
	
	
	function addContact(list_id){  // retreive form to add an inividual contact
	      		  		
			document.getElementById("upload_contacts").style.display="none";	
			
			var ajax1;	//load the blue action menu	for upload contacts page
			ajax1=new Ajax.Updater('add_contact', '../forms/add_contact_form.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('add_contact',{duration:1}), evalScripts:true  } );
					
	}
	
	
	
	function editContact(contact_id){  // retreive form to add an inividual contact
	
			//new Effect.Highlight('edit_contact-'+contact_id);
			
			///document.getElementById("edit_function-"+contact_id).style.display ='none';   
			// does not work!  document.getElementById('edit_link-'+contact_id).disabled=true; 
			      		  		
			var ajax1;	
		 	ajax1=new Ajax.Updater('edit_contact_form-'+contact_id, '../forms/edit_contact_form.php?contact_id='+contact_id, {asynchronous:true, onSuccess: new Effect.Appear('edit_contact_form-'+contact_id,{duration:1}), onFailure: new showWaitWheel('edit_contact_form-'+contact_id), evalScripts:true  } );
					
	} // Appear effect for this div is redundant, need to update--------------------



	function unDoUnsub(contact_id){
				
			var answer = confirm("Are you sure you want to undo the usub for this contact? This contact will thereafter start receiving SMS from you")
			
			if (answer){
				
				document.getElementById('undo_unsub_fn1-'+contact_id).style.display="none";
			
						
 				var ajax1;			
				ajax1=new Ajax.Updater('undo_unsub-'+contact_id, '../processors/undo_unsub_processor.php?contact_id='+contact_id, {asynchronous:true, onSuccess: new Effect.Appear('undo_unsub-'+contact_id,{duration:1}), onFailure: new showWaitWheel('undo_unsub-'+contact_id), evalScripts:true  } );
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
		
		
	}


	
	
	function close_addContact(){  		
			new Effect.SlideUp('add_contact');			
	}
	
	
	
	
	function deleteContact(contact_id,list_id,duplicate){   //delete the selected group when clicked 
		
			var answer = confirm("Are you sure you want to delete this contact?")
			if (answer){
						
				document.getElementById("indicator2_text").innerHTML ='Please wait... <br /><br />';    
				new Effect.Appear('indicator2');
			
				var ajax1;			
				ajax1=new Ajax.Updater('contact-'+contact_id, '../processors/delete_contact_processor.php?contact_id='+contact_id+'&list_id='+list_id, {asynchronous:true, onComplete: new Effect.Appear('contact-'+contact_id,{duration:1}),onFailure: new showWaitWheel('contact-'+contact_id), evalScripts:true  } );
	      if(duplicate == 'duplicate'){
  
            var ajax2;	//load the blue action menu	for contacts	
			      ajax2=new Ajax.Updater('event_status', '../processors/load_menu_group_contents_duplicate.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
        }
        else  {
	
	         var ajax2;	//load the blue action menu	for contacts	
			     ajax2=new Ajax.Updater('event_status', '../processors/load_menu_group_contents.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.5}), evalScripts:true  } );
			
			  }
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	

	
	function loadGroupContacts(list_id){   //load the individual contacts in a group when clicked 
	        
			//#document.getElementById("indicator2_text").innerHTML ='Please wait while we load your contacts... <br /><br />';    		
		      //#new Effect.Appear('indicator2'); //why does this flicker?
			//new Effect.SlideUp('contacts');
			
			//=====
			//new Effect.SlideUp('contacts_individual');
			new Effect.Appear('contacts');
			//=====
			
			document.getElementById("search_contacts").style.display="none";
			//document.getElementById("contacts").style.display="none";	
			
			//new Effect.Appear('contacts_individual'); //new
			
			
			var ajax1;		
			//ajax1=new Ajax.Updater('contacts_individual', '../processors/load_groups_contents_processor.php?list_id='+list_id, {asynchronous:true , onComplete: new Effect.Appear('contacts_individual') , evalScripts:true} );
			//onSuccess: document.getElementById("indicator2_text").innerHTML =""
			
			ajax1=new Ajax.Updater('contacts', '../processors/load_groups_contents_processor.php?list_id='+list_id, {asynchronous:true , onSuccess: new Effect.Fade('indicator2') ,onFailure: new showWaitWheel('contacts'), evalScripts:true} );
	
				
			var ajax2;	//load the blue action menu	for contacts in a group
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_group_contents.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}),evalScripts:true  } );
				
	}
	
	
	
	function loadUnsubscribes(ab_id){   //load the contacts in the SMS unsubs table 
	        
			document.getElementById("contacts").style.display="none";	
			
			new Effect.Appear('contacts_individual'); 
			
			
			var ajax1;		
			
			ajax1=new Ajax.Updater('contacts_individual', '../processors/load_sms_unsub_list_processor.php?ab_id='+ab_id, {asynchronous:true , onSuccess: new Effect.Fade('indicator2') ,onFailure: new showWaitWheel('contacts_individual'), evalScripts:true} );
	
				
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_unsub.php?ab_id='+ab_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}),evalScripts:true  } );
				
	}
	
	
	
	
	function deleteGroup(list_id){   //delete the selected group when clicked 
	
			var answer = confirm("Are you sure you want to remove this group?")
			if (answer){
						
				document.getElementById("indicator2_text").innerHTML ='Please wait... <br /><br />';    
				new Effect.Appear('indicator2');
			
				var ajax1;			
				ajax1=new Ajax.Updater('contacts', '../processors/delete_group_processor.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('contacts',{duration:1}), evalScripts:true  } );
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	
	function show_addContacts_options(list_id){ 
						
				document.getElementById("event_status_more").innerHTML ='<br /><span ><img src="../images/icons/upload.png" /> <br /> <a href="#" onclick="addContact('+list_id+');return false;">Add Contacts Manually</a> | <a href="#" onclick="loadUploadContacts_group('+list_id+');return false;">Upload Contacts to this Group</a> </span>';    
				
				new Effect.SlideDown('event_status_more',{duration:0.2}); 
						
	}
/************            Add by Kuo Wei on 12-11-2007   **********************/	
	function general_export(){   //exports  as csv
										
			    window.location.href="../processors/export_as_csv_processor.php";
							
	}
/**************************************************************************/	
	
	function show_exportGroup(list_id){ 
						
				document.getElementById("event_status_more").innerHTML ='<br /><div ><img src="../images/icons/export.png" />&nbsp<img src="../images/icons/close_button.png" width="20" height="14" onClick="new Effect.SwitchOff(\'event_status_more\');" /><br /><a href="#" onclick="exportGroup_active('+list_id+');return false;">Export Active Contacts only</a> | <a href="#" onclick="exportGroup_all('+list_id+');return false;">Export All</a> </div>';    
				
				new Effect.SlideDown('event_status_more',{duration:0.2}); 
						
	}
	
	
	
	function hide_exportGroup(){ 
				  
			    document.getElementById("event_status_more").innerHTML ='';
				document.getElementById("event_status_more").style.display="none";	
		
				//new Effect.SlideUp('event_status_more');      		  		
	}
	

	function exportGroup_all(list_id){   //exports the selected group as csv
										
			    window.location.href="../processors/export_csv_processor.php?list_id="+list_id;
							
	}
	
	function exportGroup_active(list_id){   //exports the selected group as csv
										
			    window.location.href="../processors/export_csv_processor.php?mode=active&list_id="+list_id;
							
	}
	
	
		
	function show_searchGroup(list_id) { //defunct
			
			var ajax1;	
			ajax1=new Ajax.Updater('event_status_more', '../forms/search_contact_form.php?list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more',{duration:1}), evalScripts:true  } );
			
			//new Effect.SlideDown('event_status_more'); 
						
	}
	
	
	function loadSearchContacts(addressbook_id){ //show search form: Kuo Wei 5-11-2007 --
  
		  new Effect.Appear('search_contacts');
		  
		  var ajax1;	//update the search contacts div
		  ajax1=new Ajax.Updater('search_contacts', '../forms/search_contact_form.php?addressbook_id='+addressbook_id, {asynchronous:true, onSuccess: new Effect.Appear('search_contacts',{duration:1}), evalScripts:true  } );
							
  
  }
  
  
  function close_searchContacts(){  // Kuo Wei 5-11-2007 -
		
		    new Effect.SwitchOff('search_contacts');
		    document.getElementById("contacts_individual").style.display="none"; //where search results go..
			
			document.getElementById("contacts").style.display="visible";
	
			//var ajax1;			
		    //ajax1=new Ajax.Updater('contacts', '../processors/load_groups_processor.php', {asynchronous:true, method:'POST', postBody: 'page=1', onSuccess: new Effect.Appear('contacts',{duration:1}),onFailure: new showWaitWheel('contacts'), evalScripts:true  } );
    
	
	}
  
	function load_menuSearchResults() {
		
			var ajax1;	//load the blue action menu	for upload contacts page
			ajax1=new Ajax.Updater('event_status', '../processors/load_menu_search_results.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:1}), evalScripts:true  } );
		
		
	}
	
	function viewUploadFileExamples() {
		
		var ajax1;	
		ajax1=new Ajax.Updater('info', '../includes/upload_formats.php', {asynchronous:true, onSuccess: new Effect.Appear('info'), onFailure: new showWaitWheel('info'), evalScripts:true  } );
			
		//document.getElementById("info").innerHTML="<b>Cellphone Sample Upload Format</b><br />981727726<br />97655726<p /><b>Email Sample Upload Format</b><br />joe@company.com<br />smith@cg.com <br/><br/>(Each record is seperated by a new line)";	
		//new Effect.Highlight('info');
	}
	
	
	function viewOptOutExamples() {
		
		var ajax1;	
		ajax1=new Ajax.Updater('info', '../includes/optout_format.php', {asynchronous:true, onSuccess: new Effect.Appear('info'), onFailure: new showWaitWheel('info'), evalScripts:true  } );
			
	}
	
	function create_API_Key(list_id) { //20071103 creates and displays Email subscription API key for webmasters to integrate
		
		var ajax1;	
		ajax1=new Ajax.Updater('event_status_more', '../processors/subscriber_api.php?mode=makekey&list_id='+list_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status_more'), onFailure: new showWaitWheel('event_status_more'), evalScripts:true  } );			
			
	}
	
	
	function loadGroupSort(){ 
	
				document.getElementById("event_status_more").innerHTML ='<br /><div ><img src="../images/icons/sort.png" />&nbsp<img src="../images/icons/close_button.png" width="20" height="14" onClick="new Effect.SwitchOff(\'event_status_more\');" /><br /><a href="#" onclick="ContactsGroupSortByName();return false;"> Sort By Name </a> | <a href="#" onclick="ContactsGroupSortByLastModified();return false;"> Sort By Last Modified</a></div>';    
				
				new Effect.SlideDown('event_status_more',{duration:0.2}); 
						
	}



//---Pagination functions--------------------------
//==================================================
		
	function loadNextPage_contacts(list_id,page) { //this is to support pagination 2007-07
			
		//document.getElementById("contacts").style.display="none";	
		
		var ajax1;		
		ajax1=new Ajax.Updater('contacts', '../processors/load_groups_contents_processor.php?list_id='+list_id+'&page='+page, {asynchronous:true , onComplete: new Effect.Appear('contacts') , onFailure: new showWaitWheel('contacts') ,evalScripts:true} );
	
	}
	
	
	function loadNextPage_reports(system_id,page) { //this is to support pagination 2007-07
			
			document.getElementById("reports_list").style.display="none";	
		
			var ajax1;		
			ajax1=new Ajax.Updater('reports_list', '../processors/load_reports_list_processor.php?system_id='+system_id+'&page='+page, {asynchronous:true , onComplete: new Effect.SlideDown('reports_list'), onFailure: new showWaitWheel('reports_list') , evalScripts:true} );
	
	}
	
	
	function loadNextPage_reports_sms(system_id,page) { //this is to support pagination 2007-07
					
			document.getElementById("reports_list").style.display="none";	
				
			var ajax1;		
			ajax1=new Ajax.Updater('reports_list', '../processors/load_reports_list_processor.php?system_id='+system_id+'&page='+page+'&type=SMS', {asynchronous:true , onComplete: new Effect.SlideDown('reports_list') , onFailure: new showWaitWheel('reports_list') , evalScripts:true} );
	
	}
	
	
	
	
//Reports Section-------------------------------------------------
//================================================================
	
	function initReportsList(system_id){  // shows Reports List on body onload     
	
			document.getElementById("reports_list").style.display="none";
			document.getElementById("report_details").style.display="none";
			document.getElementById("report_logs").style.display="none";
			
			document.getElementById("event_status").style.display="none";
	
			var ajax1;			
			ajax1=new Ajax.Updater('reports_summary', '../processors/load_reports_summary_processor.php?system_id='+system_id, {asynchronous:true, onSuccess: new Effect.Appear('reports_summary',{duration:2}),onFailure: new showWaitWheel('reports_summary')  } );			
				
	}
	
	
	
	function initCustomReportsList(system_id){  // shows Custom Reports List on body onload     
	
			document.getElementById("reports_list").style.display="none";
			document.getElementById("report_details").style.display="none";
			document.getElementById("report_logs").style.display="none";
			
			document.getElementById("event_status").style.display="none";
	
			var ajax1;			
			ajax1=new Ajax.Updater('custom_reports_summary', '../processors/load_custom_reports_summary_processor.php?system_id='+system_id, {asynchronous:true, onSuccess: new Effect.Appear('custom_reports_summary',{duration:1}),onFailure: new showWaitWheel('custom_reports_summary')  } );			
				
	}
	
	//+++++++++++++++++++++++++++++++++++++++++++++++++
	
	function initReportsList_Email(system_id){  // shows Reports List on body onload     
	
			var ajax1;			
			ajax1=new Ajax.Updater('reports_list', '../processors/load_reports_list_processor.php?system_id='+system_id+'&type=Email', {asynchronous:true, onSuccess: new Effect.Appear('reports_list',{duration:1}), onFailure: new showWaitWheel('reports_list')   } );			
			
			
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?&type=Email', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
			document.getElementById("reports_summary").style.display="none"; 
			document.getElementById("custom_reports_summary").style.display="none";
				
	}
	
		
	function initReportsList_SMS(){  // shows Reports List on body onload     
	
			var ajax1;			
			ajax1=new Ajax.Updater('reports_list', '../processors/load_reports_list_processor.php?type=SMS', {asynchronous:true, onSuccess: new Effect.Appear('reports_list',{duration:1}), onFailure: new showWaitWheel('reports_list')  } );
			
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=SMS', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:0.2}), evalScripts:true  } );
								
			document.getElementById("reports_summary").style.display="none";
			document.getElementById("custom_reports_summary").style.display="none";
				
	}
	
	
	//+++++++++++++++++++++++++++++++++++++++++++++++++
	
	function initReportsList_Custom(system_id,type){  //type1= Custom Campaign, type2= HTTP API    
	
			var ajax1;			
			ajax1=new Ajax.Updater('reports_list', '../processors/load_custom_reports_list_processor.php?system_id='+system_id+'&type='+type, {asynchronous:true, onSuccess: new Effect.Appear('reports_list',{duration:1}), onFailure: new showWaitWheel('reports_list')   } );			
			
			
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
			document.getElementById("reports_summary").style.display="none"; 
			document.getElementById("custom_reports_summary").style.display="none";
			
	}

	
	//+++++++++++++++++++++++++++++++++++++++++++++++++	
	
	function loadReportDetails(ec_id){   //load the individual campaign report details
	        		
		    //new Effect.Appear('indicator2'); //why does this flicker?
			//document.getElementById("indicator2").style.visibility="visible";
			//document.getElementById("indicator2_text").innerHTML ='Please wait while we load your contacts... <br /><br />';    		
			//new Effect.SlideUp('contacts');
			document.getElementById("reports_list").style.display="none";	
			
			var ajax1;		
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_details_processor.php?ec_id='+ec_id, {asynchronous:true , onComplete: new Effect.Appear('report_details'),onFailure: new showWaitWheel('report_details') , evalScripts:true} );
				
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?ec_id='+ec_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}),evalScripts:true  } );
				
	}
	
		
	function loadReportDetails_SMS(ca_id){   //load the individual campaign report details
	        		
		    //new Effect.Appear('indicator2'); //why does this flicker?
			//document.getElementById("indicator2").style.visibility="visible";
			//document.getElementById("indicator2_text").innerHTML ='Please wait while we load your report... <br /><br />';    		
			//new Effect.SlideUp('contacts');
			
			
			document.getElementById("reports_list").style.display="none";	
			
			
			var ajax1;		
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_details_sms_processor.php?ca_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details'), onFailure: new showWaitWheel('report_details'), evalScripts:true} ); //******* New onFailure
				
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}),evalScripts:true  } );
		
	}
	
	
	//+++++++++++++++++++++++++++++++++++++++++++++++++!
	
	function loadReportDetails_CustomCampaign(cr_map_id){  
	
			document.getElementById("reports_list").style.display="none";	
			
			var ajax1;		
			ajax1=new Ajax.Updater('report_details', '../processors/load_custom_report_details_processor.php?cr_map_id='+cr_map_id, {asynchronous:true , onComplete: new Effect.Appear('report_details'), onFailure: new showWaitWheel('report_details'), evalScripts:true} );
				
			var ajax2;	//load the blue action menu
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?cr_map_id='+cr_map_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}),evalScripts:true  } );
		
	}
	
	
	//+++++++++++++++++++++++++++++++++++++++++++++++++
	
	
	
	function viewOpenedReport(ec_id){   //load the log details within a Campaign Report
		
			var ajax1;		
			ajax1=new Ajax.Updater('report_logs', '../processors/load_report_opens.php?ec_id='+ec_id, {asynchronous:true , onComplete: new Effect.Appear('report_logs'), onFailure: new showWaitWheel('report_logs') ,evalScripts:true} );	
					
			new Effect.ScrollTo('report_logs');
								
	}	
	
	
	function viewLinksClickedReport(ec_id){   //load the log details within a Campaign Report
		
			var ajax1;		
			ajax1=new Ajax.Updater('report_logs', '../processors/load_report_link_tracking.php?ec_id='+ec_id, {asynchronous:true , onComplete: new Effect.Appear('report_logs'), onFailure: new showWaitWheel('report_logs') ,evalScripts:true} );	
					
			new Effect.ScrollTo('report_logs');
								
	}
	
	
	function viewLinksClickedReport_details(link_id,ec_id){   //load the log details within a Campaign Report
		
			var ajax1;		
			ajax1=new Ajax.Updater('edit_function-'+link_id, '../processors/load_report_link_tracking_details.php?ec_id='+ec_id+'&link_id='+link_id, {asynchronous:true , onComplete: new Effect.Appear('edit_function-'+link_id), onFailure: new showWaitWheel('edit_function-'+link_id) ,evalScripts:true} );	
					
			new Effect.ScrollTo('edit_function-'+link_id);
								
	}
	
	
	
	function viewUnsubReport(ec_id){   //load the log details within a Campaign Report
	        		
				var ajax1;		
			ajax1=new Ajax.Updater('report_logs', '../processors/load_report_unsub.php?ec_id='+ec_id, {asynchronous:true , onComplete: new Effect.Appear('report_logs'), onFailure: new showWaitWheel('report_logs'), evalScripts:true} );
			
					
			new Effect.ScrollTo('report_logs');
								
	}
	
	
	function viewBounceReport(ec_id){   //load the log details within a Campaign Report
	        		
		var ajax1;		
			ajax1=new Ajax.Updater('report_logs', '../processors/load_report_bounces.php?ec_id='+ec_id, {asynchronous:true , onComplete: new Effect.Appear('report_logs'),onFailure: new showWaitWheel('report_logs'), evalScripts:true} );
			
					
			new Effect.ScrollTo('report_logs');
								
	}
	
	
	
	function view_SMS_SentReport(ca_id){   //load the SMS sent log details within a SMS Campaign Report
	
			//new Effect.ScrollTo('menu_blue');
	        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_sms_sent.php?ca_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
			
			
			var ajax2;	//load the blue action menu 			
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=LogsSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
	}
	
	
	
	function view_SMS_UnsentReport(ca_id){   //load the SMS unsent log details within a SMS Campaign Report
	
			//new Effect.ScrollTo('menu_blue');
	        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_sms_unsent.php?ca_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
			
			
			var ajax2;	//load the blue action menu 			
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=LogsSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
	}
	
	
	function view_SMS_ReceivedReport(ca_id){   //load the SMS RECEIVED log details within a SMS Campaign Report
	
			//new Effect.ScrollTo('menu_blue');
	        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_sms_received.php?ca_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
		
			
			var ajax2;	//load the blue action menu , no change from "sent" type			
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=LogsSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
	}
	
	
	
	
	function view_SMS_SentReport_unsub(ca_id){   //load the master SMS unsub Report (not possible to load on per campaign basis
	        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_sms_unsub.php?ab_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
			//new Effect.ScrollTo('report_logs');
			
			var ajax2;	//load the blue action menu ***incomplete***		
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=UnsubSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
	}
	
	
	
	function view_SMS_VoteMultipleRespondents(ca_id){  
		        					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('report_details', '../processors/load_report_vote_respondents.php?ca_id='+ca_id, {asynchronous:true , onComplete: new Effect.Appear('report_details') , onFailure: new showWaitWheel('report_details'), evalScripts:true} );
			
		
			
			var ajax2;	//load the blue action menu , no change from "sent" type			
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_reports.php?type=LogsSMS&ca_id='+ca_id, {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:3}), evalScripts:true  } );
			
						
	}
	
	
	
	
		
	function viewMMGReport(ext_app_id,type){   //load the MMG SMS sent log details within a SMS Campaign Report
	        					
			var ajax1;		
			ajax1=new Ajax.Updater('report_logs', '../processors/load_mmg_report.php?ext_app_id='+ext_app_id+'&type='+type, {asynchronous:true , onComplete: new Effect.Appear('report_logs') , onFailure: new showWaitWheel('report_logs'), evalScripts:true} );
			
			new Effect.ScrollTo('report_logs');
										
	}
	
	
	
	function viewAPIReport(from_date,to_date){   //load the API  log details 2008-02-24
		        
		    new Effect.SlideUp('api_info');
		        					
			var ajax1;		
			ajax1=new Ajax.Updater('api_report', '../processors/load_report_api.php?from_date='+from_date+'&to_date='+to_date, {asynchronous:true , onComplete: new Effect.Appear('api_report') , onFailure: new showWaitWheel('api_report'), evalScripts:true} );
			
			new Effect.ScrollTo('api_report');
			
			var ajax2;	//load the blue action menu 	
			ajax2=new Ajax.Updater('event_status', '../processors/load_menu_api.php?action=logs', {asynchronous:true, onSuccess: new Effect.Appear('event_status',{duration:1}), evalScripts:true  } );
							
	}
	
	
	
	function exportCustomReport(cr_map_campaign_id){  //*** 2007-10-31. this needs to be improved to make it generic, current only exports messages received
										
			    window.location.href="../processors/export_reports_csv_processor.php?cr_map_campaign_id="+cr_map_campaign_id;
							
	}
	
	
	
	//++++++++++++++++++++++++++++++++++++++++++++
		
	function deleteCampaignReport(campaign_id){   //delete the selected campaign when clicked 
	
			var answer = confirm("Are you sure you want to delete this Email Campaign and its data?")
			if (answer){
						
				//document.getElementById("indicator2_text").innerHTML ='Please wait... <br /><br />';    
				//new Effect.Appear('indicator2');
					
				document.getElementById('report_fn1_'+campaign_id).style.display="none";
				document.getElementById('report_fn2_'+campaign_id).style.display="none";
			
				var ajax1;			
				ajax1=new Ajax.Updater('report_'+campaign_id, '../processors/delete_campaign_processor.php?campaign_id='+campaign_id, {asynchronous:true, onSuccess: new Effect.Appear('report_'+campaign_id,{duration:1}), onFailure: new showWaitWheel('report_'+campaign_id), evalScripts:true  } );
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	
		
		
	function deleteCampaignReport_SMS(campaign_id){   //delete the selected campaign when clicked 
	
			var answer = confirm("Are you sure you want to delete this SMS Campaign and its data?")
			if (answer){
						
				//document.getElementById("indicator2_text").innerHTML ='Please wait... <br /><br />';    
				//new Effect.Appear('indicator2');
				
				document.getElementById('report_fn1_'+campaign_id).style.display="none";
				document.getElementById('report_fn2_'+campaign_id).style.display="none";
			
				var ajax1;			
				ajax1=new Ajax.Updater('report_'+campaign_id, '../processors/delete_campaign_processor.php?type=SMS&campaign_id='+campaign_id, {asynchronous:true, onComplete: new Effect.Appear('report_'+campaign_id,{duration:1}),onFailure: new showWaitWheel('report_'+campaign_id), evalScripts:true  } );
				
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	
	function abortCampaign(ca_id) { //remove from Campaigns main page (does not delete data)
		
		var answer = confirm("Are you sure you want to abort this SMS Campaign? Pending messages will not be sent. ")
			
		if (answer){
						
				
				//document.getElementById('campaigns_'+ca_id).style.display="none";
			
				var ajax1;			
				ajax1=new Ajax.Updater('campaign_detail_1_'+ca_id, '../processors/abort_campaign_processor.php?ca_id='+ca_id, {asynchronous:true, onComplete: new Effect.Highlight('campaign_detail_1_'+ca_id,{duration:1}),onFailure: new showWaitWheel('campaign_detail_1_'+ca_id), evalScripts:true  } );
				
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	
	
	function removeActiveCampaign(ca_id) { //remove from Campaigns main page (does not delete data)
		
		var answer = confirm("This SMS Campaign will no longer be monitored on this page, report data can still be found on the Reports page. Continue?")
			
		if (answer){
						
				
				//document.getElementById('campaigns_'+ca_id).style.display="none";
			
				var ajax1;			
				ajax1=new Ajax.Updater('campaigns_'+ca_id, '../processors/remove_active_campaign_processor.php?ca_id='+ca_id, {asynchronous:true, onComplete: new Effect.Highlight('campaigns_'+ca_id,{duration:1}),onFailure: new showWaitWheel('campaigns_'+ca_id), evalScripts:true  } );
				
	
			}
			
			else{
				//answer=false;       
				//return answer;		
			}
	}
	
	
	
	
	
// Hiding functions--------------------------------------------
//=============================================================

	function hideIndicator2(){ //use this in processer returns to fade indicator2 whenever results load
    	
		new Effect.Fade("indicator2");
	
	}
	
	function hideContactsIndividual(){ //use this in processer returns to fade contacts_individual whenever results load
    	
		new Effect.BlindUp("contacts_individual");
		new Effect.BlindUp("add_contact");
		new Effect.BlindUp("upload_contacts");
	
	}
	
	function hideUploadContacts(){ //use this in processer returns to fade contacts_individual whenever results load
    	
		new Effect.BlindUp("upload_contacts");
		
		//document.getElementById("upload_contacts").style.display="none";	
	}
	
	
	function hideReportDetails(){ //use this in processer returns to fade contacts_individual whenever results load
    	
		//new Effect.BlindUp("report_details");
		document.getElementById("report_details").style.display="none"; //hide this again in case of back nav		
		document.getElementById("report_logs").style.display="none"; //hide this again in case of back nav

	}
	
	//-----------------------------------------------------------
	
	function clearAll(){  // set for body onload. deprecated by ajax form submit implementation
		document.campaign_step.NextStep.disabled=false;
		document.getElementById("indicator").style.visibility="hidden";		
	}
	
	function show_resetPassword(){ 
		document.getElementById('forgot_password').innerHTML="Reset Password";
	}
	
	
	

//--Submit Buttons-----------------------------------------------------------------------
//======================================================================================
	
	
		
	function submitButton_signup(){ 
	
		document.signup_form.register.disabled=true;
		document.signup_form.register.value='Please wait. . .';
		//document.getElementById("indicator").style.visibility="visible";
		
		if (validateSignup()==true) {
		
				var ajax1;			
				ajax1=new Ajax.Updater('signup_process_status','../signup/65279e1ecf00d0d1177a5b3b458fd187a1d6135e.php', {asynchronous:true,  parameters: Form.serialize('signup_form'), onSuccess: new Effect.Appear('signup_process_status',{duration:1}),onFailure: new showWaitWheel('signup_process_status'), evalScripts:true  } );
									
		}
		
		else {
			resetSignup();
			//document.signup_form.email.focus();
		}
	
	}
	
	
	function resetSignup() {
			
			document.signup_form.register.disabled=false;			
			document.signup_form.register.value='Proceed';
			
		
	}
	
	
	function submitVerification_signup() {
		
		   	document.verify_code.next.disabled=true;
		
			if (verifyCode()==true) {
			
					var ajax1;			
					ajax1=new Ajax.Updater('signup_verification_status','../signup/108be1ed80981e647b61c22993e9a42d9aca7fdc.php', {asynchronous:true,  parameters: Form.serialize('verifyCode'), onSuccess: new Effect.Appear('signup_verification_status',{duration:1}),onFailure: new showWaitWheel('signup_verification_status'), evalScripts:true  } );		
			
			}
			
			else {
				document.verify_code.next.disabled=false;
				//document.login.NextStep.value='Login';
				
			}		
		
	}
	
	//++++++++++++++++++++++++
	
	
	function submitButton(){ //for all normal pages
		document.campaign_step.NextStep.disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.campaign_step.submit();		
	}
	
	
	
	function submitButton_uploadContacts(){ 
		if ((document.getElementById("contacts_file").value=="") && (document.getElementById("skip_contacts_file").checked==false )) { //
					alert("Please select a contacts file to upload!");
					return;
		}
		
		else if (document.getElementById("group_name").value=="") { //
					alert("Please give this Group a name!");
					return;
		}
		
		else if (document.getElementById("contacts_file").value!=null){
		    loadProgressBarContacts();
			document.upload_contacts_form.NextStep.disabled=true;
			document.getElementById("indicator").style.visibility="visible";
			document.upload_contacts_form.submit();		
		}
	}
	
	
	
	function submitButton_addContact(list_id){ 
	
	if(document.getElementById("mobile_country_code").value=='' ){
  
      alert('Please enter country code!');
  
  }
  else if(document.getElementById("mobile_number").value=='' ){
  
      alert('Please enter mobile number!');
  
  }
  else if(document.getElementById("mobile_number").value.length<6 ){
  
      alert('Your mobile number is invalid!');
  
  }
  else if(document.getElementById("mobile_country_code").value != '' && document.getElementById("mobile_number").value.length >= 6){
		document.add_contact_form.NextStep.disabled=true;
		document.getElementById("indicator").style.visibility="visible";

		var ajax1;			
		ajax1=new Ajax.Updater('add_contact_status','../processors/insertcontacts_processor.php?add_contact=true&list_id='+list_id, {asynchronous:true,  parameters: Form.serialize('add_contact_form'), onSuccess: new Effect.Appear('add_contact_status',{duration:1}),onFailure: new showWaitWheel('add_contact_status'), evalScripts:true  } );		
	}
}
	
	
		
function submitButton_saveContact(contact_id){ 
	
	if(document.getElementById("contact_mobile_cc").value=='' ){
  
      alert('Please enter country code!');
  
  }
  else if(document.getElementById("contact_mobile").value=='' ){
  
      alert('Please enter mobile number!');
  
  }
  else if(document.getElementById("contact_mobile").value.length<6 ){
  
      alert('Your mobile number is invalid!');
  
  }
  else if(document.getElementById("contact_mobile_cc").value != '' && document.getElementById("contact_mobile").value.length >= 6){
	
	
		//document.'edit_contact_form-'+contact_id.NextStep.disabled=true;
		//document.getElementById("indicator_edit_contact").style.visibility="visible";
		//new Effect.Fade('edit_contact_form-'+contact_id,{duration:3});
		//document.getElementById('edit_contact_form-'+contact_id).innerHTML='<img name="indicator" src="../images/indicator3.gif" />';
		var ajax1;			
		ajax1=new Ajax.Updater('edit_contact-'+contact_id,'../processors/update_contact_processor.php?contact_id='+contact_id, {asynchronous:true,  parameters: Form.serialize('edit_contact_form-'+contact_id), onSuccess: new Effect.Appear('edit_contact-'+contact_id,{duration:3}), evalScripts:true  } );
	}	
	
}
	
	function submitButton_saveContact_cancel(contact_id){ 
		
		new Effect.SlideUp('edit_contact_form-'+contact_id);
		
		new Effect.ScrollTo('contacts');
	
	}
	
	
	
	function submitButton_searchContact(addressbook_id){ // kuo wei 2007-11-07
		
		
		if(document.getElementById("search_name").value == '' && document.getElementById("search_email").value == '' && document.getElementById("search_mobile").value == '') {
          
		  	alert("Please enter at least 1 field!");
      
      	}
       
	   else {
			  new Effect.Fade("search_contacts");
			  //document.getElementById("search_contacts").style.display="none";
		      document.search_contact_form.SearchButton.disabled=false;
		      document.search_contact_form.SearchButton.value='Searching...';
		
		      var ajax1;			
		      ajax1=new Ajax.Updater('contacts_individual','../processors/searchcontacts_processor.php?addressbook_id='+addressbook_id, {asynchronous:true,  parameters: Form.serialize('search_contact_form'), onSuccess: new Effect.Appear('contacts_individual',{duration:1}), onFailure: new showWaitWheel('contacts_individual'), evalScripts:true  } );		
		      
		      document.getElementById("contacts").style.display="none";
	   }
	}
	
	
	/*
	function submitLogin(){ //for login page
		document.login.NextStep.disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.login.NextStep.value='Verifying...';
		if (checkForm()==true) {
		 	document.login.submit();	
			//alert('True!');
		}
		else {
			document.login.NextStep.disabled=false;
			document.getElementById("indicator").style.visibility="hidden";	
			document.login.NextStep.value='Login';
		}
	}
	*/
	
	//------------------------------
	
	function submitLogin(){ //for login page
		document.login.NextStep.disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.login.NextStep.value='Verifying...';
			
		if (checkForm()==true) {
		 	//document.login.submit();	
			//alert('True!');
			
			//document.getElementById("event_status").style.visibility="hidden";	
				
			var ajax1;			
			ajax1=new Ajax.Updater('event_status', '../processors/login_processor-x.php', {asynchronous:true, parameters: Form.serialize('login'), onSuccess: new Effect.Appear('event_status'), evalScripts:true  } ); 

			//new Effect.Shake("event_status"); //necessary especially for repeated attempts
	
		}
		else {
			document.login.NextStep.disabled=false;
			document.getElementById("indicator").style.visibility="hidden";	
			document.login.NextStep.value='Login';
		}
	}
	
	
	function clearLogin(){			
			document.login.NextStep.disabled=false;
			document.getElementById("indicator").style.visibility="hidden";
			document.login.NextStep.value='Login';
	}
	
	
	//--------------------------------------------------------------------------------------
	
	function showError() {
		
			//document.getElementById("event_status").innerHTML = error ;
			new Effect.Appear("event_status"); 
			
	}

	
	
	
	
//CAMPAIGN MANAGEMENT========================================================================================
//---------------------------------------------------------------------------------------


	function setSMSCampaignName_Date(datetime) {   //sets current date/time for SMS campaign name

		document.campaign_sms.ca_sms_name.value= datetime ;
		new Effect.Highlight('ca_sms_name');
		
	}
	
	
	function setCampaignName_Date(datetime) {   //sets current date/time for Email campaign name

		document.campaign.ca_name.value= datetime ;
		new Effect.Highlight('ca_name');
		
	}
	
	
	function checkEmailSyntax(){
		var x = document.campaign2.ca_from_email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {	
			document.campaign2.ca_reply_to.value=document.campaign2.ca_from_email.value;
			new Effect.Highlight('reply_to');		
		}
		else {
			alert('The From email address you entered seems to be of incorrect format. Please try again!');
			document.campaign2.ca_from_email.focus();			
		}
	}
	
		
	function checkEmailSyntax_2(){
		var x = document.campaign2.ca_reply_to.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {	
		
			return true;
		
		}
		else {
			alert('The Reply-to email address you entered seems to be of incorrect format. Please try again!');
			document.campaign2.ca_reply_to.focus();		
			return false;
		}
	}



	
	//-------------------------------------------------
	
	function submitCampaign(){ //submits campaign step 1
	
		document.campaign.campaignNext.disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.campaign.campaignNext.value=='Please wait...';
		
		var campaignName=document.campaign.ca_name.value;
		//alert(campaignName);	
			
		if (checkCampaign1()==true) {
			//alert('True!');
			new Effect.SlideUp('campaign')
			
			var ajax1;			
			ajax1=new Ajax.Updater('campaign2', '../processors/campaign_processor?step=1', {asynchronous:true, parameters: Form.serialize('campaign'), onComplete: new Effect.Appear('campaign2'),onFailure: new showWaitWheel('campaign2'), evalScripts:true  } ); 
			
			//new Effect.Highlight("event_status");		

		}
		else {
			document.campaign.campaignNext.disabled=false;
			document.getElementById("indicator").style.visibility="hidden";	
			document.campaign.campaignNext.value='Next';
		}
	}
	
	
	
	//------------------------
	
	
	function submitCampaign2(){ //submits campaign step 2
	
	
		document.campaign2.campaign2Next.disabled=true;
		document.getElementById("indicator_c2").style.visibility="visible";
		document.campaign2.campaign2Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		if (checkCampaign2()==true) {
			//alert('True!');
			new Effect.SlideUp('campaign2')
			
			var ajax1;			
			ajax1=new Ajax.Updater('campaign3', '../forms/campaign_upload_form.php', {asynchronous:true, parameters: Form.serialize('campaign2'), onComplete: new Effect.Appear('campaign3'), onFailure: new showWaitWheel('campaign3'),evalScripts:true  } ); 			
			//new Effect.Highlight("event_status");		

		}
		
		else {
			document.campaign2.campaign2Next.disabled=false;
			document.getElementById("indicator_c2").style.visibility="hidden";	
			document.campaign2.campaign2Next.value='Next';
		}
	}
	
	
	
	function submitCampaign3(){ //submits campaign step 3
	
		document.campaign3.campaign3Next.disabled=true;
		document.getElementById("indicator_c3").style.visibility="visible";
		document.campaign3.campaign3Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		if (checkCampaign3()==true) {
			//alert('True!');		
			//document.getElementById("indicator2").style.visibility="visible";//doesn't work?
			document.campaign3.submit();	
		}
		
		else {
			document.campaign3.campaign3Next.disabled=false;
			document.getElementById("indicator_c3").style.visibility="hidden";	
			document.campaign3.campaign3Next.value='Next';
			
		}
	}
	
	
	function submitCampaign4(){ //submits campaign step 4, final step
	
			document.campaign4.campaign4Next.disabled=true;
			document.getElementById("indicator_c4").style.visibility="visible";
			document.campaign4.campaign4Next.value=='Please wait...';
		
			if (checkCampaign4()==true) {
				//alert('True!');
				new Effect.SlideUp('final_step')
				
				var ajax1;			
				ajax1=new Ajax.Updater('campaign4_result', '../processors/campaign_processor?step=final', {asynchronous:true, parameters: Form.serialize('campaign4'), onComplete: new Effect.Appear('campaign4_result'), onFailure: new showWaitWheel('campaign4_result'),evalScripts:true  } ); 
				
			}
			
			else {
				document.campaign4.campaign4Next.disabled=false;
				document.getElementById("indicator_c4").style.visibility="hidden";	
				document.campaign4.campaign4Next.value='Next';
			}
			
			
	}
	

/*############################## KW 20071102    Modify Start From Here                #################################################*/

	/* PENDING ACTIVATION ----------------
	
	function submitCampaign(){ //submits campaign step 1
	
		document.campaign.campaignNext.disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.campaign.campaignNext.value=='Please wait...';
		
		var campaignName=document.campaign.ca_name.value;
		//alert(campaignName);	
			
		if (checkCampaign1()==true) {
			//alert('True!');
			new Effect.SlideUp('campaign')
			
			var ajax1;			
			ajax1=new Ajax.Updater('campaign2', '../processors/campaign_processor.php?step=1', {asynchronous:true, parameters: Form.serialize('campaign'), onComplete: new Effect.Appear('campaign2'),onFailure: new showWaitWheel('campaign2'), evalScripts:true  } ); 
			
			//new Effect.Highlight("event_status");		

		}
		else {
			document.campaign.campaignNext.disabled=false;
			document.getElementById("indicator").style.visibility="hidden";	
			document.campaign.campaignNext.value='Next';
		}
	}
	//---
	function submitCampaign2(){ //submits campaign step 2(select upload html file or edit the file)
	
	  document.campaign2.campaign2Next.disabled=true;
		document.getElementById("indicator_c2").style.visibility="visible";
		document.campaign2.campaign2Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		if (checkCampaign2()==true) {
			//alert('True!');
			new Effect.SlideUp('campaign2')
			
			var ajax1;			
			ajax1=new Ajax.Updater('campaign3', '../processors/campaign_processor.php?step=2', {asynchronous:true, parameters: Form.serialize('campaign2'), onComplete: new Effect.Appear('campaign3'), onFailure: new showWaitWheel('campaign3'),evalScripts:true  } ); 			
			//new Effect.Highlight("event_status");		

		}
		
		else {
			document.campaign2.campaign2Next.disabled=false;
			document.getElementById("indicator_c2").style.visibility="hidden";	
			document.campaign2.campaign2Next.value='Next';
		}
	}
	
	//------------------------
	
	
	function submitCampaign3(){ //submits campaign step 3
	
	
		document.campaign3.campaign3Next.disabled=true;
		document.getElementById("indicator_c3").style.visibility="visible";
		document.campaign3.campaign3Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		//if (checkCampaign3()==true) {
			//alert('True!');
			   new Effect.SlideUp('campaign3')
			   if(document.getElementById("upload_file").checked)
			   {
			          var ajax1;			
			          ajax1=new Ajax.Updater('campaign4', '../forms/campaign_upload_form.php', {asynchronous:true, parameters: Form.serialize('campaign3'), onComplete: new Effect.Appear('campaign4'), onFailure: new showWaitWheel('campaign4'),evalScripts:true  } ); 			
			         //new Effect.Highlight("event_status");		
         }
         if(document.getElementById("write_file").checked)
			   {
  			      
             // var ajax1;			
			 //       ajax1=new Ajax.Updater('campaign4', '../forms/htmleditor_form.php', {asynchronous:true, parameters: Form.serialize('campaign3'), onComplete: new Effect.Appear('campaign4'), onFailure: new showWaitWheel('campaign4'),evalScripts:true  } ); 			
            
            window.location.href="../app/campaign-htmleditor.php";
             
			   
        }
	//	}
		
		else {
			document.campaign3.campaign3Next.disabled=false;
			document.getElementById("indicator_c3").style.visibility="hidden";	
			document.campaign3.campaign3Next.value='Next';
		}
	}
	
	
	
	function submitCampaign4_1(){ //submits campaign step 4 (check upload file)
	
		document.campaign4.campaign4Next.disabled=true;
		document.getElementById("indicator_c4").style.visibility="visible";
		document.campaign4.campaign4Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		if (checkCampaign4_1()== true) {
			//alert('True!');		
			//document.getElementById("indicator2").style.visibility="visible";//doesn't work?
			document.campaign4.submit();	
		}
			
		else {
			document.campaign4.campaign4Next.disabled=false;
			document.getElementById("indicator_c4").style.visibility="hidden";	
			document.campaign4.campaign4Next.value='Next';
			
		}
	}
	
	function submitCampaign4_2(){ //submits campaign step 4  (check write file)
	
		document.campaign4.campaign4Next.disabled=true;
		document.getElementById("indicator_c4").style.visibility="visible";
		document.campaign4.campaign4Next.value=='Please wait...';
		
		//alert(campaignName);	
			
		if (checkCampaign4_2()== true) {
			   //alert('True!');		
			   //document.getElementById("indicator2").style.visibility="visible";//doesn't work?
			   //new Effect.SlideUp('campaign4')
			   //var ajax1;			
			   //ajax1=new Ajax.Updater('campaign5', '../app/campaign-recipients.php', {asynchronous:true, parameters: Form.serialize('campaign4'), onComplete: new Effect.Appear('campaign5'), onFailure: new showWaitWheel('campaign5'),evalScripts:true  } ); 			
			   //new Effect.Highlight("event_status");
         //document.campaign4.submit();		
         window.location.href="../app/campaign-recipients.php";
		}
		
		else {
			document.campaign4.campaign4Next.disabled=false;
			document.getElementById("indicator_c4").style.visibility="hidden";	
			document.campaign4.campaign4Next.value='Next';
			
		}
	}
	
	
	function submitCampaign5(){ //submits campaign step 5, final step
	
			document.campaign5.campaign5Next.disabled=true;
			document.getElementById("indicator_c5").style.visibility="visible";
			document.campaign5.campaign5Next.value=='Please wait...';
		
			if (checkCampaign5()==true) {
				//alert('True!');
				new Effect.SlideUp('final_step')
				
				var ajax1;			
				ajax1=new Ajax.Updater('campaign5_result', '../processors/campaign_processor.php?step=final', {asynchronous:true, parameters: Form.serialize('campaign5'), onComplete: new Effect.Appear('campaign5_result'), onFailure: new showWaitWheel('campaign5_result'),evalScripts:true  } ); 
				
			}
			
			else {
				document.campaign5.campaign5Next.disabled=false;
				document.getElementById("indicator_c5").style.visibility="hidden";	
				document.campaign5.campaign5Next.value='Next';
			}
			
			
	}
	
*/
/*##############################   KW 20071102  Modify Ends Here                #################################################*/	



   function showCampaignAdvancedOptions() {
   
   
   			new Effect.Appear('campaign_advanced_options');
   
   
   }





	function submitCampaignSMS(type){ //submits SMS campaign 
	        
	        //new Effect.SwitchOff('scroller');
			//document.getElementById("RightArrow").style.display="none";	
			//alert("Type is"+type);
			
			document.campaign_sms.campaign_SMS_submit.disabled=true;
			document.getElementById("indicator").style.visibility="visible";
			document.campaign_sms.campaign_SMS_submit.value=='Please wait...';
		
			if (checkCampaignSMS(type)==true) {
				//alert('All Checks True! Sending now...');
				//new Effect.Fade('campaign_sms')
				document.getElementById("campaign_sms").style.display="none";
				
				var ajax1;			
				ajax1=new Ajax.Updater('campaign_sms_result', '../processors/sms_processor.php', {asynchronous:true, parameters: Form.serialize('campaign_sms'), onComplete: new Effect.Appear('campaign_sms_result'), onFailure: new showWaitWheel('campaign_sms_result'), evalScripts:true  } ); 
				
			}
			
			else {
				//alert("Something is wrong, Campaign Validation failed, please contact customer support ...");
				document.campaign_sms.campaign_SMS_submit.disabled=false;
				document.getElementById("indicator").style.visibility="hidden";	
				document.campaign_sms.campaign_SMS_submit.value='Start Campaign';
			}
			
			
	}
	
	
	
	
	function loadCampaignDetails(ca_id,ca_status,mode) {
	
			var ajax1;			
		
			ajax1=new Ajax.Updater('campaign_detail_'+ca_id, '../processors/load_campaign_detail_processor.php?ca_id='+ca_id+'&ca_status='+ca_status+'&show_details1='+mode, {asynchronous:true, onComplete: new Effect.Appear('campaign_detail_'+ca_id), evalScripts:true  } ); 
			
			//new Effect.ScrollTo('campaign_detail_1_'+ca_id);
			//overscroll problem on IE6 for this	
	
	}
	
	function hideCampaignDetails(ca_id) {
	
			new Effect.SlideUp('campaign_detail_'+ca_id); 
	
	}
	

	
	
	//-------------------------------------------------------------------------------------------
	///QUICK SEND FUNCTIONS-----------------------------------
	
	/*
	function submitQuickSendSMS(){ //submits QuickSend
	
			//new Effect.Fade('quicksend_sms_result');
	
			document.quicksend.quicksend_SMS_submit.disabled=true;
			document.getElementById("indicator").style.visibility="visible";
			document.quicksend.quicksend_SMS_submit.value=='Please wait...';
		
			if (checkQuickSend()==true) {
				//alert('True!');
			
				var ajax1;			
				ajax1=new Ajax.Updater('quicksend_sms_result', '../processors/sms_processor_quicksend.php', {asynchronous:true, parameters: Form.serialize('quicksend'), onComplete: new Effect.Appear('quicksend_sms_result'), evalScripts:true  } ); 
				
			}
			
			else {
				document.quicksend.quicksend_SMS_submit.disabled=false;
				document.getElementById("indicator").style.visibility="hidden";	
				document.quicksend.quicksend_SMS_submit.value='Send';
			}
			
			
	} */
	
	
	
	function submitQuickSendSMS(){ //submits QuickSend
	
			//new Effect.Fade('quicksend_sms_result');
	
			document.quicksend.quicksend_SMS_submit.disabled=true;
			document.getElementById("indicator").style.visibility="visible";
			document.quicksend.quicksend_SMS_submit.value=='Please wait...';
			
			
			if (document.quicksend.qs_sms_messagebody.value == "") {
					
          			alert("Please enter a Message to be sent!");
					document.quicksend.qs_sms_messagebody.focus();
					document.quicksend.quicksend_SMS_submit.disabled=false;
				    document.getElementById("indicator").style.visibility="hidden";	
				    document.quicksend.quicksend_SMS_submit.value='Send';
				    
				    return;
			}
		  
			if (document.quicksend.mobile_numbers.value == ""  && document.getElementById('quicksend_sms_recipients_drag').innerHTML == '' || document.quicksend.mobile_numbers.value == 'Enter Mobile Numbers' && document.getElementById('quicksend_sms_recipients_drag').innerHTML == '' || document.quicksend.mobile_numbers.value == 'Enter Mobile Numbers' && document.getElementById('secondlist').innerHTML == '' || document.quicksend.mobile_numbers.value == '' && document.getElementById('secondlist').innerHTML == '') {
			//if (document.quicksend.mobile_numbers.value == "" && document.getElementById('recipients').innerHTML == "") {
		
					
          			alert("Please enter at least 1 Mobile Number");
					document.quicksend.mobile_numbers.focus();
					document.quicksend.quicksend_SMS_submit.disabled=false;
				      document.getElementById("indicator").style.visibility="hidden";	
				      document.quicksend.quicksend_SMS_submit.value='Send';
				    
				      return;
			}
			
			
			
			if (document.quicksend.mobile_numbers.value != 'Enter Mobile Numbers' && document.quicksend.mobile_numbers.value != '' && !validateQuickSendMsisdn())  {
			
					alert("Your Mobile Numbers entered should contain only numbers, each number should be in a newline. Please try again!");
					document.quicksend.mobile_numbers.focus();
					document.quicksend.quicksend_SMS_submit.disabled=false;
				       document.getElementById("indicator").style.visibility="hidden";	
				       document.quicksend.quicksend_SMS_submit.value='Send';
				    
				      return;
			}
			
			//}
			
			else {
					
				  var ajax1;			
				  ajax1=new Ajax.Updater('quicksend_sms_result', '../processors/sms_processor_quicksend.php', {asynchronous:true, parameters: Form.serialize('quicksend'), onComplete: new Effect.Appear('quicksend_sms_result'), evalScripts:true  } ); 
				  if(document.getElementById('select_sms_list').value != 'NONE'){

              					display_recipients('NONE');
          			  }
          			  document.getElementById('select_sms_list').value='NONE';
          			  document.quicksend.mobile_numbers.value = 'Enter Mobile Numbers';
				 				
			}
			
			
	}
	
	
	
	function resetQuickSendSMS(){
				new Effect.ScrollTo('quicksend_sms_result');
				document.quicksend.quicksend_SMS_submit.disabled=false;
				document.getElementById("indicator").style.visibility="hidden";	
				document.quicksend.quicksend_SMS_submit.value='Send Again';	
				
				document.quicksend.mobile_numbers.value ='';
				document.quicksend.qs_sms_messagebody.value ='';
				
				document.quicksend.mobile_numbers.value='Enter Mobile Numbers';

	}
	
	
	
	function initQuickSend(list_id){  // shows sms_recipients_group pull-down menu for selection on body onload
	    
      		//new Effect.Appear('quicksend_sms_recipients_group'); 
      	
			var ajax1;			
			ajax1=new Ajax.Updater('quicksend_sms_recipients_group', '../processors/load_quicksend_groups_processor.php?list_id='+list_id, {asynchronous:true, method:'POST', onSuccess: new Effect.Appear('quicksend_sms_recipients_group',{duration:1}),onFailure: new showWaitWheel('quicksend_sms_recipients_group'), evalScripts:true  } );
	
	}
	
	/*
	function loadQuicksendSmsRecipients(list_id){   //by KuoWei: load the individual numbers into the left list for selection 
	   
	   		//new Effect.Appear('quicksend_sms_recipients_contents'); 
			//new Effect.Appear('recipients');
		 	
		 	var ajax1;
			ajax1=new Ajax.Updater('quicksend_sms_recipients_contents', '../processors/load_quicksend_groups_contents_processor.php?list_id='+list_id, {asynchronous:true, onFailure: new showWaitWheel('quicksend_sms_recipients_contents'), evalScripts:true} );
	
	} */

	function loadQuicksendSmsRecipients(){   //load the individual contacts in a group when clicked 
	    //new Effect.Appear('quicksend_sms_recipients_group'); 
			new Effect.Appear('quicksend_sms_recipients_contents'); //new
			new Effect.Appear('recipients');
			
			
			//Add by Kuo Wei on 2-1-2008 start
			var selected_option=document.getElementById("select_sms_list").selectedIndex;
			var list_id=document.getElementById("select_sms_list").options[selected_option].value;
			//Add by Kuo Wei on 2-1-2008end
		  var ajax1;		
			
			ajax1=new Ajax.Updater('quicksend_sms_recipients_contents', '../processors/load_quicksend_groups_contents_processor.php?list_id='+list_id, {asynchronous:true, onFailure: new showWaitWheel('quicksend_sms_recipients_contents'), evalScripts:true} );
	
	}
			
			
			
	function view_SMS_Quicksend_Report(from_date,to_date){   //load the SMS sent log details within a SMS Campaign Report
	
			//new Effect.ScrollTo('menu_blue');
	    new Effect.SlideUp('quicksend_main');
       					
			var ajax1;		
			//changed from report_logs to report_details
			ajax1=new Ajax.Updater('quicksend_sms_menu', '../processors/load_quicksend_sms_menu.php', {asynchronous:true , onComplete: new Effect.Appear('quicksend_sms_menu') , onFailure: new showWaitWheel('quicksend_sms_menu'), evalScripts:true} );

			 var ajax2;		
					//changed from report_logs to report_details
			 ajax1=new Ajax.Updater('quicksend_sms_report', '../processors/load_quicksend_sms_report.php?from_date='+from_date+'&to_date='+to_date, {asynchronous:true , onComplete: new Effect.Appear('quicksend_sms_report') , onFailure: new showWaitWheel('quicksend_sms_report'), evalScripts:true} );
		}			
				
	function backToQuicksend()	{
	
		  new Effect.SlideUp('quicksend_sms_menu');
		  new Effect.SlideUp('quicksend_sms_report');
		  new Effect.SlideDown('quicksend_main');
			  
	}		


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

	
	
	function nextPage(){ //for campaign step 4, insert validated contacts
		document.getElementById("NextStep").disabled=true;
		document.getElementById("indicator").style.visibility="visible";
		document.getElementById("indicator2_text").innerHTML ='Please wait while we finalize your campaign setup ...<br /><br />';    
		//document.getElementById("indicator2").style.visibility="visible"; 
		new Effect.Appear('indicator2');
			
		new Effect.Fade(document.getElementById('contacts_result'));

		//location.href="campaign-step5.php";	
	}
	
	
	function loadProgressBarImages(){ //need to subsume/consolidate this
		document.getElementById("upload_images").style.visibility="hidden";
		document.getElementById("indicator2").style.visibility="visible";		
	}	
	
	
	function loadProgressBar(){
		
		new Effect.Appear('indicator2');
		
	}	
	
	
	function loadProgressBarContacts(){
	    //document.getElementById("indicator2_image").style.visibility="visible";
		//new Effect.Appear(document.getElementById('indicator2_image'));
		
		document.getElementById("indicator2_text").innerHTML ='Please wait while we check your list...<br />'; 
		//document.getElementById("indicator2").style.visibility="visible";
		new Effect.Appear('indicator2');
		//new Effect.BlindDown(document.getElementById('indicator2'));
		
		//document.getElementById("upload_contacts").style.visibility="hidden";
		//new Effect.Fade(document.getElementById('contacts_result'));
		
	}	

	
	
//------------------------------------------
var AjaxReq;

	function showContactsUploadResults(){
		//document.getElementById("upload_contacts").style.visibility="hidden";
		//document.getElementById("indicator2").style.visibility="hidden";
		//document.getElementById("continue_upload").style.visibility="visible";
		
		 if (typeof window.ActiveXObject != 'undefined' )  {
				AjaxReq = new ActiveXObject("Microsoft.XMLHTTP");
				AjaxReq.onreadystatechange = getResults;
		  }
		  
		  else {
			AjaxReq = new XMLHttpRequest();			
		    AjaxReq.onload = getResults;
		  }
		  
		  try { 
			AjaxReq.open( 'GET', '../processors/show_contacts_result.php', true );
		  } 
		  
		  catch( e ) {
			alert( e );
		  }
		  AjaxReq.send("");
	}	
	
	function getResults() {
	
	  if ( AjaxReq.readyState == 4 && AjaxReq.status == 200 ) {
	  
		var rows = eval('('+AjaxReq.responseText+')' );
		
		//alert('There are '+rows.contacts_result.length+' results!');

		var html = "<br /><b>The following email addresses has problems</b><br /><br /><table width='100%'><tr bgcolor='#D8D8D8'><td>Email Address</td></tr>";
		

		var r= rows.contacts_result.length;	
		for(var i=0; i<rows.contacts_result.length; i++) {
			 
			html += "<tr>";
			html += "<td>"+rows.contacts_result[i].email+"</td>";
			//html += "<td>"+rows.contacts_result[i].desc+"</td>";
			html += "</tr>";
		}
		html += "</table>";
		html += "<br /><p> These email address will not be uploaded, the rest will be created as members of a new Contact Group. </p>";
		html += '<div align="right"><br /><input  id="NextStep"  name="Next" type="button"  value="Next" onClick="nextPage()"/><div id="indicator" style="visibility:hidden"><img name="indicator" src="../images/indicator3.gif" /></div></div>';
	
		document.getElementById( "contacts_result" ).innerHTML = html;
		
	  }
	}
	
//------------------------------------------


	function insertContacts() {
	
	  if ( AjaxReq.readyState == 4 && AjaxReq.status == 200 ) {
	  
		var rows = eval('('+AjaxReq.responseText+')' );
		
		//alert('There are '+rows.contacts_result.length+' results!');

		var html = "<br /><b>The following email addresses has problems</b><br /><br /><table width='100%'><tr bgcolor='#D8D8D8'><td>Email Address</td></tr>";
		

		var r= rows.contacts_result.length;	
		for(var i=0; i<rows.contacts_result.length; i++) {
			 
			html += "<tr>";
			html += "<td>"+rows.contacts_result[i].email+"</td>";
			//html += "<td>"+rows.contacts_result[i].desc+"</td>";
			html += "</tr>";
		}
		html += "</table>";
		html += "<br /><p> These email address will not be uploaded, the rest will be created as members of a new Contact Group. </p>";
		html += '<div align="right"><br /> <form><input  id="NextStep"  name="Next" type="button"  value="Next" onClick="nextPage()"/><div id="indicator" style="visibility:hidden"><img name="indicator" src="../images/indicator3.gif" /></div></form></div>';
	
		document.getElementById( "contacts_result" ).innerHTML = html;
		
	  }
	}


//-----------------------
function initReportsPie(){ 
			 
			//new Effect.Appear('dash_col-A');
	
			var ajax1;			
			ajax1=new Ajax.Updater('flashcontent', '../processors/get_piegraph_processor.php', {asynchronous:true, onSuccess: new Effect.Appear('flashcontent',{duration:1}),onFailure: new showWaitWheel('flashcontent'),evalScripts:true } );
			
			
	}
	

///-----Side Scroller-------------
  
function MoveLeft() {
	
	var page=document.getElementById("Page");	
	if (page.value == 1) return;
	
    new Effect.MoveBy('scroll_area', 0, 450 , 
                              {
                                  duration: 0.4,  
                                  transition: Effect.Transitions.sinoidal,
								  queue: 'end'
                              });
                              
   var val = parseInt(page.value) - 1;
   page.value = val;
   
       
   if (page.value==3) {
		document.getElementById("info").style.display="none";
		//document.getElementById("recipients").style.display="visible";
		new Effect.Appear('recipients');
   }
	
   if (page.value!=3) {
		document.getElementById("recipients",{duration:0.2}).style.display="none";
   }
   
   
}

function MoveRight() {

	var page=document.getElementById("Page");	
	var maxPage=document.getElementById("MaxPage");
	
	
	if (page.value == maxPage.value ) return;
	

    new Effect.MoveBy('scroll_area', 0, -450 , 
                              {
                                  duration: 0.4,  
                                  transition: Effect.Transitions.sinoidal,
								  queue: 'end'
                              });
    var val = parseInt(page.value) + 1;
    page.value = val;
    
    if (page.value==3) {
		document.getElementById("info").style.display="none";
		//document.getElementById("recipients").style.display="visible";
		new Effect.Appear('recipients',{duration:0.2});
	}
	
	if (page.value!=3) {
		document.getElementById("recipients").style.display="none";
    }
}

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


function togglePullCampaign() { //sets broadcast related pages to not appear, set keyword page to appear
   
   
	if (document.getElementById("PullCampaign").value=="false") { //initially not set
			
			//alert("Creating Pull Campaign");
			document.getElementById("PullCampaign").value="true";
			document.getElementById("campaign_sms_main_message").style.display="none";
			document.getElementById("campaign_sms_recepients").style.display="none";
			
			//set broadcast_required to 1
			document.getElementById("ca_bcast_required").value="0"; 
			
			//set keyword page display to display
			//document.getElementById("campaign_keyword").style.display="";
						
			var maxPage=document.getElementById("MaxPage");
			maxPage.value=maxPage.value-2;
	}
	
	else if (document.getElementById("PullCampaign").value=="true")	{ //toggle back to Push Campaign , 
			
			//alert("Creating Push Campaign");
			document.getElementById("PullCampaign").value="false";
			document.getElementById("campaign_sms_main_message").style.display="";
			document.getElementById("campaign_sms_recepients").style.display="";
			
			//set broadcast_required to 0
			document.getElementById("ca_bcast_required").value="1"; 
			//alert (document.getElementById("ca_bcast_required").value);
						
			var maxPage=document.getElementById("MaxPage");
			maxPage.value=maxPage.value+1; //!!max page value has a problem here!
	}
}

function togglePullCampaignContest() { //for contest only, due to its keyword nature
   
   
	if (document.getElementById("PullCampaign").value=="false") { //initially not set
			
			//alert("Creating Pull Contest Campaign");
			document.getElementById("PullCampaign").value="true";
			document.getElementById("campaign_sms_main_message").style.display="none";
			document.getElementById("campaign_sms_recepients").style.display="none";
			
			//set broadcast_required to 1
			document.getElementById("ca_bcast_required").value="1"; 
			
			//set keyword page display to display
			document.getElementById("campaign_keyword").style.display="";
						
			var maxPage=document.getElementById("MaxPage");
			maxPage.value=maxPage.value-1;
	}
	
	else if (document.getElementById("PullCampaign").value=="true")	{ //toggle back to Push Campaign , 
			
			//alert("Creating Push Campaign");
			document.getElementById("PullCampaign").value="false";
			document.getElementById("campaign_sms_main_message").style.display="";
			document.getElementById("campaign_sms_recepients").style.display="";
			
			//set broadcast_required to 0
			document.getElementById("ca_bcast_required").value="0"; 
			
			//set keyword page display to none
			document.getElementById("campaign_keyword").style.display="none";
			
						
			var maxPage=document.getElementById("MaxPage");
			maxPage.value=maxPage.value+1; //!!max page value has a problem here!
	}
}



//---------------------------------
//Contest Campaign

function  setContestSubtype() {

		var maxPage=document.getElementById("MaxPage");
			    
		var subtype=document.getElementById("contest_type").selectedIndex;
		//alert ("Subtype is"+subtype);
		
		switch (subtype) {
		
			case 1: //
				showallContestSubtype();
				//document.getElementById("campaign_contest_options2").style.display="none";
				document.getElementById("campaign_contest_options3").style.display="none";
				document.getElementById("campaign_auto_respond_2").style.display="none";
				
			    maxPage.value=maxPage.value-2;
				
				break;
				
			case 2:
				showallContestSubtype();
				document.getElementById("campaign_contest_options3").style.display="none";
				document.getElementById("campaign_auto_respond_3").style.display="none";
				
			    maxPage.value=maxPage.value-2;
							    
			    break;
				
			case 3:
			    showallContestSubtype();
				//document.getElementById("campaign_contest_options2").style.display="none";
				document.getElementById("campaign_auto_respond_2").style.display="none";
				
				maxPage.value=maxPage.value-1;
				
				
				break;
				
			case 4:
				//do nothing! All options in!
				showallContestSubtype();
				break;
		
		}


}


function  showallContestSubtype() {

			document.getElementById("campaign_contest_options2").style.display="";
			document.getElementById("campaign_contest_options3").style.display="";
			document.getElementById("campaign_auto_respond_2").style.display="";
			document.getElementById("campaign_auto_respond_3").style.display="";
			
}

function  addContestAnswer() {

		var contest_correct_answers_qty=document.getElementById("contest_correct_answers_qty");	
		
		
		if  (document.getElementById("contest_correct_answer2").style.display=="none") {
				document.getElementById("contest_correct_answer2").style.display="";
				
				var val = parseInt(contest_correct_answers_qty.value) + 1;
    			contest_correct_answers_qty.value = val;
    			
				return;
		}
		
		else if  (document.getElementById("contest_correct_answer3").style.display=="none"){
				document.getElementById("contest_correct_answer3").style.display="";
				
				var val = parseInt(contest_correct_answers_qty.value) + 1;
    			contest_correct_answers_qty.value = val;
    			
				return;
		}
		else if  (document.getElementById("contest_correct_answer4").style.display=="none"){
				document.getElementById("contest_correct_answer4").style.display="";
				
				var val = parseInt(contest_correct_answers_qty.value) + 1;
    			contest_correct_answers_qty.value = val;
    			
				return;
		}
		else if  (document.getElementById("contest_correct_answer5").style.display=="none"){
				document.getElementById("contest_correct_answer5").style.display="";
				
				var val = parseInt(contest_correct_answers_qty.value) + 1;
    			contest_correct_answers_qty.value = val;
    			
				return;
		}
		
			
}

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

//Vote Campaign

function  addVoteChoice() { //vote_choice_qty

		var vote_choice_qty=document.getElementById("vote_choice_qty");	
		
		
		if  (document.getElementById("choiceB").style.display=="none") {
				document.getElementById("choiceB").style.display="";
				
				var val = parseInt(vote_choice_qty.value) + 1;
    			vote_choice_qty.value = val;
    			
				return;
		}
		
		else if  (document.getElementById("choiceC").style.display=="none"){
				document.getElementById("choiceC").style.display="";
				
				var val = parseInt(vote_choice_qty.value) + 1;
    			vote_choice_qty.value = val;
    		
				return;
		}
		else if  (document.getElementById("choiceD").style.display=="none"){
				document.getElementById("choiceD").style.display="";
								
				var val = parseInt(vote_choice_qty.value) + 1;
    			vote_choice_qty.value = val;
    			
				return;
		}
		else if  (document.getElementById("choiceE").style.display=="none"){
				document.getElementById("choiceE").style.display="";
				
				var val = parseInt(vote_choice_qty.value) + 1;
    			vote_choice_qty.value = val;
    			
				return;
		}
		
			
}

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

//Survey Campaign

function  addSurveyQuestion() {

		var survey_questions_qty=document.getElementById("survey_questions_qty");	
		
		
		if  (document.getElementById("SurveyQuestion2").style.display=="none") {
				document.getElementById("SurveyQuestion2").style.display="";
				
				var val = parseInt(survey_questions_qty.value) + 1;
    			survey_questions_qty.value = val;
    			//alert(quiz_questions_qty.value);
				
				return;
		}
		
		else if  (document.getElementById("SurveyQuestion3").style.display=="none"){
				document.getElementById("SurveyQuestion3").style.display="";
				
				var val = parseInt(survey_questions_qty.value) + 1;
    			survey_questions_qty.value = val;
			
				
				return;
		}
		else if  (document.getElementById("SurveyQuestion4").style.display=="none"){
				document.getElementById("SurveyQuestion4").style.display="";
				
				var val = parseInt(survey_questions_qty.value) + 1;
    			survey_questions_qty.value = val;
				
				return;
		}
		else if  (document.getElementById("SurveyQuestion5").style.display=="none"){
				document.getElementById("SurveyQuestion5").style.display="";
				
				var val = parseInt(survey_questions_qty.value) + 1;
    			survey_questions_qty.value = val;
				//alert(quiz_questions_qty.value);
				
				return;
		}
		
}

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

//Quiz Campaign

function  addQuizQuestion() {

		var quiz_questions_qty=document.getElementById("quiz_questions_qty");	
		
		
		if  (document.getElementById("QuizQuestion2").style.display=="none") {
				document.getElementById("QuizQuestion2").style.display="";
				
				var val = parseInt(quiz_questions_qty.value) + 1;
    			quiz_questions_qty.value = val;
    			//alert(quiz_questions_qty.value);
				
				return;
		}
		
		else if  (document.getElementById("QuizQuestion3").style.display=="none"){
				document.getElementById("QuizQuestion3").style.display="";
				
				var val = parseInt(quiz_questions_qty.value) + 1;
    			quiz_questions_qty.value = val;
			
				
				return;
		}
		else if  (document.getElementById("QuizQuestion4").style.display=="none"){
				document.getElementById("QuizQuestion4").style.display="";
				
				var val = parseInt(quiz_questions_qty.value) + 1;
    			quiz_questions_qty.value = val;
				
				return;
		}
		else if  (document.getElementById("QuizQuestion5").style.display=="none"){
				document.getElementById("QuizQuestion5").style.display="";
				
				var val = parseInt(quiz_questions_qty.value) + 1;
    			quiz_questions_qty.value = val;
				//alert(quiz_questions_qty.value);
				
				return;
		}
		
}


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

function 	prefill_messageContent(){ //

		
		var keyword=document.campaign_sms.keyword.value;
		var message_body="";

		if (document.campaign_sms.campaign_type.value=="contest") { 
				
				var winnerQty=document.campaign_sms.winner_qty.value;
				var contest_duration=document.campaign_sms.contest_duration.value;

				
				switch (document.campaign_sms.contest_type.value) {
				
				
						case "0":	
								message_body="This is a SMS Contest! Be the first "+winnerQty+ " to reply with ["+keyword+"] to win";
								break;
							
						case "1":
								message_body="This is a SMS Contest! Be the first "+winnerQty+ " to reply with ["+keyword+"] within "+contest_duration+" hours to win";
								break;
							
						case "2":
								message_body="This is a SMS Contest! {Place your Question here} Be the first "+winnerQty+ " to reply with ["+keyword+"] <Answer>] to win";
								break;
							
						case "3":
								message_body="This is a SMS Contest! {Place your Question here} Be the first "+winnerQty+ " to reply with ["+keyword+" <Answer>] within "+contest_duration+" hours to win";
								break;
				
				}
				
				//Be the first 11 to reply with 'wwww {Your Answer}' within {h} hours to win
				
				//alert("Contest!");
				document.campaign_sms.ca_sms_messagebody.value=message_body;
		
		}
		
		else if (document.campaign_sms.campaign_type.value=="quiz") {
				
				//alert("Quiz!");
				document.campaign_sms.ca_sms_messagebody.value="This is a SMS Quiz! \nReply ["+keyword+"] to begin the quiz";
		
		}
		
		else if (document.campaign_sms.campaign_type.value=="vote") {
				
				//alert("Vote!");
				
				var choiceA=document.campaign_sms.choiceA.value;
				var choiceB=document.campaign_sms.choiceB.value;
				var choiceC=document.campaign_sms.choiceC.value;
				var choiceD=document.campaign_sms.choiceD.value;
				var choiceE=document.campaign_sms.choiceE.value;
				
				switch (document.campaign_sms.vote_choice_qty.value) {
				
							
						case "1":
								message_body="To vote: reply ["+keyword+" a] for "+choiceA;
								break;
							
						case "2":
								message_body="To vote: reply ["+keyword+" a] for "+choiceA+" , ["+keyword+" b] for "+choiceB  ;
								break;
							
						case "3":
								message_body="To vote: reply ["+keyword+" a] for "+choiceA+" , ["+keyword+" b] for "+choiceB+" , ["+keyword+" c] for "+choiceC;
								break;
								
						case "4":
								message_body="To vote: reply ["+keyword+" a] for "+choiceA+" , ["+keyword+" b] for "+choiceB+" , ["+keyword+" c] for "+choiceC+" , ["+keyword+" d] for "+choiceD;
								break;
								
						case "5":
								message_body="To vote: reply ["+keyword+" a] for "+choiceA+" , ["+keyword+" b] for "+choiceB+" , ["+keyword+" c] for "+choiceC+" , ["+keyword+" d] for "+choiceD+" , ["+keyword+" e] for "+choiceE;								
								
								break;
				
				}
				
				
				document.campaign_sms.ca_sms_messagebody.value=message_body;
		
		}


		else if (document.campaign_sms.campaign_type.value=="survey") {
				
				//alert("Contest!");
				document.campaign_sms.ca_sms_messagebody.value="This is a SMS Survey! \nReply ["+keyword+"] to begin the survey";
		
		}
		
		
		textCounter(document.campaign_sms.ca_sms_optout,document.campaign_sms.ca_sms_messagebody, document.campaign_sms.charcount,document.campaign_sms.maxcharcount.value);


}


