function setAsHome() {
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage(window.location.href);
}
function createBookmark() {
	title = "VSK.SK | Virtual Slovakia";
	url = "http://www.vsk.sk/";
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}
function Set_Cookie( name, value, expires, path, domain, secure ){
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ){expires = expires * 1000 * 60 * 60 * 24;}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie(check_name){
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;
	for ( i = 0; i < a_all_cookies.length; i++ ){
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name ){
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 ){cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ){return null;}
}

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function openPopupDetail(id, link) {
	newWin = window.open("http://www.vsk.sk/email/mailDetail.php?id=" + id + "&l=" + link, "", "width=550,height=650,status=1,scrollbars=1,resizable=1");
	newWin.focus();
	return false;
}
function openPopupReply(id, link) {
	newWin = window.open("http://www.vsk.sk/email/mailCompose.php?id=" + id + "&l=" + link, "", "width=550,height=650,status=1,scrollbars=1,resizable=1");
	newWin.focus();
	return false;
}
function openPopupCompose(id, link, type, rcp) {
	newWin = window.open("http://www.vsk.sk/email/mailCompose.php?id=" + id + "&l=" + link + "&t=" + type + "&rcp=" + rcp, "", "width=550,height=650,status=1,scrollbars=1,resizable=1");
	newWin.focus();
	return false;			
}
function goBack() {
	history.back();
}
function openBigNick() {
	newWin = window.open("http://www.vsk.sk/bn/index.php", "", "width=300,height=150,status=1,scrollbars=0,resizable=0");
	newWin.focus();
	return false;			
}
//ajax call
var httpRequester;
var messageID;

function callAjax(a, b, c) {
	var randID = Math.round(Math.random * 9999999);
	var serverSideURL = 'https://www.vsk.sk/libs/MailParse.php?id=';
	
	httpRequester = getHTTPRequestObject(); // Create the xml http object on the page load
	var couldProcess = false;

	messageID = Math.round(Math.random() * 99999999);

	if (!couldProcess && httpRequester) {
		httpRequester.open("POST", serverSideURL + escape(messageID), true);
		//httpRequester.onreadystatechange = processResponse;
		couldProcess = true;
		httpRequester.send(null);
	}
}
function getHTTPRequestObject() {
	var xmlHttpRequest;

	if (!xmlHttpRequest && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlHttpRequest = new XMLHttpRequest();
		} catch (exception) {
			xmlHttpRequest = false;
		}
	}
	return xmlHttpRequest;
}
function processResponse() {
	alert('received');
}
