// javascript document
// info
// var w = 398;
// var h = 220;
// cinex2
// var w = 622;
// var h = 313;
// generic
var w = 491;
var h = 261;
var topPosition = (screen.height) ? (screen.height-h)/2 : 0;
var leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
var expDays = 1; // dias para que la cookie expire
// info
// var page = "popups/info/popup_info.html";
// cinex2
//var page = "popups/cinex2/";
// generic
var page = "/app/webroot/files/popups/generic/";
var windowprops = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',top='+topPosition+',left='+leftPosition;

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*24*60*60*1000));
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));
}


