// JavaScript Document
function checkInfo(frmObj,form) {
	var theForm = typeof form != 'object' ? document.getElementById(form): form;
	var val = false;
	var ret = Spry.Widget.Form.validate(theForm);
	if (ret) {
		OpenPopUp('','gateway');
		//window.open('','gateway','resizable=1,scrollbars=0,width=300,height=150');
		return true;
	}else { return false; }
}

var Gateway = GetCookie('GatewayPage');

ReDirect('/index.php');
function ReDirect (URL) {
	SetCookie('GatewayPage','TRUE',1);
		if (Gateway == 'TRUE') 
			window.location=(URL);
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;

	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie(name, value, expDays, path, domain, secure) {
	if (expDays != null ) {
		var expires = new Date();
		expires.setTime(expires.getTime() + (expDays*24*60*60*1000));
	}

	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
} // JavaScript Document

function OpenPopUp(url, pagename) {
    var w = 300;
    var h = 150;
    var scroll = true;
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += 'scrollbars=1' + ',';
    settings += 'resizable=yes' + ',';
    settings += 'status=yes';
    win = window.open(url, pagename, settings, "");
    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
    win.window.moveTo(winl, wint);
}

