/*******************************************************************
**  jQuery global Documnet.Ready function.
********************************************************************/
$(document).ready(function () {
	$(".grey-and-rounded").corner("round 12px");
});



/*******************************************************************
**  Validation Helpers
********************************************************************/
// Validate Email Addresses
function validEmail(fld) {
	if (fld.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		return false;
	}
	return true;
}


/*******************************************************************
**  Form Validations
********************************************************************/
// Newsletter Form Validation
function validateSignUpForm(fm) {
	// Validte form fields.
	if (!validEmail(fm.i_emailgeneric)) {
		alert("This does not appear to be a valid e-mail address.  Please try again.");
		fm.i_emailgeneric.select(); return false; 
	}

	// Form's good, continue with submit.
	return true;
}


/*******************************************************************
**  Window Popups
********************************************************************/
// Function to open video gallery 
// Uses the 'openPop' function
function openVideoGalleryPopup(url) {
	openPop(url, 715, 637, 'resizable');
}
// "only 1 open at a time" popup function, used on spec pages, copied from GEA
//-----------------------------------------------------------------------------
// The fifth argument, windowname, is optional.  If specified, it is passed as
// the second argument to window.open().  This is required in order to leave
// the popup opener page (without closing the popup), come back to it, and NOT
// have a duplicate popup window.
//-----------------------------------------------------------------------------
var popupWin;
var scrnwidth = screen.width;
var scrnheight = screen.height;
function openPop(url, width, height, addloptions, windowname) {
	if (windowname == null) {
		windowname = "";
	}
	// scrnwidth
	// scrnheight
	// popupWin
	var xspot = Math.round((scrnwidth / 2) - (width / 2));
	var yspot = Math.round((scrnheight / 2) - (height / 2) - 30);
	features = "height=" + height + ",width=" + width +
		",top=" + yspot + ",screenY=" + yspot +
		",left=" + xspot + ",screenX=" + xspot;
	if (addloptions && addloptions != "") {
		features += "," + addloptions;
	}
	if (!popupWin || popupWin.closed) {
		popupWin = window.open(url, windowname, features);
	}
	else {
		window.popupWin.close();
		popupWin = window.open(url, windowname, features);
	}
	popupWin.focus();
}
