// JavaScript Document
var http = false;
var http2 = false;

if(navigator.appName == "Microsoft Internet Explorer") {
	http = new ActiveXObject("Microsoft.XMLHTTP");
	http2 = new ActiveXObject("Microsoft.XMLHTTP");
} else {
	http = new XMLHttpRequest();
	http2 = new XMLHttpRequest();
}

function load_content(url, obj) {
	//http.abort();
	http.open("GET", url, true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange=function() {
		if(http.readyState == 4) {
    		document.getElementById(obj).innerHTML = http.responseText;
		} else {
			document.getElementById(obj).innerHTML = '<p>Loading...</p>';
		}
	}
	http.send(null);
	document.getElementById("result").innerHTML = "";
}

function load_image(url2, obj2) {
	http2.abort();
	http2.open("GET", url2, true);
	http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http2.onreadystatechange=function() {
		if(http2.readyState == 4) {
    		document.getElementById(obj2).innerHTML = http2.responseText;		
		} else {
			document.getElementById(obj2).innerHTML = '<p>Loading...</p>';
		}
	}

	http2.send(null); 
	
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	if (el.style.display != "none") {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}	
}

function hide_div(obj) {
	var div = document.getElementById(obj);
	if (div.style.display != "none") {
		div.style.display = 'none';
	}
	else {
		div.style.display = 'none';
	}	
	
}

function show_div(obj) {
	var div = document.getElementById(obj);
	if(div.style.display == 'none') {
		div.style.display = 'block';
	} else {
		div.style.display = '';
	}
}

function confirm_delete(url) {
	if(window.confirm("Are you sure you want to delete this entry?")) {
		//load_content('http://localhost/projects/7stars/index.php?q=delcanvas', 'showcanvas');
		location.href=url;
	}
}

function popupWindow(page,width,height){
	window.open(page,"Print","menubar=no,width="+width+"px,height="+height+"px,toolbar=no,scrollbars=1");
}

function highlight(obj, c){
	alert(c);
	document.getElementById(obj).style.backgroundColor = "#"+c;
}

function load_favourites(){
	load_content("pages/favourites.php","content-area");	
}