// JavaScript Document
function Login(uname, password, script_file) {
	
	var url = "../inc/ajax/login.php";
	var params = "uname="+uname+"&passw="+password+"&script_file="+script_file;
	http.open("GET", url+"?"+params, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-Type", "text/html; charset=windows-1250");
    http.onreadystatechange = handleResponseLogin;
    http.send(null);
	
    document.getElementById('logindiv').innerHTML = '<div align="center" style=\"height:49px; padding-top:26px;\"><img src="http://www.bookmark.sk/images/body/working.gif" width="16" height="16"></div>';
	
}



function handleResponseLogin() {
    if(http.readyState == 4){
        if(http.status == 200 && http.responseText != '') {
            var response = http.responseText;
            var update = new Array();

            if(response.indexOf('|' != -1)) {
                update = response.split('|');
				
				if(update[27]=='') {
					
					location.href='home.html';
				}				
				
				if(update[26]=='signup') {
					
					location.href='home.html';
				}
				
                document.getElementById('logindiv').innerHTML = update[1];
                document.getElementById('logintitle').innerHTML = update[2];
                FullYear = update[3];
                FullMonth = update[4];
                FullDay = update[5];
                Hours = update[6];
                Minutes = update[7];
                Seconds = update[8];
                document.getElementById('L1_title').innerHTML = update[9];
                document.getElementById('L1_content').innerHTML = update[10];
                document.getElementById('L2_title').innerHTML = update[11];
                document.getElementById('L2_content').innerHTML = update[12];
                document.getElementById('L3_title').innerHTML = update[13];
                document.getElementById('L3_content').innerHTML = update[14];
                document.getElementById('C1_title').innerHTML = update[15];
                document.getElementById('C1_content').innerHTML = update[16];
                document.getElementById('C2_title').innerHTML = update[17];
                document.getElementById('C2_content').innerHTML = update[18];
                document.getElementById('C3_title').innerHTML = update[19];
                document.getElementById('C3_content').innerHTML = update[20];
                document.getElementById('R1_title').innerHTML = update[21];
                document.getElementById('R1_content').innerHTML = update[22];
                document.getElementById('R2_title').innerHTML = update[23];
                document.getElementById('R2_content').innerHTML = update[24];
                document.getElementById('menu').innerHTML = update[25];
				showInTime(FullYear,FullMonth,FullDay,Hours,Minutes,Seconds) 
                eval(update[28]);
            }
        }
    }
}

function waitForLogin() {
  if(!document.getElementById('logindiv').complete) {
    setTimeout('waitForLogin()',10);
  }
}


function showInTime(FullYear,FullMonth,FullDay,Hours,Minutes,Seconds) { 

	var curTime=new Date()
	var ct = curTime.getTime()
	
	var minutes = 1000 * 60;
	var hours = minutes * 60;
	
	var logTime=new Date()
	logTime.setSeconds(Seconds);
	logTime.setMinutes(Minutes);
	logTime.setHours(Hours);
	logTime.setMonth(FullMonth);
	logTime.setDate(FullDay);
	logTime.setYear(FullYear);
	var t = logTime.getTime()	
	var dt = ct - t + 10000;
	
	var he = dt/hours;
	var h = Math.floor(dt/hours);
	var hd = he - h;	
	
	var me = hd * 60
	var m = Math.floor(hd * 60);
	var md = me - m;	
	
	var se = md * 60
	var s = Math.floor(md * 60);
	var sd = se - s;		
	
	if (h<=9) 
	h="0"+h 
	
	if (m>59) 
	m=0 	
	if (m<=9) 
	m="0"+m 
	
	if (s>59) 
	s=0 	
	if (s<=9) 
	s="0"+s 
	
		
	document.getElementById('intime').innerHTML = h+":"+m+":"+s
	
	setTimeout("showInTime(FullYear,FullMonth,FullDay,Hours,Minutes,Seconds)",1000) 
} 
	