/**
 * popup hompy window
 */
var hompywindow = '', fullwindow = '';
var isIE_var = '';
function isIE(){
    var browser=navigator.appName;
    if( browser=="Microsoft Internet Explorer")
	return '1';
    return '-1';
}
function popup(url) {
    var name = "GodGame";
    var scroll = 'no';
    try {
	if( window.screen.availWidth<1000 || window.screen.availHeight <= 720 )
	    scroll = 'yes';
    }
    catch(err) {}
    var argv = "menubar=no,scrollbars="+scroll+",width=1000,height=665,resizable=yes";
    if (!hompywindow.closed && hompywindow.location) {
        hompywindow.location.href = url;
    } else {
        hompywindow = window.open(url,name,argv);
        try { if (!hompywindow.opener) hompywindow.opener = self; } catch(e) {}
    }
    if (window.focus) { hompywindow.focus(); }
    return false;
}

function popupFull(url) {
    var name = "GodGameFull";
    if (!fullwindow.closed && fullwindow.location) {
        fullwindow.location.href = url;
    } else {
        fullwindow = window.open(url,name);
        if (!fullwindow.opener) fullwindow.opener = self;
    }
    if (window.focus) { fullwindow.focus(); }
    return false;
}

function genericAJAX(method, url, poststr, callback) {
    var req;
    if (window.XMLHttpRequest)
        req = new XMLHttpRequest();
    else if (window.ActiveXObject)
        req = new ActiveXObject("Microsoft.XMLHTTP");
    else
	return;

    req.open(method, url);
    req.onreadystatechange = function() {
	if( req.readyState == 4 && req.status == 200 ) {
	    callback(req.responseText);
	}
    };
    if( method == "POST" ) {
	req.setRequestHeader('Content-Type',
			     'application/x-www-form-urlencoded');
	req.send(poststr);
    } else {
	req.send(null);
    }
}
function showTime() {
var now = new Date();
var t = new Array(5);
now = now.toString();
t = now.split(" ");
if( isIE_var == '') { isIE_var = isIE(); }
else if( isIE_var == '-1')
document.getElementById('clock').innerHTML = t[3]+" "+t[1]+" "+t[2]+" "+t[4];
else if( isIE_var == '1')
document.getElementById('clock').innerHTML = t[5]+" "+t[1]+" "+t[2]+" "+t[3];

setTimeout("showTime()",1000);
}

function shareFacebook(u,t){
 window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
}

function sharePlurk(u,t){
 window.open('http://www.plurk.com/?qualifier=shares&status=' .concat(encodeURIComponent(u)) .concat(' ') .concat('(') .concat(encodeURIComponent(t)) .concat(')'));
}

function shareTwitter(u,t){
 window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(t)) .concat(' ') .concat(encodeURIComponent(u)));
}

function logout() {
    window.location = "/logout.php?origurl=" + escape(window.location);
}
