var geoPuUrl = "http:\/\/www.seemytube.com\/";
var geoPuShown = false;

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    
    return false;
}

function geoDoOpen()
{
    if ( geoPuShown == true || getCookie('geoPopCookie'))
    {
        return true;
    }
    
    url = geoPuUrl;
    
    win = window.open(url, 'geoPu1', 'toolbar,status,resizable,scrollbars,menubar,location,height=' + GetHeight() + ',width=' + GetWidth());
    if (win)
    {
        win.blur();
        geoPuShown = true;
    }
    
    setCookie('geoPopCookie', 'shown');
    return win;
}

function initgeoPu()
{
    	if ( document.attachEvent )
    	{
    	    document.attachEvent( 'onclick', geoPopCheckTarget );
    	}
    	else if ( document.addEventListener )
    	{
    	    document.addEventListener( 'click', geoPopCheckTarget, false );
    	}
}


function geoPopCheckTarget(e)
{
    var win = geoDoOpen();
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}
 
function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}

initgeoPu();
