// CSS Browser Selector   v0.2.3
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua = navigator.userAgent.toLowerCase(),
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
	var c = b+os+' js';
	h.className += h.className?' '+c:c;
}();

function noPDF() {
alert("This PDF will be available shortly");
}



	function isValidEmail(emailAddress) {
   var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}
var FieldList = "";
var checkboxMessage=""
var HighLightColour = '#cce4f2';
// Compulsary Field Checker
function checkCompulsory(form) {
var keyword="_compulsory";
if (document.images) {
 for (i=0;i<form.length;i++) {
   var tempobj=form.elements[i];  
   if (tempobj.name.substring((tempobj.name.length-keyword.length),(tempobj.name.length))==keyword.toString()) {
    //Type checker text / textarea / selectionbox
    //alert(tempobj.name)
    shortFieldName=tempobj.name.substring(0,tempobj.name.length-keyword.length);
    shortFieldName=shortFieldName.slice(5);
    shortFieldName=shortFieldName.replace(/_/g," ")
    if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0)) {
     // Trims 'Form_' and '_compulsory' from names for display to user
     FieldList += shortFieldName + "\n";
     tempobj.style.backgroundColor=HighLightColour;
    } else if (tempobj.type=="checkbox"&&!tempobj.checked){
     if (checkboxMessage==''){
      checkboxMessage='\nPlease ensure that you have selected:\n';
     }
     tempobj.style.backgroundColor=HighLightColour
     checkboxMessage += shortFieldName+"\n";
    }
        }
  }
  
 }
}
function ValidateForm() {
var emailMessage = "";
alertMessage = "We did not get all the information we need from you.\n Please fill in the following field(s):\n\n";
// Check all compulsory fields are filled.
checkCompulsory(document.contactForm);
// Email validation.
if (document.contactForm.form_Email_compulsory.value == ""){
//FieldList = FieldList + "Email Address\n"; // Message to user.
} else {
 validEmail = isValidEmail(document.contactForm.form_Email_compulsory.value);
 if (validEmail == false) {
 document.contactForm.form_Email_compulsory.style.backgroundColor=HighLightColour;
 emailMessage = "\nPlease enter a valid email address"; // Message to user.
 }
};
 
// Submit form or display message.
if (FieldList == "" && emailMessage == ""){
document.contactForm.submit();
} else { 
   if (FieldList != "") {
      alertMessage += FieldList+checkboxMessage;
   }
 
   if (emailMessage != "") {
      alertMessage += emailMessage;
   }
   // Clear off existing messages
   FieldList = ''
   checkboxMessage = ''
   alert(alertMessage);
};
}
	
	
	
function openWin(strURL, intWidth, intHeight, scroll, resizable) {
var nav4 = window.Event ? true : false;
//alert(':' + !objWindow + objWindow)

intHeight += 30

intWidth += 5

//alert(scroll)

if (scroll==''){scroll=1}

if (resizable==''){resizable=0}

var bolWindowClosed

var _ieErrorCheckingCode = 'try{objWindow.blur();bolWindowClosed = false;}catch(oErr){bolWindowClosed = true;}';

var _navNonErrorCheckingCode = 'objWindow = null;bolWindowClosed = true;';


if (!nav4){

eval(_ieErrorCheckingCode);

}else{

eval(_navNonErrorCheckingCode);

}


//alert(scroll)


if (bolWindowClosed) {

objWindow = window.open(

strURL,

"myWindow",

"leftmargin=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=" + resizable + ",width=" + intWidth + ",height=" + intHeight

);

}

else {

objWindow.location.href = strURL

objWindow.blur()

objWindow.focus()

}


if (objWindow.resizeTo) {objWindow.resizeTo(intWidth, intHeight);}


//if (document.all)

// { w = document.body.clientWidth; h = document.body.clientHeight; }

//else if (document.layers) { w = window.innerWidth; h = window.innerHeight; }

w = screen.availWidth; h = screen.availHeight


if (objWindow.moveTo) {objWindow.moveTo(w/2-(intWidth/2),h/2-(intHeight/2));}

}



