﻿// Header Slideshow

var slideCache = new Array();
function RunSlideShow(pictureName, imageFiles, displaySecs) {
    var imageSeparator = imageFiles.indexOf(";");
    var nextImage = imageFiles.substring(0, imageSeparator);
    if (document.all) {
        document.getElementById(pictureName).style.filter = "blendTrans(duration=2)";
        document.getElementById(pictureName).filters.blendTrans.Apply();
    }
    document.getElementById(pictureName).src = "/Image/headers/" + nextImage;
    if (document.all) {
        document.getElementById(pictureName).filters.blendTrans.Play();
    }
    var futureImages = imageFiles.substring(imageSeparator + 1, imageFiles.length)
    + ';' + nextImage;
    setTimeout("RunSlideShow('" + pictureName + "','" + futureImages + "'," + displaySecs + ")",
    displaySecs * 1000);
    // Cache the next image to improve performance.
    imageSeparator = futureImages.indexOf(";");
    nextImage = futureImages.substring(0, imageSeparator);
    if (slideCache[nextImage] == null) {
        slideCache[nextImage] = new Image;
        slideCache[nextImage].src = nextImage;
    }
}

//Highslide Config
hs.captionEval = 'this.a.title';
hs.graphicsDir = '/includes/scripts/highslide_graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.dimmingOpacity = 0.5;
//hs.dimmingOpacity = 0.75;

// Add the controlbar
hs.addSlideshow({
	slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: '0.75',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '-10',
		hideOnMouseOut: true
	},
	thumbstrip: {
		mode: 'horizontal',
		position: 'bottom center',
		relativeTo: 'viewport'
	}

});
// gallery config object
var config1 = {
	slideshowGroup: 'group1',
	transitions: ['expand', 'crossfade']
};

// Turn Settings (JQuery)
$("#pageflip").hover(function() { //On hover...
	$("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '307px',
			height: '319px'
		}, 500);
	} , function() {
	$("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '50px',
			height: '52px'
		}, 220);
	$(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '50px',
			height: '50px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});
	


/* Check of an E-Mail address appears valid */
function isValidEmail(str) 
{
    return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}

/* Trim Left and Right Whitespace */
function trim(s) 
{
    if (s.value > 0) {
        while (s.substring(0, 1) == ' ') {
            s = s.substring(1, s.length);
        }
        while (s.substring(s.length - 1, s.length) == ' ') {
            s = s.substring(0, s.length - 1);
        }
    }
    return s;
}

/* Display an Alert */
function showalert(stralert)
{
	alert(stralert);
}

// Form Processing Functions

function process_ringback1() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form1.r_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form1.r_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
    if (trim(document.form1.r_besttime.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Best time to call\n';
       myerror = 1;
    }
    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}
function process_enquiry4() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form4.e_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form4.e_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form4.e_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form4.e_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form4.e_enquiry.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Your Enquiry\n';
       myerror = 1;
    }
    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}

function process_enquiry5() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form5.e_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form5.e_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form5.e_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form5.e_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form5.e_enquiry.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Your Enquiry\n';
       myerror = 1;
    }
    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}
function process_enquiry6() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form6.e_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form6.e_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form6.e_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form6.e_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form6.e_enquiry.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Your Enquiry\n';
       myerror = 1;
    }
    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}

function process_quote7() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form7.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form7.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form7.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form7.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form7.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form7.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}
function process_quote8() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form8.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form8.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form8.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form8.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form8.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form8.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}
function process_quote9() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form9.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form9.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form9.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form9.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form9.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form9.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}
function process_quote10() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form10.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form10.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form10.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form10.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form10.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form10.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}


function process_quote11() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form11.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form11.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form11.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form11.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form11.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form11.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}


function BrowseServer()
{
	// You can use the "CKFinder" class to render CKFinder in a page:
	var finder = new CKFinder() ;
	finder.BasePath = '/ckfinder/' ;	// The path for the installation of CKFinder (default = "/ckfinder/").
	finder.SelectFunction = SetFileField ;
	finder.Popup() ;

	// It can also be done in a single line, calling the "static"
	// Popup( basePath, width, height, selectFunction ) function:
	// CKFinder.Popup( '../../', null, null, SetFileField ) ;
	//
	// The "Popup" function can also accept an object as the only argument.
	// CKFinder.Popup( { BasePath : '../../', SelectFunction : SetFileField } ) ;
}

// This is a sample function which is called when a file is selected in CKFinder.
function SetFileField( fileUrl )
{
	document.getElementById( 'ctl00_rightpane_content_f_navurl' ).value = fileUrl ;
}



function process_quote22() 
{
    myerror = 0;
    myerrormsg = "";
    myerrormsg = 'Please provide the following\n';


    if (trim(document.form22.q_yourname.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Your Name\n';
        myerror = 1;
    }
    if (trim(document.form22.q_telephone.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Telephone\n';
        myerror = 1;
    }
	 if (trim(document.form22.q_email.value) == '') 
    {
        myerrormsg = myerrormsg + ' -Email\n';
        myerror = 1;
    }
	else
	{
	   if (isValidEmail(document.form22.q_email.value) == false) 
       {
           myerrormsg = myerrormsg + ' -Email (A Valid Address\n';
           myerror = 1;
       }	
	}
    if (trim(document.form22.q_from.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending From\n';
       myerror = 1;
    }
	if (trim(document.form22.q_to.value) == '') 
    {
       myerrormsg = myerrormsg + ' -Sending To\n';
       myerror = 1;
    }

    if (myerror == 1) 
    {
        alert(myerrormsg);
        return false;
    }
    else 
    {
        return true;
    }
}