var windowsInternetExplorer=false;
var isiPhone=false;
var browserDetected=false;

function detectBrowser()
{
	if(browserDetected===false)
	{
		//check for IE
		windowsInternetExplorer=false;
		var appVersion=navigator.appVersion;
		if((appVersion.indexOf("MSIE")!=-1)&&(appVersion.indexOf("Macintosh")==-1))
		{
			windowsInternetExplorer=true;
		}
	}
	else
	{
		//check for iPhone
		var ua=navigator.userAgent.toLowerCase();
		var matchResult=ua.match(/applewebkit\/(\d+)/);
		if(matchResult)
		{
			isiPhone=(ua.indexOf("mobile/")!=-1);
		}
	}
	browserDetected=true;
}
/*function checkForMSIE(){
//used to need this, don't need it anymore
	var appVersion=navigator.appVersion;
	if(appVersion.indexOf("MSIE")!=-1){
		alert('Microsoft Explorer doesn\'t support transparent PNG images, which this site makes use of. We recommend using another web browser, such as Safari or Firefox.');
	}
}*/

function CMHighlightImage(sender){
	var imageName = "./img/buttons/" + sender.id + "_Over.png";
	sender.src = imageName;
	return true;
}
function CMUnhighlightImage(sender){
	var imageName = "./img/buttons/" + sender.id + ".png";
	sender.src = imageName;
	return true;
}
function setImageToElement(name, elementName)
{
	var rolloverName=name;
	var img=document.getElementById(elementName);
	if(img)
	{
		img.src=rolloverName;
	}
	return true;
}

function fillInBlank(){
	writeAFooter();
	writeBack();
	writeWelcomePiano();
}
function writeBack(){
	var f=document.getElementById('back');
	if (f){
		f.innerHTML = '<a href="Welcome.html"><img src="content/back.png" width="59" height="23" alt="Go back."></a>';
	}
}
function writeAFooter(){
	var f = document.getElementById("footer");
	if (f){
		f.innerHTML = '&copy; 2007-10, <a href="mailto:charlie@charliemonroe.net">Charlie Monroe</a>';
	}
}
function writeWelcomePiano()
{
	var f = document.getElementById('player');
	if (!f){
		return;
	}
	detectBrowser();
	var s;
	if(windowsInternetExplorer)
	{
		s = '<object id="charliemonroePiano" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="0" height="0" style="height: 0px; left: 0px; position: absolute; top: 663px; width: 75px; z-index: 1;" type="video/quicktime><param name="src" value="content/Charliemonroe-1.mp3" ><param name="controller" value="false" ><param name="autoplay" value="true"><param name="scale" value="tofit" ><param name="volume" value="100" ><param name="loop" value="true" ></object>';
	}else if(isiPhone){
		s = '<object id="charliemonroePiano" type="video/quicktime" width="75" height="16" style="height: 0px; left: 577px; position: absolute; top: 663px; width: 75px; z-index: 1; "><param name="src" value="content/Charliemonroe-1.mp3"><param name="controller" value="false"><param name="scale" value="tofit"></object>';
	}else{
		s = '<object id="charliemonroePiano" type="video/quicktime" width="0" height="0" data="content/Charliemonroe-1.mp3" style="height: 0px; left: 0px; position: absolute; top: 0px; width: 0px; z-index: 1; "><param name="src" value="content/Charliemonroe-1.mp3"><param name="controller" value="false"><param name="autoplay" value="true"><param name="scale" value="tofit"><param name="volume" value="100"><param name="loop" value="true"></object>';
	}
	f.innerHTML = s;
}

function checkForm(form){
	if (form){
		var f = document.getElementById('antispam');
		if (f.value.toLowerCase()!='marilyn'){
			alert('You haven\'t filled the control field (First name of Marilyn Monroe.).');
			return false;
		}
		f = document.getElementById('email');
		if (f){
			var email = f.value;
			if (email.indexOf('@')==-1 || email.indexOf('.')==-1){
				alert('This is not a valid email address.');
				return false;
			}
		}
		f = document.getElementById('text');
		if (f){
			if (f.value==''){
				alert('You need to enter some text.');
				return false;
			}
		}
		return true;
	}
	return false;
}

function showHover(item){
	var hover = document.getElementById('hoverBox');
	hover.style.left = (item.x - 10)+'px';
	hover.style.top = (item.y - 150) + 'px';
	
	if (item.name=="01"){
		hover.innerHTML = '		<br>		<ul>			<li>ODS tajný dům</li>			<li>Inzerce (dopisy)</li>			<li>Zubní pasta PADANÁ</li>			<li>Nápoj Padohlav</li>			<li>Dobročinný spolek<br>Dagmar Havlové</li>		</ul>';
	}else if (item.name=="02"){
		hover.innerHTML = '		<br>		<ul>			<li>Blbionář</li>			<li>Vznik USSSSAR</li>			<li>Kosmetika LoupLoup</li>			<li>Micheal Jackson</li>			<li>Šikanovaná manželka<br>Vladimíra Železného</li>		</ul>';
	}else if (item.name=="03"){
		hover.innerHTML = '		<br>		<ul>			<li>KSČM - znárodňování</li>			<li>Krávy jdou</li>			<li>Mobilní telefony s anténou</li>			<li>Iglú</li>			<li>Páprda s.r.o.</li>		</ul>';
	}else if (item.name=="04"){
		hover.innerHTML = '		<br>		<ul>			<li>Špidlův archív</li>			<li>El. proud je radioaktiv.</li>			<li>Inzerce (dopisy)</li>			<li>Deník Miloše Zemana</li>		</ul>';
	}else if (item.name=="05"){
		hover.innerHTML = '		<br>		<ul>			<li>Rozhovor s Bořivojem<br>Kapavkou</li>			<li>Tavení Eifelovky</li>			<li>Masokostní moučka ve whiskey</li>			<li>Letadla Lion 159F</li>			<li>Leonardo di Caprio</li> <li>Milostný dopis</li>		</ul>';
	}
	
	hover.style.display = "inline";
	
}

function showPaintingsHover(item){
	var hover = document.getElementById('paintingsHoverBox');
	hover.style.left = item.x - 260 +'px';
	hover.style.top = (item.y - 40) + 'px';
	if (item.id=="Sober"){
		hover.innerHTML = "<p>Before the Gods were born, people acted and thought soberly...</p>";
	}else if (item.id=="Stonehearted"){
		hover.innerHTML = "<p>...yet with the dawn of Gods, they turned into stonehearted robots, spreading misery and pain...</p>";
	}else if (item.id=="QueenOfMag"){
		hover.innerHTML = "<p>When the Gods (maggots) eventually took over the human souls, they started to abuse their powers and positions...</p>";
	}else if (item.id=="IncUnhuman"){
		hover.innerHTML = "<p>...killing the spirit of humanity, making humans incredibly unhuman.</p>";
	}else if (item.id=="WelcomeToHell"){
		hover.innerHTML = "<p>Yet there was one place that stood up to the self-called lords: Hell.</p>";
	}else if (item.id=="UpsideDown"){
		hover.innerHTML = "<p>And so a hero was born. Beelzebub decided to reach Heaven and bring down the rulers, thus freeing the mankind and bringing peace back on Earth.</p>";
	}else if (item.id=="SaveTheWorld"){
		hover.innerHTML = "<p>Beelzebub commits himself to the toughest quest ever: to save the world.</p>";
	}else if (item.id=="GatesOfHell"){
		hover.innerHTML = "<p>Beelzebub reaches the Gates of Hell, entering this world and seeing Golgotha, understanding that he's arrived too late to Save The World.</p>";
	}else if (item.id=="InTheWild"){
		hover.innerHTML = "<p>In The Wild peeks into Beelzebub's dealing with the insanity of this world, while trying to reach his dream: Heaven.</p>";
	}else if (item.id=="AllAlone"){
		hover.innerHTML = "<p>All Alone, left in this world without friends, without help, without a place to hide. All Alone against everyone.</p>";
	}else if (item.id=="ReachingSion"){
		hover.innerHTML = "<p>Half-dead, yet half-there. Beelzebub is near the end of his journey.</p>";
	}else if (item.id=="HeavensSoDamnCold"){
		hover.innerHTML = "<p>Beelzebub finally reaches his dream - Heaven - yet he finds it too cold for him to survive and stands before a decision whether to die for his dream or to live an unfulfilled life.</p>";
	}
	
	hover.style.display = "inline";
}

function hideHover(){
	var hover = document.getElementById('hoverBox');
	hover.style.display = "none";
}

function hidePaintingsHover(){
	var hover = document.getElementById('paintingsHoverBox');
	hover.style.display = "none";
}

