// Browser 1.0
// 22-06-2007
// Benzin (HardClub)
// Ricardo Moutinho

var isFull = false;

function browserInit(){
	window.onresize = resizeHandler;
	resizeHandler();
	
}

function openProposta(imageURL){
	var url = "novo/media/images/propostas/" + imageURL;
	testwindow= window.open (url, "MobiliHard","resizable=1,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,directories=0,width=1050,height=700");
	testwindow.moveTo(0,0);
}

function openTH(userID, email, pass, idioma){
	var myform=document.createElement("form");

	var fldUserID=document.createElement("input");
	var fldEmail=document.createElement("input");
	var fldPass=document.createElement("input");
	var fldIdioma=document.createElement("input");

	fldUserID.setAttribute("type","hidden");
	fldUserID.setAttribute("value",userID);
	fldUserID.setAttribute("name","userid");

	fldEmail.setAttribute("type","hidden");
	fldEmail.setAttribute("value",email);
	fldEmail.setAttribute("name","email");

	fldPass.setAttribute("type","hidden");
	fldPass.setAttribute("value",pass);
	fldPass.setAttribute("name","pass");

	fldIdioma.setAttribute("type","hidden");
	fldIdioma.setAttribute("value",idioma);
	fldIdioma.setAttribute("name","idioma");

	var url = "../../novo/html/main/initTalkhard.cfm";

	//myform.setAttribute("onsubmit","window.open('','talkhard','resizable=1,location=0,status=0,scrollbars=0,toolbar=0,menubar=0,directories=0,width=220,height=200')");
	myform.setAttribute("action",url);
	myform.setAttribute("name", "form");
	myform.setAttribute("method", "POST");
	myform.setAttribute("target", "talkhard");
	myform.setAttribute("id", "formID");

	myform.appendChild(fldUserID);
	myform.appendChild(fldEmail);
	myform.appendChild(fldPass);
	myform.appendChild(fldIdioma);
	document.getElementsByTagName('body')[0].appendChild(myform);

	testwindow = window.open ('', "talkhard","resizable=1,location=0,status=0,scrollbars=0,toolbar=0,menubar=0,directories=0,width=550,height=350");
	testwindow.moveTo(0,0);

	form = document.getElementById("formID");

	form.submit();

	
}

function setFullscreen(full){
	isFull = full;
	resizeHandler();
}

function resizeDiv(divID, width, height){
	
	e=document.getElementById(divID);

	if (isFull == true){
		var minWidth = 990;
		var minHeight = 570;
	
		var maxWidth = width;
		var maxHeight = height;
		
		if (width > minWidth){
			e.style.width = width + 'px';
		}
		else {
			e.style.width = minWidth + 'px';
		}

		if (height > minHeight){
			e.style.height = height + 'px';
		}
		else {
			e.style.height = minHeight + 'px';
		}
		document.getElementById('flashcontent').style.marginTop = "0px";
		document.getElementById('flashcontent').style.top = "0%";
		document.getElementById('flashcontent').style.marginLeft = "0px";
		document.getElementById('flashcontent').style.left = "0%";
	}
	else
	{
		var minWidth = 990;
		var minHeight = 570;
	
		var maxWidth = 990;
		var maxHeight = 570;
		
		if ((height > minHeight) && (height < maxHeight)){
			e.style.height = height + 'px';
			document.getElementById('flashcontent').style.position = "relative";
			document.getElementById('flashcontent').style.marginTop = "0px";
			document.getElementById('flashcontent').style.top = "0px";
		}
		else if (height > maxHeight)
		{
			e.style.height = maxHeight + 'px';
			var targetTop = -(maxHeight/2) + 'px';
			document.getElementById('flashcontent').style.marginTop = targetTop;
			document.getElementById('flashcontent').style.top = "50%";
			document.getElementById('flashcontent').style.position = "absolute";
		}
		else if (height < minHeight){
			document.getElementById('flashcontent').style.marginTop = "0px";
			document.getElementById('flashcontent').style.top = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
	
	
		if ((width > minWidth) && (width < maxWidth)){
			e.style.width = width + 'px';
			document.getElementById('flashcontent').style.marginLeft = "0px";
			document.getElementById('flashcontent').style.left = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
		else if (width > maxWidth)
		{
			e.style.width = maxWidth + 'px';
			var targetLeft = -(maxWidth/2) + 'px';	
			document.getElementById('flashcontent').style.marginLeft = targetLeft;
			document.getElementById('flashcontent').style.left = "50%";
			document.getElementById('flashcontent').style.position = "absolute";
		}
		else if (width < minWidth){
			document.getElementById('flashcontent').style.marginLeft = "0px";
			document.getElementById('flashcontent').style.left = "0px";
			document.getElementById('flashcontent').style.position = "relative";
		}
	}
}


function resizeHandler(){
	var w = document.body.offsetWidth-21;
	var h = document.body.offsetHeight-4;
	//alert(w);
	resizeDiv('flashcontent', w, h)
}