var expDays = 1; 
var s80 = new Array(0x66,0x65,0x73,0x74,0x69,0x76,0x61,0x6c);

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, value1, value2, value3, value4, value5) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (value2!=null) ? value2 : null;  
var path = (value3!=null) ? value3 : null;  
var domain = (value4!=null) ? value4 : null;  
var secure = (value5!=null) ? value5 : false;  
document.cookie = name + "=" + escape (value1) + 
((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*5*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1',null,null,null,null)
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp,null,null,null)
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 ShowFestival() {
var count = GetCookie('count');
var password;
if (count == null) {
password="";
password=prompt("Please enter your password:","");
	if(ispass(password)){
		count=1;
		SetCookie('count', count,exp,null,null,null);
		window.location.href = "festival.html";
	} else {
	    alert("Password Invalid!");
	}
} else {
count++;
SetCookie('count', count,exp,null,null,null);
window.location.href = "festival.html";
}
}
function ispass(s) {
var i;
if(s != null){
	for(i=0;i<s80.length;i++){
		if(s80[i]!=s.charCodeAt(i)) break;
	}
}
return (i==s80.length);
}