var searchentered=0;
var starsearchentered=0;
var registerWindow = null;
function checkClear(obj)
{
	EMail = obj.value;
	if(EMail=="user@domain.de")
	{
		obj.value= "";
	}
}

function enterSeachbox(Obj, what)
{

	if(searchentered==0 && what=="title")
	{
		Obj.value='';
		searchentered=1;
	}
	if(starsearchentered==0 && what=="star")
	{
		Obj.value='';
		starsearchentered=1;
	}
}

function showMovie(URL, res)
{
	URL += "&LGID=" + lgid;
	if( CORE=="Soft")
	{
		document.location.href=URL;
		return;
	}

	if( res!="1m")
	{
		movieWindow = window.open(URL,'htmlplayer','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=800,height=700');
	}
	else
	{
		movieWindow = window.open(URL,'htmlplayer','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=800,height=700');
	}
	movieWindow.focus();
}


function showFreeMovie(URL)
{
	movieWindow = window.open(URL,'htmlplayer','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=340,height=260');
	movieWindow.focus();
}

function movepic(img_name,img_src) {
	document[img_name].src=img_src;
}

function displayError(ErrorText, ID)
{
	if(ErrorText.length>0)
	{
		document.getElementById(ID).innerHTML = ErrorText;
	}
}

function showPromotionWindow( movie)
{
	win = window.open("/index.php?event=showPromotionForm&movie="+movie+"&"+sid, "Promote", "width=400,height=180");
	win.focus();
}

function showEmailHelp()
{
	win = window.open("/index.php?event=showemailhelp&"+sid, "EMailHelp", "width=800,height=650,resizable=1,scrollbars=1");
	win.focus();
}

function checkRatingStars( pos, maxStars, movieid)
{
	for ( var i=0; i<pos; i++)
	{
		document.getElementById( "ratingstar_" + movieid + "_" + i).src = "/images/ratemovie_new.gif";
	}

	for ( var i=pos; i<maxStars; i++)
	{
		document.getElementById( "ratingstar_" + movieid + "_" + i).src = "/images/ratemovie_emp_new.gif";
	}

	document.forms["rating_"+movieid].rating.value = pos;
}

function getRecensionContainer()
{
	var containerid = "recensions_container";
	if ( document.getElementById( containerid))
	{
		var container = document.getElementById( containerid);
	}
	else
	{
		var container = document.createElement( "div");
		container.id = containerid;
		container.style.width 			= "800px";
		container.style.height 			= "600px";
		container.style.backgroundColor = "#FFFFFF";
		container.className 		= "contentTableMiddle";
		document.getElementById("site").appendChild( container);
	}
	return container;
}

function showRecensions( intMovieID)
{
	var container = getRecensionContainer();
	var recensionsdiv = document.getElementById( "recension_" + intMovieID);
	container.style.display 	= "";
	container.innerHTML 		= recensionsdiv.innerHTML;
	centerOnScreen( container);
}

function hideRecensions( intMovieID)
{
	var container = getRecensionContainer();
	container.style.display = "none";
}

function showSupportEmailForm(subject)
{
	window.open( "/index.php?event=showContactForm&subject=" + subject, "contact", "width=500,height=600,resizable=1,scrollbars=1");
}

function showMovieCover()
{
	var coverdiv = document.getElementById( "CoverLarge");
	coverdiv.style.display = "";
	centerOnScreen( coverdiv);
}

function hideMovieCover()
{
	var coverdiv = document.getElementById( "CoverLarge");
	coverdiv.style.display = "none";
}

function showRecensionPopup( rating, movie, urlextra)
{
	if ( !urlextra)
	{
		urlextra = "";
	}
	window.open( "/index.php?event=showRecensionForm&movie=" + movie + "&rating=" + rating + "&" + urlextra, "recension", "width=800,height=600,resizable=1,scrollbars=1");
}

function showInfo( type, lgid)
{
	FE = window.open('/text/showtext.php?LGID=' + lgid + '&type=' + type,'Extern','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=400,height=400');
	FE.focus();
}

function showMoreRecensions( movie)
{
	window.open( "/index.php?event=showMoreRecensions&movie=" + movie, "recensions", "width=800,height=600,resizable=1,scrollbars=1");
}

/* Centers an element in another element
*
* @param      {String} innerid                         The ID of the element to center
* @param     {String} outerid                         The ID of the surrounding element
*/
function centerElement(innerid, outerid)
{
	var innerelem = document.getElementById(innerid);
	var old_display = innerelem.style.display;
	innerelem.style.display = '';   // Temporarily show element
	var innerwidth = innerelem.offsetWidth;
	var innerheight = innerelem.offsetHeight;
	// Workaround (!§"$ IE6!!)
	if (innerheight == 0)
	{
		innerheight = document.body.offsetHeight;
	}
	innerelem.style.display = old_display;

	var outerelem = document.getElementById(outerid);
	var old_display = outerelem.style.display;
	outerelem.style.display = '';   // Temporarily show element
	var outerwidth = outerelem.offsetWidth;
	var outerheight = outerelem.offsetHeight;
	// Workaround (!§"$ IE6!!)
	if (outerheight == 0)
	{
		outerheight = document.body.offsetHeight;
	}
	outerelem.style.display = old_display;

	var top = outerheight / 2 - innerheight / 2;
	var left = outerwidth / 2 - innerwidth / 2;

	innerelem.style.position = 'absolute';
	innerelem.style.top = '350px';
	innerelem.style.left = left + 'px';
}

function showNotActivatedLayer()
{
	try {
		centerElement( "not_activated", "site");
		document.getElementById( "not_activated").style.display = 'block';
	}
	catch( ex) {}
}

function switchMovieDescription( movieId, type, ev)
{
	var div = document.getElementById("moviedescription_" + movieId);
	if ( type == "over")
	{
		if ( !ev)
		{
			ev = window.event;
		}
		if ( navigator.appName == "Microsoft Internet Explorer")
		{
			x = ev.clientX;
			y = ev.clientY;
		}
		else
		{
			x = ev.pageX;
			y = ev.pageY;
		}

		div.style.zIndex	= 999;
		div.style.position 	= "relative";
		div.style.left		= (x + 5) + 'px';
		div.style.top 		= (y + 5) + 'px';
		div.style.display 	= "";
	}
	else
	{
		div.style.display = 'none';
	}
}

function getNewsContent( loggedIn)
{
	ServerEventManager.addServerEvent( '?event=getnewscontent&jsinput:container=newsbox&jsinput:loggedIn=' + loggedIn, null, null, true);
	ServerEventManager.executeServerEvents();
}

function turnCover( frontCover, backCover)
{
	if (document.getElementById('MoviePrevie').src == VODURL + backCover)
	{
		document.getElementById('MoviePrevie').src = frontCover;
	}
	else
	{
		document.getElementById('MoviePrevie').src = backCover;
	}
}

function centerHandyOverlay()
{
	var overlay = document.getElementById( "handyoverlay");
	if ( overlay)
	{
		overlay.style.display = "";
		centerOnScreen( overlay);
		showHandyOverlayPage1();
	}
}

function showHandyOverlayPage1()
{
	document.getElementById( "handyoverlay_page1").style.display = "";
}

function showHandyOverlayPage2( transactioncode)
{
	document.getElementById( "handyoverlay_page1").style.display = "none";
	document.getElementById( "handyoverlay_page2").style.display = "";
	document.getElementById( "handy_transactioncode").value = transactioncode;
}

function showHandyOverlaySuccess()
{
	document.getElementById( "handyoverlay_page1").style.display = "none";
	document.getElementById( "handyoverlay_page2").style.display = "none";
	document.getElementById( "handyoverlay_success").style.display = "";
}

function showHandyOverlayError()
{
	document.getElementById( "handyoverlay_page1").style.display = "none";
	document.getElementById( "handyoverlay_page2").style.display = "none";
	document.getElementById( "handyoverlay_error").style.display = "";
}

function sendMobilePhone( voduserid, countryid)
{
	var phone = document.getElementById("mobilePhone").value;
	ServerEventManager.addServerEvent( '?event=mobileactions&jsinput:type=sendsms&jsinput:handynr=' +
		phone + '&jsinput:voduserid=' + voduserid + '&jsinput:countryid=' + countryid, null, null, true);
	ServerEventManager.executeServerEvents();
}

function sendMobilePIN()
{
	var pin = document.getElementById("mobilePIN").value;
	var transactioncode = document.getElementById("handy_transactioncode").value;
	ServerEventManager.addServerEvent( '?event=mobileactions&jsinput:type=checkpin&jsinput:pin=' + pin + '&jsinput:transactioncode=' + transactioncode, null, null, true);
	ServerEventManager.executeServerEvents();
}

function openRegisterWindow( url)
{
	registerWindow = window.open( url, 'RegisterUser','width=650,height=600,scrollbars=1');
	registerWindow.focus();
	setTimeout( "checkRegisterWindow()", 1000);
}

function checkRegisterWindow()
{
	if( !(registerWindow.closed)) {
		setTimeout( "checkRegisterWindow()", 1000);
	} else {
		registerWindow = null;
		window.document.location.href = "/index.php?event=registerdoafterfinishsignup&currentEvent=" + (location.href);
	}
}

function reloadSlots()
{
	ServerEventManager.addServerEvent( '?event=loadfreeslots', null, null, true);
	ServerEventManager.executeServerEvents();
}

