function gCode()
{
	if (getCookie("firstTime") == "1")
	{
		document.getElementById("gFrame").src = "http://www.omnovia.com/googlenotificationfortrials";
		setCookie("firstTime","1",-6,"/",location.hostname.substring(location.hostname.indexOf('.')),"");
	}
}

function postUrl(id)
{
	var form, input, param, i, tmp;

	form = document.createElement('form');
	form.method = 'post';
	form.action = id.href;

	param = id.rel.split(',');
	for (i=0; i < param.length; i++)
	{
		input = document.createElement('input');
		input.type = 'hidden';
		tmp = param[i].split(':');
		input.name = tmp[0];
		input.value = tmp[1];
		form.appendChild(input);
	}

	document.body.appendChild(form);
	form.submit();

	return false;
}

function loadPage(id)
{
	return true;
}


function loadPage(id)
{
	$('#loading').css('display','');

	// load the links's href via ajax
	// use the rel attrib to specify the output div id
	var output = id.rel.length > 0 ? '#'+id.rel : '#ptlMain';
	$.get(id.href,
	function(data){
	$('#loading').css('display','none');
	$(output).html(data);
	});
	return false;
}


function setCookie(name, value, expires, path, domain, secure)
{
	var date = new Date();
	date.setMonth(date.getMonth() + ((expires) ? expires : 6));

	var curCookie = name + "=" + escape(value) + "; expires=" + date.toGMTString() +
		((path) ? "; path=" + path : "; path=/") +
		((domain) ? "; domain=" + domain : "; domain="+location.hostname.substring(location.hostname.indexOf('.')) ) +
		((secure) ? "; secure" : "");

	try {
		document.cookie = curCookie;
	} catch(e) {
		alert("You do not appear to have cookies enabled. Please enable cookies before proceeding.");
	}
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if(begin == -1) {
		begin = dc.indexOf(prefix);
		if(begin != 0)
			return null;
	} else
		begin += 2;

	var end = document.cookie.indexOf(";", begin);

	if(end == -1)
		end = dc.length;

	var theValue = unescape(dc.substring(begin + prefix.length, end));

	return (theValue == undefined || theValue == "" ? null : theValue);
}


function displayError(msg)
{
	$('#errorDiv').css('display','');
	$('#errorMsg').html(msg);

	highlight('#errorDiv table');
}

function highlight(id,color,prop)
{
	var from = $(id).css('background-color');
	if (color == undefined)
		var color = '#ffff9a';

	$(id).animate({ backgroundColor: color }, 50)
		.animate({ backgroundColor: from }, 1000);
}

function isValidEmail(email)
{
	var email_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	return email_filter.test(email);
}