// Pop-up code for case study pop-ups
function popup(url) {	
	var winParams = "width=600,height=490,left=0,top=0,toolbar=0,resizable=1,scrollbars=auto,location=0,status=0"
	popwin = window.open(url,"",winParams);
}

// ----------------------------------------------------------------------
// Verify contact form before submission
// ----------------------------------------------------------------------

// Check those fields
function validateContactInfo() {
	// Pattern for valid e-mail address
    var objRegExp  = /(^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$)/;
    var emailField = document.getElementById('contact[email]').value;
    
    // Is the name field blank?
    if (document.getElementById('contact[name]').value == "") {
    	alert("Please enter your name.");
        document.getElementById('contact[name]').focus();
        return false;
    }
    // Is the email field blank?
    else if (document.getElementById('contact[email]').value == "") {
    	alert("Please supply an e-mail address.");
        document.getElementById('contact[email]').focus();
        return false;
    }
    // Check if the email is valid
    else if(!objRegExp.test(emailField)) {
		alert("Please enter a valid e-mail address.");
        document.getElementById('contact[email]').focus();
		return false;
	}
    // Is the subject field blank?
    else if (document.getElementById('contact[subject]').value == "") {
    	alert("Please select a subject for your message.");
        document.getElementById('contact[subject]').focus();
        return false;
    }
    // Is there any text in the message?   
    else if (document.getElementById('contact[message]').value == "") {
    	alert("Please type your message in the space provided.");
        document.getElementById('contact[message]').focus();
        return false;
    }
	// Otherwise allow the form to be submitted
	else {
        return true;
    }
}


// ----------------------------------------------------------------------
// Make cursor style of same-page links "default"
// ----------------------------------------------------------------------

function f () {
	return false;
}

// Check links against current URL
function checkForCurrentLinks() {
	var hrefs = document.getElementsByTagName("a");	
	for (var i = 0; i < hrefs.length; i ++)
	try {
		if (hrefs[i].href == location.href) {
			hrefs[i].style.cursor = "default";
			hrefs[i].onclick = f;
		}
	}
	catch(e){}
 }