<!-- Begin
var expDays = 1; // number of days the cookie should last

var page = "onetimepopup.asp";
var windowprops = "width=175,height=320,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

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) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*1));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
   }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
   }
}
//  End -->



function addgamepop(id,list) {
    popupWin = window.open('/pages/profile/add_game.php?pid=' + id + '&list=' + list, 'trackpop', 'width=260,height=440,resizable=1,scrollbars=0');
}

function track_contact(contact_username, mode, force_reload ) {
    if('undefined' == typeof force_reload) {force_reload = true;}
    addcontactpop( contact_username, mode );
    
    if ( force_reload ) {
        // reload the current page with the updated data.
        window.location.reload( force_reload );
    }
}

function addcontactpop(contact_username,mode) {
  popupWin = window.open('/pages/profile/track_contact.php?mode=' + mode + '&username=' + contact_username, 'contactpop', 'width=260,height=260,resizable=1,scrollbars=0');
}

function videoplayerpop(sid,pid,rgroup) {
  rgroup = rgroup ? '&rgroup=' + rgroup : '';
  popupWin = window.open('/pages/video_player/popup.php?sid=' + sid + '&pid=' + pid + rgroup, 'videoplayerpop', 'width=810,height=700,resizable=0,scrollbars=0');
  popupWin.focus();
}

function pollPop() {
  pollwin = window.open('/pages/modules/poll.php','pollwin','height=500,width=400');
  pollwin.focus();
}

function chatpop() {
  popupWin = window.open('/chat/chat.php','chatpop','width=620,height=420,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=1');
}

function prefspop(tab) {
  popupWin = window.open('/pages/preferences/' + tab + '.php','prefspop','width=778,height=480,scrollbars=1,menubar=0,toolbar=0,location=0,status=0,resizable=1');
}

function pmpop(tab,user) {
  popupWin = window.open('/pages/pm/' + tab + '.php?to=' + user,'pmpop','width=778,height=480,scrollbars=1,menubar=0,toolbar=0,location=0,status=0,resizable=1');
}

function emblempop(id) {
  popupWin = window.open('/pages/profile/show_emblem.php?id=' + id,'emblempop','width=330,height=360,scrollbars=auto,menubar=0,toolbar=0,location=0,status=0,resizable=1');
  popupWin.focus();
}


function open_image_viewer(pid,img,sid,path,caption,numimg) {
    var page = 'imagebig.asp?image=' + pid + '&num=' + img + '&nimage=' + sid;
    if(path) {
        page += '&path=' + path;
    }
    if(caption) {
        page += '&caption=' + caption;
    }
    if(numimg) {
        page += '&numimg=' + numimg;  
    }

    x = window.open(page, '_blank', 'location=0,menubar=0,statusbar=0,toolbar=0,resizable=1,scrollbars=1,width=1024,height=748,left=0,top=0');

}

function open_image_viewer_for_path_gallery(img,numimg,path,caption) {
    var page = '/pages/image_viewer/frame.php?img=' + img + '&numimg=' + numimg + '&path=' + path;
    if(caption) {
        page += '&caption=' + caption;
    }

    x = window.open(page, '_blank', 'location=0,menubar=0,statusbar=0,toolbar=0,resizable=1,scrollbars=0,width=800,height=600,left=0,top=0');

}


function open_cover(img) {
    var page = '../public/Cover/' + img + '.jpg';
    
    x = window.open(page, '_blank', 'location=0,menubar=0,statusbar=0,toolbar=0,resizable=1,scrollbars=0,width=400,height=400,left=0,top=0');

}

function open_image(img) {
    var page = img;
    
    x = window.open(page, '_blank', 'location=0,menubar=0,statusbar=0,toolbar=0,resizable=1,scrollbars=0,width=400,height=400,left=0,top=0');

}

function genpop(url,name,width,height,resize,scroll) {
    popupWin = window.open(url, name,'width='+width+',height='+height+',resizable='+resize+',scrollbars='+scroll+',location=0,menubar=0,statusbar=0,toolbar=0');
}


function lunchboxOpen(lunchID, testo) {
    document.getElementById('lunch_' + lunchID).style.display = "block";
    document.getElementById('clasp_' + lunchID).innerHTML = "<a href=\"javascript:lunchboxClose('" + lunchID + "','" + testo + "');\">Chiudi " + testo + "</a>";
}
function lunchboxClose(lunchID, testo) {
    document.getElementById('lunch_' + lunchID).style.display = "none";
    document.getElementById('clasp_' + lunchID).innerHTML = "<a href=\"javascript:lunchboxOpen('" + lunchID + "','" + testo + "');\">" + testo + "</a>";
}

function lunchboxImgOpen(lunchID, testo) {
    document.getElementById('lunch_' + lunchID).style.display = "block";
    document.getElementById('clasp_' + lunchID).innerHTML = "<a href=\"javascript:lunchboxImgClose('" + lunchID + "','" + testo + "');\"><img border=0 src=images/" + testo + "></a>";
}
function lunchboxImgClose(lunchID, testo) {
    document.getElementById('lunch_' + lunchID).style.display = "none";
    document.getElementById('clasp_' + lunchID).innerHTML = "<a href=\"javascript:lunchboxImgOpen('" + lunchID + "','" + testo + "');\"><img border=0 src=images/" + testo + "></a>";
}



function poppo(url,width,height) {
    popupWin = window.open(url, 'Regolamento','width='+width+',height='+height+',resizable=1,scrollbars=1,location=0,menubar=0,statusbar=0,toolbar=0');
}

// use this instead of body.onload (see below for usage)

function addEvent(obj, evType, fn, useCapture){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    }
    else {
        alert("Handler could not be attached");
    }
}




	

