/**
 * @name jquery.dwcore.js
 * @author Dominik Wlazlowski
 * @description Standard operations to running jQuery (and UI based on jQuery)
 */

var jq = jQuery.noConflict();

// ...





function getViewportSize()
{
	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	 else if (typeof document.documentElement != 'undefined'
	     && typeof document.documentElement.clientWidth !=
	     'undefined' && document.documentElement.clientWidth != 0)
	 {
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	 
	 var r = new Array();
	 r['w'] = viewportwidth;
	 r['h'] = viewportheight;
	 
	 return r;
}


function fadeEfectClass(b) {
	
	this.changeOpac = changeOpac;
	this.fadeIn = fadeIn;
	this.fadeOut = fadeOut;
	
	var b = b;
	var opcaityTimer1;
	var opcaityTimer2;
	var opacityN = 1;
	
	function changeOpac(opacity, id) {
	    var object = document.getElementById(id).style;
	 try {   object.opacity = (opacity / 100); } catch (e) { }
	 try {   object.MozOpacity = (opacity / 100);} catch (e) { }
	 try {   object.KhtmlOpacity = (opacity / 100);} catch (e) { }
	 try {   object.filter = "alpha(opacity=" + opacity + ")";} catch (e) { }
	}
	
	
	function fadeIn(id) { 
		if(opacityN < 100) { 
			clearTimeout(opcaityTimer2);
			opacityN = opacityN+5;
			changeOpac(opacityN, id);
			opcaityTimer1 = setTimeout(b+'.fadeIn(\''+id+'\')', 15);
		}
	}
	
	function fadeOut(id) { 
		if(opacityN > 5) {
			clearTimeout(opcaityTimer1);
			opacityN = opacityN-5;
			changeOpac(opacityN, id);
			opcaityTimer2 = setTimeout(b+'.fadeOut(\''+id+'\')', 15);
		}
	}
}

var menu_button = new Array();
jq(document).ready(function() { 
	jq('#menu-container a img.up').each(function(key, val) {
		var exp = "menu_button["+key+"] = new fadeEfectClass('menu_button["+key+"]');";
		eval(exp);
		
		jq(val).mouseover(function() {
			eval("menu_button["+key+"].fadeIn('"+jq(val).attr('id')+"')");
		});
		
		jq(val).mouseout(function() {
			eval("menu_button["+key+"].fadeOut('"+jq(val).attr('id')+"')");
		});
	});
});
 
