/*
 * Create email adresses
 * Used instead of mailto: for preventing spam
 */
 
sendMail = function(user,domain) {
	try {
		locationstring = "mailto:" + user + "@" + domain; 
		window.location = locationstring; 
	}
	catch(error) {
		errorMessage(error, "There was an error when trying to send mail to:\n\n"+user+"@"+domain);
		return false;
	}
}

//////////////////////////////////////////////////
/*
 * POPUP FUNCTIONS
 */

// Open Centered Popup

openCenteredPopup = function(mypage,w,h,scroll,resizable) {
	var win = null;

	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resizable+'';
	
	win = window.open(mypage,"centerpopup",settings)
	win.focus();
}

// Open Popup 

openPopup = function(mypage,w,h,scroll,resizable,Lpos,Tpos) {
	var win = null;
	
	settings = 'height='+h+',width='+w+',top='+Tpos+',left='+Lpos+',scrollbars='+scroll+',resizable='+resizable+'';
	
	win = window.open(mypage,"popUp",settings)
	win.focus();
}


//////////////////////////////////////////////////
/*
 * SLIDESHOW
 */

// slideshow

<!-- Begin
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'image_bin/01.jpg'
Pic[1] = 'image_bin/02.jpg'
Pic[2] = 'image_bin/03.jpg'
Pic[3] = 'image_bin/04.jpg'
Pic[4] = 'image_bin/05.jpg'
Pic[5] = 'image_bin/06.jpg'


// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
//  End -->


//////////////////////////////////////////////////
/*
 * Create roll overs for navigation
 * 
 */
 
home_up = new Image
about_up = new Image
adr_up = new Image
adr2_up = new Image
dgsa_up = new Image
imdg_up = new Image
courses_up = new Image
contact_up = new Image
links_up = new Image
driverscpc_up = new Image

home_over = new Image
about_over = new Image
adr_over = new Image
adr2_over = new Image
dgsa_over = new Image
imdg_over = new Image
courses_over = new Image
contact_over = new Image
links_over = new Image
driverscpc_over = new Image

home_up.src = "image_bin/home_up.jpg"
about_up.src = "image_bin/about_up.jpg"
adr_up.src = "image_bin/adr_up.jpg"
adr2_up.src = "image_bin/adr2_up.jpg"
dgsa_up.src = "image_bin/dgsa.jpg"
imdg_up.src = "image_bin/imdg_up.jpg"
courses_up.src = "image_bin/courses_up.jpg"
contact_up.src = "image_bin/contact_up.jpg"
links_up.src = "image_bin/links_up.jpg"
driverscpc_up.src = "image_bin/driverscpc_up.jpg"

home_over.src = "image_bin/home_over.jpg"
about_over.src = "image_bin/about_over.jpg"
adr_over.src = "image_bin/adr_over.jpg"
adr2_over.src = "image_bin/adr2_over.jpg"
dgsa_over.src = "image_bin/dgsa_over.jpg"
imdg_over.src = "image_bin/imdg_over.jpg"
courses_over = "image_bin/courses_over.jpg"
contact_over.src = "image_bin/contact_over.jpg"
links_over.src = "image_bin/links_over.jpg"
driverscpc_over.src = "image_bin/driverscpc_over.jpg"

function imgOver(thisImg) {
	document[thisImg].src = "image_bin/" + thisImg + "_over.jpg"
}
	
function imgOut(thisImg) {
	document[thisImg].src = "image_bin/" + thisImg + "_up.jpg"
}

//////////////////////////////////////////////////


/*
 * Resizable pop up script
 */

		function PopupPic(sPicURL) { 
     window.open( "pop.asp?"+sPicURL, "pop",  
     "resizable=1,height=200,width=200"); } 

//////////////////////////////////////////////////


/* IMAGE PRELOADING
 * 
 * Used for preloading images on every page.
 * 
 */
 
function preloadImages(ImageSources)
{
  for (var i = 0; i < ImageSources.length; i++)
  {
    var oImage = new Image();
    oImage.src = ImageSources[i];
  }
}

//////////////////////////////////////////////////
/*
 * VALIDATE FORM
 */

// enquiry

function Validate(objForm)
{
	if (objForm.C_Name.value == "")
	{
		window.alert("Name is a required Field!");
		objForm.C_Name.focus();
		return false;
	}

	if (objForm.C_Email.value == "")
	{
		window.alert("Email Address is a required Field!");
		objForm.C_Email.focus();
		return false;
	}

	if (objForm.C_Email.value.indexOf("@", 0) == -1 || (objForm.C_Email.value.indexOf("@", 0) != objForm.C_Email.value.lastIndexOf("@", (objForm.C_Email.value.length - 1))) || objForm.C_Email.value.indexOf(".", 0) == -1)
	{
		window.alert("Email Address must be a valid Email Address!");
		objForm.C_Email.focus();
		return false;
	}

	if (objForm.C_Enquiry.value == "")
		{
			window.alert("Please fill out your enquiry.");
			objForm.C_Enquiry.focus();
			return false;
	}

	return true;
}
// -->

