var ns6 = document.getElementById && !document.all; // pro kontrolu zda jse o FF,NS6 nebo o IE

var preview;
var justlogged;
var mainForm;

function init()
{
    preview = new AdPreview("/services/adinfotext.aspx", 500, "preview");
    // refresh each 20s = 20000ms
	justlogged = new JustLoggedView("/services/justlogged.aspx", "justLogged", "justLoggedContent", "justLoggedCaption", "justLoggedWindowState", 20000);
	mainForm = window.document.getElementById("aspnetForm");

	adjustMainformPosition();
	window.onresize = adjustMainformPosition;
//		mainForm.style.left = "0px";
}

function adjustMainformPosition() {
//	alert("onResize");
//	alert (document.documentElement.clientWidth);
//	alert (mainForm.pixelWidth);
//	alert (mainForm.offsetWidth);
//	alert (justlogged.getWidth());

	var windowWidth = document.body.clientWidth;
	if(document.body.clientWidth) {
		windowWidth = document.body.clientWidth;
	} else {
		if (document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
	}
//	alert (windowWidth);
//	alert (mainForm.Width);
	if (windowWidth < mainForm.offsetWidth) {
		mainForm.style.left = "0px";
		return;
	}
	if (((windowWidth - mainForm.offsetWidth) / 2) > justlogged.getWidth()) {
		mainForm.style.left = (windowWidth - mainForm.offsetWidth) / 2 + "px";
//		mainForm.style.left = "0px";
	} else {
		if((windowWidth - mainForm.offsetWidth) < justlogged.getWidth()) {
			mainForm.style.left = (windowWidth - mainForm.offsetWidth) + "px";
		} else {
			mainForm.style.left = justlogged.getWidth() + "px";
		}
	}
//	alert(((windowWidth - mainForm.offsetWidth) / 2) > justlogged.getWidth());
//	alert(mainForm.style.left = (windowWidth - mainForm.offsetWidth) / 2 + "px");
//	alert (window.innerWidth);
//	alert (document.body.clientWidth);
}


function answer(id1, id2, color)
{
	window.document.getElementById(id1).style.backgroundColor = color;
	window.document.getElementById(id2).style.backgroundColor = color;
}
function answer_hide(id1, id2)
{
	window.document.getElementById(id1).style.backgroundColor = "#CCCCCC";
	window.document.getElementById(id2).style.backgroundColor = "#CCCCCC";
}


function switchmenu(elementId) 
{
	var elementIds = [
		"basic_menu",
		"menu_author_text",
		"menu_profile_notes",
		"menu_media",
		"menu_locations",
		"INTEREST_CATEGORY__LOOKING_FOR",
		"INTEREST_CATEGORY__HOBBIES",
		"INTEREST_CATEGORY__SPORTS",
		"INTEREST_CATEGORY__MUSIC",
		"INTEREST_CATEGORY__KITCHEN",
		"INTEREST_CATEGORY__SEXUAL_PRACTISES",
		"INTEREST_CATEGORY__FETISHES"
	];

	for (var iterator = 0; iterator < elementIds.length; iterator++) {
		var currElementID = elementIds[iterator];
		var visibility;
		var display;
		if (currElementID == elementId) {
			window.document.getElementById(currElementID).style.visibility = "visible";
			window.document.getElementById(currElementID).style.display = "block";
			document.getElementById("ctl00_ContentPlaceHolder1_hiddenField_ShowMenu").value = currElementID;
		} else {
			window.document.getElementById(currElementID).style.visibility = "hidden";
			window.document.getElementById(currElementID).style.display = "none";
		}
	}
}

function hide_or_unhide_elemement(elementId) {
	var element = window.document.getElementById(elementId);
	if (element != null) {
		if (element.style.display == "none") {
			element.style.display = "block";
		} else {
			element.style.display = "none";
		}
	}
}


