function divimage()
{
	
	if (document.getElementById("img").style.display=='none') 
			{				
			   document.getElementById("img").style.display='';
			   document.GGForm.button.value = "Cancel";
			}
			else 
			{
				
				document.getElementById("img").style.display='none';
				document.GGForm.button.value = "Upload New Image";
			}	
	
}


function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submitting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg
if(x==1){alert(msg); return false;}
}


// pop up - Media Ads pop up
function popwin(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=510,height=580,left=150,top=50');}
// ends

// pop up
function popwin(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=600,height=580,left=150,top=50');}
// ends


// pop up - Dubai Map
function popwinmap(x, y)
{window.open(x, y,'status=no,toolbar=0,scrollbars=1,resizable=1,menubar=0,width=700,height=580,left=150,top=50');}
// ends


//Verify TEXTAREA field - general
function VerifyMsg(f_ld,c_nt,cnt_fld) {

	var len = f_ld.value.length
	var cl

	if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
		f_ld.value = ""
		len = 0
	}
	if (len > (c_nt-10)) {
		f_ld.value = f_ld.value.substring(0, c_nt)
		cl = 0
	}
	else {
		cl = c_nt - len
	}
	eval(cnt_fld).value = cl
}

//Delete news release check
function delCheck() {
	var conf = confirm("This record will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}
	
//for email addresses
var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

//illegal characters in fields
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';
 	
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//check for illegal characters
function checkIlleg(va)
{
	var stripped = stripCharsInBag (va, illegalCharStr);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check illegal characters for url
function checkIllegweb(va)
{
	var stripped = stripCharsInBag (va, illegalCharStrWeb);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}
function mailvalidate()
{
	var x=0;
var err_msg="";
	
	if(document.GGForm.FName.value=="")
        {
        err_msg=err_msg+"Full Name\n"; x=1;
        }
		if(document.GGForm.Email.value=="")
        {
                err_msg=err_msg+"Email\n"; x=1;		 
        }							
else {
		email = document.GGForm.Email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
		if(document.GGForm.tname.value=="")
        {
        err_msg=err_msg+"Full Name\n"; x=1;
        }
		if(document.GGForm.temail.value=="")
        {
                err_msg=err_msg+"Email\n"; x=1;		 
        }							
else {
		email = document.GGForm.temail.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}

if(document.GGForm.Comments.value=="")
        {
                err_msg=err_msg+"Enquiries/ Comments\n"; x=1;		 
        }		

	
	return msg(err_msg,x);
}
// Rental Enquiry Us Validation
function tafValidate()
{
var x=0;
var err_msg=""	
if(document.GGForm.send_name.value=="")
        {
        err_msg=err_msg+"Your Name\n"; x=1;
        }
if(document.GGForm.send_email.value=="")
        {
                err_msg=err_msg+"Your E-Mail Address\n"; x=1;		 
        }							
else {
		email = document.GGForm.send_email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Your E-Mail Address - Invalid Characters\n"; x=1;
			}
		}
if(document.GGForm.recipname_1.value=="")
        {
        err_msg=err_msg+"Friends Name\n"; x=1;
        }
if(document.GGForm.recipemail_1.value=="")
        {
                err_msg=err_msg+"Friends E-Mail Address\n"; x=1;		 
        }							
else {
		email = document.GGForm.recipemail_1.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Friends E-Mail Address - Invalid Characters\n"; x=1;
			}
		}										
return msg(err_msg,x);	
}	

// Rental Enquiry Us Validation
function earthhourValidate()
{
var x=0;
var err_msg=""	
if(document.GGForm.send_name.value=="")
        {
        err_msg=err_msg+"Your Name\n"; x=1;
        }
if(document.GGForm.send_email.value=="")
        {
                err_msg=err_msg+"Your E-Mail Address\n"; x=1;		 
        }							
else {
		email = document.GGForm.send_email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Your E-Mail Address - Invalid Characters\n"; x=1;
			}
		}
							
return msg(err_msg,x);	
}	
//Subscribe Form Validation
function subValidate(){
	var x=0;
	var err_msg=""
	if (!document.GGForm.name.value) {
		err_msg=err_msg+"Name\n"; x=1;
		}
	if (!document.GGForm.email.value) {
		err_msg=err_msg+"Email\n"; x=1;
		}
		else {
		email = document.GGForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"EMail Address - Invalid Characters\n"; x=1;
			}
		}
	if (!document.GGForm.cntry.value) {
		err_msg=err_msg+"Country\n"; x=1;
		}		
	if (!document.GGForm.FindUs.value) {
		err_msg=err_msg+"How did you hear about us?\n"; x=1;
		}
	if (document.GGForm.captcha.value !=  document.GGForm.captcha1.value)
        {
         err_msg=err_msg+"Incorrect Authorization Code\n"; x=1;
        }		
	return msg(err_msg,x)
	}		

	
	
//Send newsletter form Validation
function sndValidate(){
	var x=0;
	var err_msg=""
	if(!document.GGForm.subj.value){
		err_msg=err_msg+"Subject\n"; x=1;
		}
	if(!document.GGForm.sender.value){
		err_msg=err_msg+"Sender's Address\n"; x=1;
		}
	else{		
		email = document.GGForm.sender.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
	if(!document.GGForm.emlmode[0].checked && !document.GGForm.emlmode[1].checked && !document.GGForm.emlmode[2].checked ){
		err_msg=err_msg+"Select Subscriber List\n"; x=1;
		}	
	if(document.GGForm.emlmode[0].checked){
		if(!document.GGForm.txtfile.value){
			err_msg=err_msg+"Upload Text File\n"; x=1;
			}
		}	
	if(document.GGForm.emlmode[1].checked){
		if(!document.GGForm.addr.value){
			err_msg=err_msg+"Enter Email addresses\n"; x=1;
			}
		}
	if(x==1){
		return msg(err_msg,x);
		}
	else {
		var conf = confirm("This will broadcast the current newsletter to all the subscribers selected.\nAre you sure?")
		if(!conf) 
			return false;
		else
			return true;
		}	
	}		
	
