/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function($) {
	$(document).ready(function() {
        $('.styleswitch').click(function() {
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

    function switchStylestyle(styleName) {

        //var arr = $('#hauptnavigation ul li a img');

        if (styleName == 'big_style') {
            $('#hauptnavigation .fontsizesmall').css("display", "none"); /* added by CSD Mehdi Haresi */
            $('#hauptnavigation .fontsizebig').css("display", "");        /* added by CSD Mehdi Haresi */
            /* removed by CSD Mehdi Haresi
            jQuery.each(arr, function(i, val) {
                file = val.src;
                var newfile = file.substr(file.lastIndexOf('/'), file.length);
                var print = '';
                if (newfile.indexOf('_') == -1) { // ein nicht aktiv gesetztes element
                    print = newfile.replace(/\./g, '_big.');
                } else {
                    print = newfile.replace(/_/g, '_big_');
                }
                var path = file.substr(0, file.lastIndexOf('/'));
                var newFilePath = path + print;
                val.src = newFilePath;
            });
            */
            if ($.browser.msie && jQuery.browser.version == '7.0') {
                $("#hauptnavigation").css("top", "75px");
                $("#subnavigation3 hr").css("width", "83.22em");
                $("#content_main").css("margin", "0 -10px 7px 0");
                $("#subnavigation2 ul li").css("margin", "0 0 -5px 0");
                $("#content_main .content_prozent_66 #fom_hausnr, #content_main .content_prozent_66 #fom_stiege , #content_main .content_prozent_66 #fom_tuer, #content_main .content_prozent_66 #fom_vorwahl, #content_main .content_prozent_66 #fom_titel").css("width", "1.8em");
                $("#content_main .content_prozent_66 #fom_telnummer").css("width", "5.22em");
                $(".teaser_hoch img").css("margin-bottom", "-11.6em");
                $(".teaser_verteiler").css("width", "99%");
                $("#content_main .content_prozent_66 #button_suche").css("top", "-0.22em");
                $("#loginfeld #input_email, #loginfeld #input_passwort").css("margin-top", "0.11em");
                $("#content_footer").css("right", "1px");
                $("#content_footer_border").css("padding", "0 0 0 5px");
                $("#content_footer_border").css("margin", "-1.25em 1px 0 -5px");
                $("#content_footer").css("width", "75.15em");
                $(".hauptthema object, .hauptthema embed").css("height", "24.8em");
                $(".teaser .teaser_bild_text").css("margin-top", "-1em");
            }
            if ($.browser.msie && jQuery.browser.version == '8.0') {
                $(".teaser_hoch img").css("margin-bottom", "-12em");
                $(".teaser_hoch").css("min-height", "15.5em");
                $("#content_main .content_prozent_66 #button_suche").css("top", "0.44em");
                $(".hauptthema object, .hauptthema embed").css("height", "24.8em");
            }

        } else {
            $('#hauptnavigation .fontsizesmall').css("display", ""); /* added by CSD Mehdi Haresi */
            $('#hauptnavigation .fontsizebig').css("display", "none");        /* added by CSD Mehdi Haresi */
            /* removed by CSD Mehdi Haresi
            jQuery.each(arr, function(i, val) {
                file = val.src;
                var newfile = file.substr(file.lastIndexOf('/'), file.length);
                var print = '';
                if (newfile.indexOf('_big.') != -1) { // ist big
                    //				alert('element nicht big.');
                    print = newfile.replace(/_big\./g, '.');
                } else {
                    print = newfile.replace(/_big_/g, '_');
                }
                var path = file.substr(0, file.lastIndexOf('/'));
                var newFilePath = path + print;
                val.src = newFilePath;
            });
            */
            if ($.browser.msie && jQuery.browser.version == '7.0') {
                $("#hauptnavigation").css("top", "78px");
                $("#subnavigation3 hr").css("width", "83.44em");
                $("#content_main").css("margin", "0 -10px 5px 0");
                $("#subnavigation2 ul li").css("margin", "0 0 -4px 0");
                $("#content_main .content_prozent_66 #fom_hausnr, #content_main .content_prozent_66 #fom_stiege , #content_main .content_prozent_66 #fom_tuer, #content_main .content_prozent_66 #fom_vorwahl, #content_main .content_prozent_66 #fom_titel").css("width", "1.95em");
                $("#content_main .content_prozent_66 #fom_telnummer").css("width", "5.1em");
                $("#content_main .content_prozent_66 #button_suche").css("top", "-0.11em");
                $("#content_footer").css("right", "0");
                $("#content_footer_border").css("padding", "0 0 0 4px");
                $("#content_footer_border").css("margin", "-1.25em 0 0 -5px");
                $("#content_footer").css("width", "75.22em");
                $(".teaser_hoch img").css("margin-bottom", "-13em");
                $(".teaser_hoch .teaser_bild_text").css("margin-top", "-1em");
                $(".teaser .teaser_bild_text").css("margin-top", "-2em");
            }
            if ($.browser.msie && jQuery.browser.version == '8.0') {
                //$(".teaser_bild_text").css("top","-1em");
                $(".teaser_hoch img").css("margin-bottom", "-14em");
            }

        }
	
        $('link[@rel*=style][title]').each(function(i) {
			this.disabled = true;

            if (this.getAttribute('title') == styleName) {
                this.disabled = false;
            }
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
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) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions

