//INIT
jQuery( function() {
	jQuery("#noscript").addClass("js");

	// swf
	AC_FL_RunContent = 0;

	// font resize
	jQuery("#fontDecrease").click( function() {
		var _s = parseInt(jQuery("body").css("fontSize")); // reads value in px
			if (!isNaN(_s)) {
				jQuery("body").css("font-size", _s - 2 + "px");
			}
		});
	jQuery("#fontIncrease").click( function() {
		var _s = parseInt(jQuery("body").css("fontSize")); // reads value in px
			if (!isNaN(_s)) {
				jQuery("body").css("font-size", _s + 2 + "px");
			}
		});
	
	//extend all links with the class nyroModal so that we can show only the parsys leftContent
	//modify url and add .lightbox.show.
	


	$("a.nyroModal").each(function(i) {
		var href = this.href;
		if (href.indexOf("localhost")>=0 || href.indexOf("devday1")>=0 || href.indexOf(hostname)>=0 || href.indexOf("egl")>=0 || href.indexOf("10.54.50.193")>=0 || href.indexOf("axponet")>=0) {
			var withoutDotHtml = href.substring(0, href.lastIndexOf("."));
			var newLink = withoutDotHtml + ".lightbox.show.html";
			this.href = newLink;
		}
	 }); 
	
	 
		//Hover Function for main_navigation_home
	  $("#main_navigation_home li").mouseover(function(){
     	jQuery(this).css("background-image", "url(/internet/egl/img/bg_green_navigation_li_hover.png)");
    }).mouseout(function(){
      jQuery(this).css("background-image", "url(/internet/egl/img/bg_green_navigation_li.png)");
    });


	if (!$.cookie('playonce')) {
		$.cookie('playonce', 'true', { expires: 2, path: '/'});
	}
	
	beginsWith = function(a, b, i) { 
		if (i==false) { 
			return (b == a.substring(0, b.length)); 
		} else { 
			return (b.toLowerCase()	== a.substring(0, b.length).toLowerCase()); 
		} 
	}
	
	// Set referrer if client was before inside egl-website. Otherwise read set cookie
	$("a.back").attr("href", function(e) {
		if(document.referrer) {
			hostnames = new Array(hostname, "devday1", "staday", "10.54.50.193", "egl-axi-author.axponet.ch");
			for(var i = 0; i < hostnames.length; i++) {
				var url = document.location.protocol + "//" + hostnames[i];
				if(url == document.referrer.substring(0, url.length)) {
					return document.referrer;
				}
			}
		} 
	});
});