$(document).ready(function() {

	$("#map").gMap({ 
		  controls: false,
	      scrollwheel: true,                 
	      latitude: 53.333894,
	      longitude: -1.334410,                  
	      zoom: 15,
	      controls: ["GLargeMapControl3D", "GOverviewMapControl"],
	      
	       /* icon: { image: "/images/map_pointer.png", 
	                iconsize: [59, 64],
	                iconanchor: [20, 48]
	           },*/		 		                	      
	      
		  markers: [{ latitude: 53.333894,
	      			longitude: -1.334410,		               
           			html: "<strong>UKP Training</strong><br />Unit 6 Holbrook Industrial Estate<br />Longacre Close<br />Sheffield<br />S20 3FR",
                	popup: true	                
	 		       }]
		 		       
         
	      
	     });

});

function validate_contact_form()
{
    
	msg = "";
    valid = true;

    if ( document.contact_form.message.value == "" )
    {
		msg = msg + "You must enter a message.\n";
        valid = false;
    }   
	
    if ( document.contact_form.name.value == "" )
    {
		msg = msg + "You must enter your name.\n";
        valid = false;
    }   	
	
    if ( document.contact_form.captcha_code.value == "" )
    {
		msg = msg + "You must enter the security code.\n";		
        valid = false;
    }   	

	
	if (document.contact_form.email.value != "")
	{
	
		apos = document.contact_form.email.value.indexOf("@");
		dotpos = document.contact_form.email.value.lastIndexOf(".");
		
		if (apos < 1 || dotpos - apos < 2)
		{
			msg = msg + "The email address entered is not valid.\n";		
			valid = false;
		}
		
	}
	
	if(document.contact_form.email.value == "" && document.contact_form.tel.value == "")
    {
		msg = msg + "You must enter either your telephone number or email address.\n";		
        valid = false;
    }   	

	if(valid == false)       
	{
        alert (msg);		
	}
	   

    return valid;
	
}
function validate_booking_form()
{
    
	msg = "";
    valid = true;

    if ( document.booking_form.full_name.value == "" )
    {
		msg = msg + "You must enter a contact name.\n";
        valid = false;
    }   
	
    if ( document.booking_form.job_title.value == "" )
    {
		msg = msg + "You must enter a job title for the contact.\n";
        valid = false;
    }   	
	
    if ( document.booking_form.tel.value == "" )
    {
		msg = msg + "You must enter a telephone number.\n";		
        valid = false;
    }   	

	if (document.booking_form.email.value != "")
	{
	
		apos = document.booking_form.email.value.indexOf("@");
		dotpos = document.booking_form.email.value.lastIndexOf(".");
		
		if (apos < 1 || dotpos - apos < 2)
		{
			msg = msg + "The email address entered is not valid.\n";		
			valid = false;
		}
		
	}
	
	if(document.booking_form.o_name.value == "")
    {
		msg = msg + "Please enter an organisation name.\n";		
        valid = false;
    }  
	if(document.booking_form.o_address.value == "")
    {
		msg = msg + "Please enter the address of the organisation.\n";		
        valid = false;
    }  
	
	if(document.booking_form.postcode.value == "")
    {
		msg = msg + "Please enter the postcode of the organisation.\n";		
        valid = false;
    }  
	
	if(document.booking_form.terms.checked == false)
    {
		msg = msg + "Please agree to the terms and conditions before submitting.\n";		
        valid = false;
    }   	
 	

	if(valid == false)       
	{
        alert (msg);		
	}
	   

    return valid;
	
}

function validate_signup(frm) {
        var emailAddress = frm.Email.value;
        var errorString = '';
		
		frm.cd_DFEMAIL.value = frm.Email.value;
		frm.ReturnURL.value = frm.ReturnURL.value + "/"+frm.Email.value;
		
        if (emailAddress == '' || emailAddress.indexOf('@') == -1 || emailAddress == 'Your email address') {
                errorString = 'Please enter your email address';
        }

   
var els = frm.getElementsByTagName('input');
for (var i = 0; i < els.length; i++)
{
    if (els[i].className == 'text' || els[i].className == 'date' || els[i].className == 'number')
    {
        if (els[i].value == '')
            errorString = 'Please complete all required fields.';
    }
    else if (els[i].className == 'radio')
    {
        var toCheck = document.getElementsByName(els[i].name);
        var radioChecked = false;
        for (var j = 0; j < toCheck.length; j++)
        {
            if (toCheck[j].name == els[i].name && toCheck[j].checked)
                radioChecked = true;
        }
        if (!radioChecked)
            errorString = 'Please complete all required fields.';
    }
}

        var isError = false;
    if (errorString.length > 0)
        isError = true;

    if (isError)
        alert(errorString);
        return !isError;
}


