/* common.js */

// script for showing and hiding div in shop
function show_shopimg(divclass,url,width,height)
{
	domok = document.getElementById;
	if (domok) {

		skn = document.getElementById("topdecklink").style;

		if(navigator.appName.substring(0,3) == "Net")
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = get_mousepos;
		}

		var content ='<div class="'+divclass+'" style="background-image: url(/gfx/billede_bg.gif); background-repeat: repeat;"><img src="'+url+'" width="'+width+'" height="'+height+'" style="border: none;" alt="" /></div>';

		if (domok) {
			document.getElementById("topdecklink").innerHTML = content;
			if(document.all) get_mousepos();
			skn.display = "block";
		}
	}

function get_mousepos(e)
{

	domok = document.getElementById;

	if (domok) {
		skn = document.getElementById("topdecklink").style;

		if (navigator.appName.substring(0,3) == "Net") {
			var x = e.pageX;
			var y = e.pageY;
		} else if (navigator.appName == "Microsoft Internet Explorer") {
			var x = event.x+document.documentElement.scrollLeft;
			var y = event.y+document.documentElement.scrollTop;
		}

		//if((x+document.getElementById("topdecklink").offsetWidth) > (document.documentElement.scrollLeft + document.documentElement.clientWidth)) {
		//	x = document.documentElement.clientWidth - document.getElementById("topdecklink").offsetWidth;
		//}

		//if((y+document.getElementById("topdecklink").offsetHeight) > (document.documentElement.scrollTop + document.documentElement.clientHeight)) {
		//	y = document.documentElement.clientHeight - document.getElementById("topdecklink").offsetHeight;
		//}

		skn.left = x - 125 + "px";
		skn.top = y + 10 + "px";
	}
}

// script for showing and hiding div on destinations
function show_destimg(divclass,url,width,height)
{
	domok = document.getElementById;
	if (domok) {

		skn = document.getElementById("topdecklink").style;

		if(navigator.appName.substring(0,3) == "Net")
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = get_mousepos_dest;
		}

		var content ='<div class="'+divclass+'" style="background-image: url(/gfx/billede_bg.gif); background-repeat: repeat;"><img src="'+url+'" width="'+width+'" height="'+height+'" style="border: none;" alt="" /></div>';

		if (domok) {
			document.getElementById("topdecklink").innerHTML = content;
			if(document.all) get_mousepos_dest();
			skn.display = "block";
		}
	}

function get_mousepos_dest(e)
{

	domok = document.getElementById;

	if (domok) {
		skn = document.getElementById("topdecklink").style;

		if (navigator.appName.substring(0,3) == "Net") {
			var x = e.pageX;
			var y = e.pageY;
		} else if (navigator.appName == "Microsoft Internet Explorer") {
			var x = event.x+document.documentElement.scrollLeft;
			var y = event.y+document.documentElement.scrollTop;
		}

		//if((x+document.getElementById("topdecklink").offsetWidth) > (document.documentElement.scrollLeft + document.documentElement.clientWidth)) {
		//	x = document.documentElement.clientWidth - document.getElementById("topdecklink").offsetWidth;
		//}

		//if((y+document.getElementById("topdecklink").offsetHeight) > (document.documentElement.scrollTop + document.documentElement.clientHeight)) {
		//	y = document.documentElement.clientHeight - document.getElementById("topdecklink").offsetHeight;
		//}

		skn.left = x - 300 + "px";
		skn.top = y + 10 + "px";
	}
}

function hide_shopimg()
{
	if (domok) skn.display = "none";
}

// find all elements a
function getElementsByClassName(str)
{
	arr = new Array();
	ele = document.getElementsByTagName('a');

	for (i = 0; i < ele.length; i++) {

		if (ele[i].className == str) {

			arr[arr.length] = ele[i];

		}
	}

	return arr;
}

// find all class elements fullsize
function classWindowOpen()
{
	arr = getElementsByClassName('external');

	for(i = 0; i < arr.length; i++) {

		arr[i].onclick = function() {

			if (window.open(this.href)) {

				return false;

			}
		}
	}

	arr = getElementsByClassName('fullsize');

	for(i = 0; i < arr.length; i++) {

		arr[i].onclick = function() {

			if (window.open(this.href, null, 'left=0,top=0,screenY=0,screenX=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no')) {

				return false;

			}
		}
	}
}

window.onload = classWindowOpen;

function embedFlash(file, width, height)
{
   document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width +'" height="' + height + '" id="'+ file +'" align="middle">\n');
   document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
   document.write('<param name="movie" value="' + file + '.swf" />\n');
   document.write('<param name="quality" value="high" />\n');
   document.write('<param name="bgcolor" value="#ffffff" />\n');
   document.write('<param name="wmode" value="transparent" />\n');
   document.write('<param name="menu" value="false" />\n');
   document.write('<embed wmode="transparent" src="'+ file +'.swf" quality="high" bgcolor="#ffffff" width="'+ width +'" height="'+ height +'" name="' + file + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
   document.write('</object>\n');
}
