$(document).ready(function () {
	//dropLineNavWithDelay();
	dropDownNavWithDelay();
});

function dropDownNavWithDelay() {
	var menu = $('ul#navigation li.menuparent');

	$(menu).removeClass('csshover'); //prevent css hover functionality (no delay with css)

	$(menu).mouseenter(function () {
		var selectedNav = $(this).children('ul').first();

		selectedNav.fadeTo(0, 0.0);
		selectedNav.css('left', 'auto');
		selectedNav.stop().animate({ opacity: 0.9 }, 200)
	});

	$(menu).mouseleave(function () {
		$(this).children('ul').first().css('left', '-999px');
	});
}

function dropLineNavWithDelay() {
	var navTimeout;
	$('ul#navigation li').removeClass('csshover');	//prevent css hover functionality (no delay with css)

	$('ul#navigation li.menuparent ').mouseenter(function () {
		var selectedNav = $(this).children('ul').first();
		navTimeout = setTimeout(function () { selectedNav.css('left', '0'); }, 250);
	});

	$('ul#navigation li.menuparent ').mouseleave(function () {
		clearTimeout(navTimeout); //cancel pending open
		var selectedNav = $(this).children('ul').first().css('left', '-999px');
	});
}


function fontSizer(vilken, somestring) {
	if (!document.getElementById) 
		return;
		geticon_1 = document.getElementById("icon_1");
		var is_selected=geticon_1.src.indexOf("_selected");
		if (is_selected==-1)
		{ 
			suffix_1 = geticon_1.src.substring(geticon_1.src.lastIndexOf('.'));
			geticon_1_var_selected = geticon_1.src.substring(0,geticon_1.src.lastIndexOf('.')) + "_selected" + suffix_1;
			geticon_1_var = geticon_1.src;
		}else{
			geticon_1_var_selected = geticon_1.src;
			geticon_1_var = geticon_1.src.replace("_selected","");
		}
		geticon_2 = document.getElementById("icon_2");
		is_selected=geticon_2.src.indexOf("_selected");
		if (is_selected==-1)
		{ 
			suffix_2 = geticon_2.src.substring(geticon_2.src.lastIndexOf('.'));
			geticon_2_var_selected = geticon_2.src.substring(0,geticon_2.src.lastIndexOf('.')) + "_selected" + suffix_2;
			geticon_2_var = geticon_2.src;
		}else{
			geticon_2_var_selected = geticon_2.src;
			geticon_2_var = geticon_2.src.replace("_selected","");
		}
		geticon_3 = document.getElementById("icon_3");
		is_selected=geticon_3.src.indexOf("_selected");
		if (is_selected==-1)
		{ 
			suffix_3 = geticon_3.src.substring(geticon_3.src.lastIndexOf('.'));
			geticon_3_var_selected = geticon_3.src.substring(0,geticon_3.src.lastIndexOf('.')) + "_selected" + suffix_3;
			geticon_3_var = geticon_3.src;
		}else{
			geticon_3_var_selected = geticon_3.src;
			geticon_3_var = geticon_3.src.replace("_selected","");
		}
    if(vilken==1){
        getBody = document.getElementsByTagName('body')[0];
	    getBody.style.fontSize = '62.5%';
		geticon_1.src = geticon_1_var_selected;
		geticon_2.src = geticon_2_var;
		geticon_3.src = geticon_3_var;
	    createCookie('Chloride_font_size','62.5%','7');
    }else if(vilken==2){
        getBody = document.getElementsByTagName('body')[0];
		getBody.style.fontSize = '68%';
		geticon_1.src = geticon_1_var;
		geticon_2.src = geticon_2_var_selected;
		geticon_3.src = geticon_3_var;
		createCookie('Chloride_font_size','68.0%','7');
    }else if(vilken==3){
        getBody = document.getElementsByTagName('body')[0];
		getBody.style.fontSize = '75%';
		geticon_1.src = geticon_1_var;
		geticon_2.src = geticon_2_var;
		geticon_3.src = geticon_3_var_selected;
		createCookie('Chloride_font_size','75.0%','7');
    }else if(vilken==4){
        getBody = document.getElementsByTagName('body')[0];
		getBody.style.fontSize = somestring;
			geticon_1.src = geticon_1_var;
			geticon_2.src = geticon_2_var;
			geticon_3.src = geticon_3_var;
			if(somestring=='62.5%'){
				geticon_1.src = geticon_1_var_selected;
			}else if(somestring=='68.0%'){
				geticon_2.src = geticon_2_var_selected;
			}else if(somestring=='75.0%'){
				geticon_3.src = geticon_3_var_selected;
			}else {}
		createCookie('Chloride_font_size',somestring,'7');
    }

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0){
		    
		    var somestring  = Right(c, 5);
		    fontSizer('4',somestring);
		    return;
		}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function Right(str, n){
    if (n <= 0)
    return "";
    else if (n > String(str).length)
    return str;
    else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
    }
}


function swfmc(movie,width,height)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="');
	// Width for Object TAG
	document.write(width);
	document.write('" height="');
	// Height for Object TAG
	document.write(height);
	document.write('">\n');
	// File for Object TAG
	document.write('<param name="movie" value="');
	document.write(movie);
	document.write('">\n');

	// Params for Object TAG

	document.write('<param name="wmode" value="transparent">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="menu" value="false">\n');

	// File for EMBED TAG
	document.write('<embed wmode="transparent" src="');
	document.write(movie);
	document.write('" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
	// Width for EMBED TAG
	document.write(width);
	document.write('" height="');
	// Height for EMBED TAG
	document.write(height);

	// Params for Object TAG
	document.write('" menu="false"></embed>\n');
	document.write('</object>');
}