/*  
	NETCU DEFAULT JAVASCRIPT
	CREATED: 30.11.05
	MODIFIED: 20.04.10
*/

/* UPDATED
****************************************************/


$(document).ready( function() {
   	$('A[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
    });

	$("#registerme").validate({
		
		rules: {
			txtFirstName: "required",
			txtLastName: "required",
			ddlTitle: "required",
			txtNewEmail: {
				required: true,
				email: true
			},
			txtMobile: {
				required: true,
				digits: true
			},
			ddlCategory: "required",
			txtTelephone: {
				required: true,
				digits: true
			},
			txtJobTitle: "required",
			txtOrganisation: "required",
			txtAddress: "required",
			txtCity: "required",
			txtPostcode: "required"
		},
		messages: {
			txtFirstName: "Please enter your first name",
			txtLastName: "Please enter your last name",
			ddlTitle: "Please select a title",
			txtNewEmail: "Please enter a valid email address",
			txtMobile: "Please enter a mobile number",
			ddlCategory: "Please select a category",
			txtTelephone: "Please enter a contact telephone number",
			txtJobTitle: "Please enter your job title",
			txtOrganisation: "Please enter your organisation name",
			txtAddress: "Please enter your address",
			txtCity: "Please enter a city",
			txtPostcode: "Please enter your postcode"
		}
	});
	
	
	var COOKIE_NAME = 'NETCU-HIGHLIGHT';
	$hifive = $.cookie(COOKIE_NAME);
	if ($hifive == null) {
		$.cookie(COOKIE_NAME, 'highlight', { path: '/', expires: 5 });
		$("#highlight").addClass("shine");
	}

});


/* OLD
****************************************************/








function printMe() {
	window.print();
}

/* LINK PREVIEW CODE */

addEvent(window, 'load', linkPreview);

function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} 
	else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	}
	else { 
		return false; 
	} 
}

function linkPreview(){
	var links = document.getElementsByTagName("a");

	for (i=0; i<links.length; i++){
		var currentLink = links[i];
		var	images = currentLink.getElementsByTagName("img");
		
		if (images.length == 0){
			var linkHref = currentLink.href;
			
			if (linkHref.match(/amazon.com/)){
				append(currentLink, "amazon");
			}
			else{
				checkLinks(linkHref, currentLink)
			}
		}
	}
}

function checkLinks(linkHref, currentLink){
	var linkHrefParts = linkHref.split(".");
	
	var extension = linkHrefParts[linkHrefParts.length - 1];
	
	extension = extension.replace("/","");
	
	if( extension in { doc:1, pdf:1, ppt:1, txt:1, xls:1, zip:1 } ){
		append(currentLink, extension );
	}
}

function append(currentLink, extension){
	var span = document.createElement('span');
	span.innerHTML = "&nbsp;";
	currentLink.parentNode.insertBefore(span,currentLink.nextSibling);
	span.className = extension;
}

/* POP-UP WINDOW CODE */

function popUp(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}