
function isDefined(property) {
	return (typeof property != 'undefined');
}

// Targets
function externalLinks() {
	
	if (!document.getElementsByTagName)
	return;
	
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0;i<anchors.length;i++) { 
		var anchor = anchors[i];
		if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external")) {
			anchor.target = "_blank";
		}
	}
}

function blurLinks() {
	lnks	= document.getElementsByTagName("a");
	
	for(i=0;i<lnks.length;i++) {	
		if ((lnks[i].getAttribute("rel") == null) || (lnks[i].getAttribute("rel") == "")) {
			lnks[i].onfocus		= new Function("this.blur()");
		}
	}
	
	// Input Buttons
	inpts	= document.getElementsByName("input");
	
	for(i=0;i<inpts.length;i++) {
		inpts[i].onfocus= new Function("this.blur()");
	}
}

function loadHeader() {
                var so = new SWFObject("data/assets/" + BaseURL + "/flash/header_ani_" + Lang + ".swf", "Game Overview", "905", "109", "6", "#FFFFFF");
                so.addParam("wmode", "transparent");
                so.write("FlashOverlay");
}

function correctPNG() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			img.style.visibility = "hidden";
			var src = img.src;
			var div = document.createElement("DIV");
			div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')"
			div.style.width = img.width + "px";
			div.style.height = img.height + "px";
			if (img.parentElement.href) {
				div.style.cursor = "hand";
			}
			img.replaceNode(div);
			img.style.visibility = "visible";
		}
	}
}

// call rolloverInit when document finishes loading
if (isDefined(window.addEventListener)) {
	window.addEventListener("load", RunFunctions, false);
}

else if (isDefined(window.attachEvent)) {
	window.attachEvent("onload", RunFunctions);
}


function loadFonts() {
	
					sIFR.replace(font, { selector: 'h1',css: ['.sIFR-root { color: #8266A8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#8266A8; text-decoration: none;}'], wmode:'transparent', selectable: false});
					
		// Headers			
		sIFR.replace(font, { selector: 'h2',css: ['.sIFR-root { color: #FFFDDA; text-align: left; font-size: 16px;   }'], wmode:'transparent', selectable: false});
		
			// Headers			
		sIFR.replace(font, { selector: '.PonyClubHeader',css: ['.sIFR-root {min-height:27px; color: #FFFDDA; text-align: left; font-size: 17px;   }'], wmode:'transparent', selectable: true});
			
						// Headers			
		sIFR.replace(font, { selector: '.UpdatesHeader',css: ['.sIFR-root {min-height:27px; color: #FFFDDA; text-align: left; font-size: 17px;   }'], wmode:'transparent', selectable: true});
								
				sIFR.replace(font, {selectable: false, selector: 'h3',css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}'], wmode:'transparent'});
		
		
	// Custom Fonts with Javascript	
		
		
  sIFR.replace(font, {
    selector: '.download_printables'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { downloadPrintables(fi.getAncestor()); }
});


  sIFR.replace(font, {
    selector: '.download_screensaver'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { downloadScreensaver(fi.getAncestor()); }
});

  sIFR.replace(font, {
    selector: '.download_posters'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { downloadPoster(fi.getAncestor()); }
});

  sIFR.replace(font, {
    selector: '.download_wallpapers'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { downloadWallpaper(fi.getAncestor()); }
});
  
  
    sIFR.replace(font, {
    selector: '.download_desktop'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { downloadDesktopBuddy(fi.getAncestor()); }
});
		
  sIFR.replace(font, {
    selector: '.active_tips'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { goToTips()(fi.getAncestor()); }
});
  
    sIFR.replace(font, {
    selector: '.active_games'
    ,css: ['.sIFR-root { color: #8266A8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#8266A8; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { goToMiniGames()(fi.getAncestor()); }
});
  
    sIFR.replace(font, {
    selector: '.active_downloads'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { goToDownloads()(fi.getAncestor()); }
});
  			
	    sIFR.replace(font, {
    selector: '.active_ponyclub'
    ,css: ['.sIFR-root { color: #2599C8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#1C7195; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { goToPonyClub()(fi.getAncestor()); }
});
	


    sIFR.replace(font, {
    selector: '.active_buygame'
    ,css: ['.sIFR-root { color: #8266A8; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#8266A8; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { showBuyOptions()(fi.getAncestor()); }
});
	
	
					sIFR.replace(font, { selector: 'h4',css: ['.sIFR-root {color: #2599C8; text-align: center; font-size: 14px;  height: 22px; text-decoration:none; margin-right:10px; float:left;  }', 'a {color:#2599C8; text-decoration: none; margin-left:30px;}', 'a:hover {color:#1C7195; text-decoration: none;}'], wmode:'transparent', selectable: true});	
		
		
		    sIFR.replace(font, {
    selector: '.play_ds'
    ,css: ['.sIFR-root { color: #D84188; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#D84188; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { playTrailerDS()(fi.getAncestor()); }
});	
		
		
				    sIFR.replace(font, {
    selector: '.play_wii'
    ,css: ['.sIFR-root { color: #D84188; text-align: center; font-size: 18px; margin-top:10px;  height: 22px; text-decoration:none; }', 'a {color:#2599C8; text-decoration: none;}', 'a:hover {color:#D84188; text-decoration: none;}']
    ,selectable: false, wmode: 'transparent',
onRelease: function(fi) { playTrailerWii()(fi.getAncestor()); }
});	
		

}



function RunFunctions() {
	externalLinks();
	blurLinks();
	loadHeader();
	loadFonts();
	if ((window.attachEvent) && (!isDefined(document.body.style.maxHeight))) {
		correctPNG();
	}
}


function goToTips() {

	window.location.href = "/tips";
	
}

function goToMiniGames() {

	window.location.href = "/play-games";
	
}

function goToDownloads() {

	window.location.href = "/downloads";
	
}

function goToPonyClub() {

	window.location.href = "/club";
	
}



function WarningAlert(url, msg) {

	var answer = confirm (msg)
	if (answer)
window.open(url,'_blank');
	else

return false;

}


function showBuyOptions() {
		
        document.getElementById('OneThirdPurpleTopBuy').style.background = 'url(data/assets/' + BaseURL + '/images/panels/small/buy_game_top2.png)';

			        document.getElementById('OneThirdPurpleBodyBuyHome').style.background = 'url(data/assets/' + BaseURL + '/images/panels/small/buy_over.jpg)';
					
			document.getElementById('OneThirdPurpleBuyBottom').innerHTML = "";
			
		if(Lang == "de") {
			
			document.getElementById('OneThirdPurpleBodyBuyHome').innerHTML = "<img src='data/assets/" + BaseURL + "/images/logos/amazon_de.png' align='left' style='margin-left:15px; margin-top:10px;' onclick=\"WarningAlert('http://www.amazon.de/gp/search?ie=UTF8&keywords=%26%2334%3BPony%20Friends%202%26%2334%3B&tag=httwwweidde-21&index=videogames&linkCode=ur2&camp=1638&creative=6742', 'M\\u00F6chtest du die Pony Friends 2-Website wirklich verlassen?\\n\\nDu wechselst dadurch auf eine Seite, die nicht von Eidos betrieben wird. Eidos ist f\\u00FCr die Inhalte dieser Seite nicht verantwortlich.\\n\\nBitte deine Eltern um Hilfe, wenn du dir nicht sicher bist.');\" />";
			
		} else if(Lang == "es") {
			
			
		} else if(Lang == "it") {

			document.getElementById('OneThirdPurpleBodyBuyHome').innerHTML = "<img src='data/assets/" + BaseURL + "/images/logos/gamestop_it.png' align='left' style='margin-left:15px; margin-top:10px;' onclick=\"WarningAlert('http://www.gamestop.it/default.aspx?quickSearch=pony%20friends%202&random=719682332', 'Sei sicuro di voler lasciare il sito di Pony Friends 2?\\n\\nStai per visitare un sito che non \\u00E8 di propriet\\u00E0  di Eidos ed Eidos non \\u00E8 responsabile per alcun contenuto che si trovi su quel sito.\\n\\nIn caso di dubbio, consulta i tuoi genitori.');\" />" +  "<img src='data/assets/" + BaseURL + "/images/logos/multiplayer_it.png' align='left' style='margin-left:15px; margin-top:10px;' onclick=\"WarningAlert('http://multiplayer.com/catalog/advanced_search_result.php?search_in_description=0&inc_subcat=1&keywords=pony+friends+2', 'Sei sicuro di voler lasciare il sito di Pony Friends 2?\\n\\nStai per visitare un sito che non \\u00E8 di propriet\\u00E0  di Eidos ed Eidos non \\u00E8 responsabile per alcun contenuto che si trovi su quel sito.\\n\\nIn caso di dubbio, consulta i tuoi genitori.');\" />";



		} else if(Lang == "fr") {
			
			document.getElementById('OneThirdPurpleBodyBuyHome').innerHTML = "<img src='data/assets/" + BaseURL + "/images/logos/eidos_fr.png' align='left' style='margin-left:15px; margin-top:10px; cursor:pointer;' onclick=\"WarningAlert('http://www.eidoshop.fr/', 'Veux-tu vraiment quitter le site Internet de Pony Friends 2?\\n\\nTu t\\u0027appr\\u00E0tes acc\\u00E0der \\u00E0 un site n\\u0027appartenant pas \\u00E0 Eidos, et Eidos n\\u0027est pas responsable du contenu de ce site.\\n\\nEn cas de doute, demande l\\u0027autorisation de tes parents.');\" />";
			
		}
		
		else if(Lang == "en-us") {
			
			document.getElementById('OneThirdPurpleBodyBuyHome').innerHTML = "<img src='data/assets/" + BaseURL + "/images/logos/amazon_us_wii.jpg' align='left' style='margin-left:10px; margin-top:10px; cursor:pointer;' onclick=\"WarningAlert('http://www.amazon.com/Pony-Friends-2-Nintendo-Wii/dp/B002HWRMU0/ref=sr_1_1?ie=UTF8&s=videogames&qid=1262742224&sr=8-1', 'Are you sure you would like to leave the Pony Friends 2 website?\\n\\nYou are about to go to a site that is not owned by Eidos and Eidos is not responsible for any content on that site.\\n\\nPlease check with your parents if you\\u0027re unsure.');\" /><img src='data/assets/" + BaseURL + "/images/logos/amazon_us_ds.jpg' align='left' style='margin-left:10px; margin-top:10px; cursor:pointer;'onclick=\"WarningAlert('http://www.amazon.com/Pony-Friends-2-Nintendo-DS/dp/B0014BDUBU/ref=sr_1_2?ie=UTF8&s=videogames&qid=1262742125&sr=8-2', 'Are you sure you would like to leave the Pony Friends 2 website?\\n\\nYou are about to go to a site that is not owned by Eidos and Eidos is not responsible for any content on that site.\\n\\nPlease check with your parents if you\\u0027re unsure.');\" />";
			
		} else {

			document.getElementById('OneThirdPurpleBodyBuyHome').innerHTML = "<img src='data/assets/" + BaseURL + "/images/logos/amazon_uk.png' align='left' style='margin-left:15px; margin-top:10px; cursor:pointer;' onclick=\"WarningAlert('http://www.amazon.co.uk/Pony-Friends-2-Nintendo-DS/dp/B002UD538O/ref=sr_1_3?ie=UTF8&s=videogames&qid=1257793367&sr=8-3', 'Are you sure you would like to leave the Pony Friends 2 website?\\n\\nYou are about to go to a site that is not owned by Eidos and Eidos is not responsible for any content on that site.\\n\\nPlease check with your parents if you\\u0027re unsure.');\" />" + "<img src='data/assets/" + BaseURL + "/images/logos/play_uk.png' align='left' style='margin-left:15px; margin-top:10px; cursor:pointer;' onclick=\"WarningAlert('http://www.play.com/Search.aspx?searchtype=allproducts&searchstring=pony+friends+2&page=search&pa=search', 'Are you sure you would like to leave the Pony Friends 2 website?\\n\\nYou are about to go to a site that is not owned by Eidos and Eidos is not responsible for any content on that site.\\n\\nPlease check with your parents if you\\u0027re unsure.');\" />" + "<img src='data/assets/" + BaseURL + "/images/logos/hmv_uk.png' align='left' style='margin-left:15px; margin-top:10px; cursor:pointer;' onclick=\"WarningAlert('http://hmv.com/hmvweb/simpleMultiSearch.do?searchUID=&pGroupID=0&adultFlag=false&primaryID=0&simpleSearchString=pony+friends+2', 'Are you sure you would like to leave the Pony Friends 2 website?\\n\\nYou are about to go to a site that is not owned by Eidos and Eidos is not responsible for any content on that site.\\n\\nPlease check with your parents if you\\u0027re unsure.');\" />";



}
	
}