function toggleFormImage(obj, imgObject) {
    eval("obj.src = "+imgObject+".src");
}

function hideElement(sElement) {
	oElement = document.getElementById(sElement);
	oElement.style.display = "none";
}

function showElement(sElement) {
	oElement = document.getElementById(sElement);
	oElement.style.display = "";
}

function moveElement(sElement,left,top) {
	clearTimeout(ElementTimer);
	if (sElement != sElementActive) {
		if (document.getElementById(sElementActive)) {
			document.getElementById(sElementActive).style.left = "-2000px";
		}
		document.getElementById(sElement).style.left = left+"px";
		document.getElementById(sElement).style.top = top+"px";
		sElementActive = sElement;
	}
}

function setElementTimer() {
	clearTimeout(ElementTimer);
	ElementTimer = setTimeout("moveElementOut()", 500);
}

function moveElementOut() {
	document.getElementById(sElementActive).style.left = "-2000px";
	sElementActive = null;
}

function preloadImages() {
    document.preload = new Array();
    if (document.images) {
        for (var i = 0; i < preloadImages.arguments.length; i++) {
            document.preload[i] = new Image();
            document.preload[i].src = preloadImages.arguments[i];
        }
    }
}

function popup(url,x,y,scrollbars) {
    if (scrollbars != "yes") {
        scrollbars = "no";
    }
    popupWindow = window.open(url,"popup","width="+x+",height="+y+",resizeable=no,status=no,locationbar=no,scrollbars="+scrollbars+",screenX=150,screenY=100");
    popupWindow.focus();
}

function getWindowSize() {
	var x,y;
	if (self.innerHeight) {
		// All except Explorer
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight)	{
		// Explorer 6 Strict Mode
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		// other Explorers
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	} else {
		x = y = -1;
	}
	return new Array(x,y);
}

function resizeWindow(x,y) {
	if (self.innerHeight) {
		// All except Explorer
		self.innerWidth = x;
		self.innerHeight = y;
	} else if (document.documentElement && document.documentElement.clientHeight)	{
		// Explorer 6 Strict Mode
		document.documentElement.clientWidth = x;
		document.documentElement.clientHeight = y;
	} else if (document.body) {
		// other Explorers
		document.body.clientWidth = x;
		document.body.clientHeight = y;
	}
}

function maximizeWindow() {
	windowSize = getWindowSize();
	if ((windowSize[0] < 870) || (windowSize[1] < 600)) {
		window.moveTo(0,0)
		window.resizeTo(screen.width,screen.height)
	}
}

function generateMouseover() {
	// Generate Mouseover Effect
	$(".msover").hover(function() {
		generateMouseOver(this);
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
		generateMouseOut(this);
	});

	$("input[@type=image]").addClass("submit");
	$("input[@type=submit]").addClass("submit");

	$("input[@type=image]").hover(function() {
		generateMouseOver(this);
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
		generateMouseOut(this);
	});
	
	$("input[@type=submit]").hover(function() {
		$(this).addClass("over");
	}, function() {
		$(this).removeClass("over");
	});
	
	function generateMouseOver(object) {
		var src_no = object.src;
		var src_ms = src_no;
		var Regex = /(.*\/)(.*)(-no|-act)\.(gif|jpg|png)/;
		// Get the pure image name
		Regex.exec(src_no);
		if(RegExp.$3 == "-no") {
			src_ms = RegExp.$1 + RegExp.$2 + "-ms." + RegExp.$4;
		}
		if(RegExp.$3 == "-act") {
			src_ms = RegExp.$1 + RegExp.$2 + "-act-ms." + RegExp.$4;
		}
		object.src = src_ms;
	}
	
	function generateMouseOut(object) {
		var src_ms = object.src;
		var src_no = src_ms;
		var Regex = /(.*\/)(.*)-(act-ms)\.(gif|jpg|png)/;
		// Get the pure image name
		Regex.exec(src_ms);
		if(RegExp.$3 != "act-ms") {
			var Regex = /(.*\/)(.*)-(ms)\.(gif|jpg|png)/;
			// Get the pure image name
			Regex.exec(src_ms);
		}
		if (RegExp.$3 == "ms") {
			src_no = RegExp.$1 + RegExp.$2 + "-no." + RegExp.$4;
		}
		if (RegExp.$3 == "act-ms") {
			src_no = RegExp.$1 + RegExp.$2 + "-act." + RegExp.$4;
		}
		object.src = src_no;
	}
	
}

function generateStrongLinkSpecials() {
	linktext = $("strong a.internal-link-standalone").html();
	linktext = '<span class="strongLinkArrow">'+linktext+'</span>';
//	$("strong a.internal-link-standalone").html(linktext);
}

function pageInit() {
	generateMouseover();
	generateStrongLinkSpecials();
	if (window.generateDynamicContent) {
		generateDynamicContent();
	}
	if (window.dynamicFormular) {
		dynamicFormular();
	}
}

// On Document Ready call pageInit
$(document).ready(pageInit);
