/**
 * Login next function.
 * 
 * @param result:
 *            the result of the login request.
 */
function loginOk(result) {
	if (result > 0) {
		window.location = 'http://www.jrapid.com/management/forms.Main/Panel.jsp';
	} else {
		alert('Invalid username or password');
	}
}

/**
 * Join Alpha Program next function.
 * 
 * @param result:
 *            the result of the login request.
 */
function joinOk(result) {
	//alert('Thanks for registering. Check your email box.');
	//window.location.reload();
	window.location = 'welcome-jrapid.html';
}

/**
 * Reproduces the movie on url provided
 * 
 * @param url:
 *            containing .swf file.
 */
function play(url) {
	$("div#player").flashembed(url);
}

function openRemindPassword() {
	//jrapid.form({entity: 'RemindPassword', openWindow: true});
	remindWindowRef = window.open('http://www.jrapid.com/management/forms.Main/RemindPassword_form.html','mywin',
	'left=20,top=20,width=500,height=150,toolbar=0,resizable=0, status=0');
}

/**
 * Sets the referrer cookie.
 */
function setCookies() {
	var date = new Date();
	date.setTime(new Date().getTime() + (24 * 60 * 60 * 1000 * 365));
	// document.cookie = 'theme=;Path=/;Expires=' + date.toGMTString() + ';';
	var r = document.referrer;
	if (document.cookie.indexOf('ref') == -1 && r && r.length > 7) {
		document.cookie = 'ref=' + r.substring(7) + ';Path=/;Expires=' + date.toGMTString() + ';';		
		
	}
	if (r && r.indexOf('q=') != -1) {
		r = r.substring(r.indexOf('q=') + 2);
		r = r.indexOf('&') != -1 ? r.substring(0, r.indexOf('&')) : r;
		document.cookie = 'key=' + r + ';Path=/;Expires=' + date.toGMTString() + ';';			
	}
}

// set cookies.
setCookies();

function goal(name) {
	var c = document.cookie;
	var i = c.indexOf('g=');
	var g = '';
	if (i != -1) {
		g = c.substring(i+2);
		g = g.substring(0, g.indexOf(';')) + '|';
	}
	if (g.indexOf(name) == -1) {
		var date = new Date();
		date.setTime(new Date().getTime() + (24 * 60 * 60 * 1000 * 365));
		document.cookie = 'g=' + g + name + '-' + new Date().getTime() + ';Path=/;Expires=' + date.toGMTString() + ';';
	}
}




