<!--

// Preload navigation

	image1 = new Image();
	image1.src = "images/home_roll.gif";

	image2 = new Image();
	image2.src = "images/search_roll.gif";

	image3 = new Image();
	image3.src = "images/directory_roll.gif";

	image4 = new Image();
	image4.src = "images/onlineshopping_roll.gif";
	
	image5 = new Image();
	image5.src = "images/getlisted_roll.gif";

	image6 = new Image();
	image6.src = "images/articles_roll.gif";

	image7 = new Image();
	image7.src = "images/contactus_roll.gif";


// variables
var textnormal		= "#517CA3";
var textactive		= "#E7F1F9";
var cellnormal	 	= "#E7F1F9";
var cellactive		= "#517CA3";

// mouseover-effect
function highlight_cell(cell) {
	cell.style.cursor = 'hand';
	cell.bgColor = cellactive;
	cell.children.tags('A')[0].style.color = textactive;
}

// mouseout-effect
function normal_cell(cell) {
	cell.style.cursor = 'hand';
	cell.bgColor = cellnormal;
	cell.children.tags('A')[0].style.color = textnormal;
}

// link-simulation
function cell_link(cell) {
	cell.children.tags('A')[0].click();
}

//-->

/*  Validate the form for contact us page */
function checkFields() {

	var missinginfo = "";

	if (document.form.Business.value == "") {
		missinginfo += "\n     -  Name";
	}

	if ((document.form.eMail.value == "") || (document.form.eMail.value.indexOf('@') == -1) || (document.form.eMail.value.indexOf('.') == -1)) {
		missinginfo += "\n     -  Email address";
	}
	if (document.form.Comments.value == "") {
		missinginfo += "\n     -  Enquiry/Comments";
	}

	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"You failed to correctly fill in your:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease re-enter and submit again";
		alert(missinginfo);
		return false;
	}
	else 
		return true;
}

//check length of textarea input
function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('maximum length used');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}

/*  Validate the form for contact us page */
function checkSO() {

	var missinginfo = "";

	if (document.form.sname.value == "") {
		missinginfo += "\n     -  Company name";
	}

	if (document.form.bank.value == "") {
		missinginfo += "\n     -  Bank name";
	}

	if (document.form.bankadd1.value == "") {
		missinginfo += "\n     -  Bank Address";
	}

	if (document.form.sortcode.value == "") {
		missinginfo += "\n     -  Sortcode";
	}

	if (document.form.accno.value == "") {
		missinginfo += "\n     -  Account Number";
	}

	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"You failed to correctly fill in your:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease re-enter and submit again";
		alert(missinginfo);
		return false;
	}
	else 
		return true;
}

/**
 * Analytics | Get more out of Google | A tutorial for .NET magazine by Public
 * @author Tim Whitlock 
 */
 

// We're going to have multiple functions, so the GA tracker can be declared a global
var pageTracker;

/**
 * The initializing function. This gets called as soon as GA is available in the HTML document
 * @param string your GA tracking code
 * @return void 
 */
function runGA( trackingCode ){
    try {
        // intialize the tracker and perform the default page track
        pageTracker = _gat._getTracker( trackingCode );
        pageTracker._trackPageview();
        // Now we'll kick start the external link tracking magic
        initializeExternalLinks();
    }
    // Always trap JavaScript errors: 
    // You can display these while developing, and silence them once you're live.
    catch( Er ){
        //alert( Er.message );
    }
}


/**
 * This function adds click listeners to all external links on the page.
 * We'll call it only when GA and all links on the page are available
 * @return void
 */
function initializeExternalLinks(){
    // Grab all <a> elements from the DOM and check whether they are external to this site.
    var lnks = document.getElementsByTagName('a');
    var regLocal = new RegExp("^https?:\\/\\/"+window.location.hostname);
    var i, elLnk;
    for( i = 0; i < lnks.length; i++ ){
        elLnk = lnks[i];
        // If a link is not a web address, or if it is on our current site we skip it.
        if( ! /^https?:\/\//.test(elLnk.href) || regLocal.test(elLnk.href) ){
            continue;
        }
        // otherwise we'll use the browser-specific even listening method to give it an additional click action. 
        // This does not interfere with any other actions on the link.
        if( elLnk.attachEvent ){
            elLnk.attachEvent( 'onclick', onExternalClick );
        }
        else if( elLnk.addEventListener ){
            elLnk.addEventListener('click', onExternalClick, true );
        }
    }
}


/**
 * Utility function to perform the old-school method of tracking external links using artificial content paths.
 * @param HTMLAnchorElement the browser's native DOM object for a link.
 * @return bool always true
 */
function trackExternal( elLnk ){
    // We'll use a Regular Expression to create a string like "/external/www.publicreative.com/"
    var path = elLnk.href.replace(/^https?:\/\//, '/external/');
    // If we failed, we won't track it, (it could also be a mailto: link)
    if( path && path.indexOf('/external/') === 0 ){
        // hand off the artificial path to the GA tracker
        pageTracker._trackPageview( path );
    }
    return true;
}


/**
 * Click handler, invoked by the browser
 * @param Event internally passed event object
 * @return bool always true
 */
function onExternalClick( Evt ){
    try {
        // A little bit of wizardry handles cross-browser nuances and obtains a reference to the clicked link.
        // There are many ways to achieve this, and you could also use a library like jQuery.
        var elLnk = Evt ? ( Evt.target ? Evt.target : Evt.srcElement ) : event.srcElement;
        // We'll hand off to the trackExternal function which uses the old-school method of tracking external links
        trackExternal( elLnk );
        // If you have the new GA event tracking function enabled on your account you should use _trackEvent directly instead:
        // Passing the links href attribute ensures the full external URL is logged as the event value.
        // pageTracker._trackEvent( 'links', 'external', elLnk.href );
    }
    catch( Er ){
        // you should comment out error alerts when you go live
        //alert( Er.message);
    }
    return true;
}

