/*************/
/** content **/
/*************/
var curSect, DEBUG = false, content = ['home_news|bg1.jpg',
	[null, 'videoflux_live|bg1.jpg', 'videoflux_features|bg2.jpg', 'videoflux_details|bg3.jpg', 'videoflux_demo|bg4.jpg', 'videoflux_buy.php|bg5.jpg', ],
	[null, 'download_fx|bg3.jpg', 'download_texture|bg1.jpg', 'download_footage|bg2.jpg', 'download_updates|bg5.jpg', 'download_demo|bg5.jpg'],
	[null, 'support_faq|bg3.jpg', 'support_manual|bg4.jpg', 'support_helpdesk|bg1.jpg'],
	[null, 'gallery_video|bg1.jpg', 'gallery_photo|bg2.jpg', 'gallery_djs_events|bg3.jpg', 'gallery_awards|bg4.jpg', 'gallery_links|bg5.jpg'],
	[null, 'company_about|bg2.jpg', 'company_people|bg4.jpg', 'company_sales|bg5.jpg', 'company_contact|bg1.jpg']
];

function displayInfo(data){
	if(data[0]){
		data[0] = data[0].split('\|');
		setBG(data[0].shift());
	}
	if(data[1]){
		document.getElementById('contentDiv').innerHTML = data[1];
		//showPicturesIE();
		setTimeout('showPicturesIE()', 300);
	}
}
function doLogin(){
	HTTP.call('loadPage.php', [['page', 'login'], ['user', username = document.getElementById('txtUser').value], ['pass', document.getElementById('txtPass').value]], setLogin);
}
function doLogout() {
	HTTP.call('loadPage.php', [['page', 'login'], ['user', ''], ['pass', '']], setLogin);
}
function loadPage(mainCat, subCat){
	if (mainCat && subCat) info = content[mainCat][subCat].split('\|');
	else info = content[0].split('\|');
	HTTP.call('loadPage.php', [['page', info.shift()], ['background', info.join('|') || '']], displayInfo);
}
function openPayWin(){
	window.open('about:blank', 'pay', 'width=800,height=600,resizable,status=yes,scrollbars=yes');
}
function openWindow (URL, windowName, width, height) {
	if (!windowName) windowName = "popup";
	if (!width) width = "400";
	if (!height) height = "400";
	var left = (window.screen.availWidth / 2) - (width / 2) - 2;
	var top = (window.screen.availHeight / 2) - (height / 2) + 40;
	window.open(URL, windowName , "width=" +width+ ",height=" +height+ ",location=no,menubar=no,status=no,toolbar=no,scrollbars=no,left=" +left+ ",top=" +top);
}
function setBG(bg){
	if(bg) document.getElementById('containerDiv').style.backgroundImage = 'url(media/' + bg + ')';
}
function setLogin(data){
	if(data[2] == 2 || data[2] == 1) { /* accept all users, active/inactive */
		document.getElementById('loginDivInput').innerHTML = 'logged in as <strong>'+username+'</strong>&nbsp; <input class="logBut" onclick="doLogout()" type="button" value="logout">';
	}
	else {
		document.getElementById('loginDivInput').innerHTML = '<strong>user</strong> <input class="login" type="text" id="txtUser" size="20">&nbsp; <strong>pass</strong> <input class="login" type="password" id="txtPass" size="20">&nbsp; <input class="logBut" onclick="doLogin()" type="button" value="login">';
		username = "";
	}
	if(data[0]){
		data[0] = data[0].split('\|');
		setBG(data[0].shift());
	}
	if(data[1]) document.getElementById('contentDiv').innerHTML = data[1];
}
function showPicturesIE() {		 
		for (i=0; i<document.images.length; i++) document.images[i].src = document.images[i].src; // beacause IE stops showing pictures after loading iframe;
}