//jQuery onReady

$(document).ready(function(){



$('.csc-mailform-field').each(function(){
	if($(this).find('input').attr('type') == "checkbox"){
		$(this).addClass("checkbox");
	}
});

//---
//border fix for news
if($('.news-single-imgcaption').length == 0){
$('.extrainfo:first').css({"border":"none","padding-top":"0","margin-top":"0"});
}

//---
// Border fix for contacts
$('.tx-contacts-pi1 .address:last').addClass("last");

//---
//pdf links target
//---
$('#innercontent p a').each(function(){
	var ref = $(this).attr('href');
	ref = ref.split(".");
	var last = ref.length;
	if(ref[last-1] == "pdf"){
		$(this).attr("target", "_blank");
	}
	if(ref[last-1] == "doc"){
		$(this).attr("target", "_blank");
	}
});


//---
//topheader
//---
var imgwidth = $('#headers td:eq(1)').find('img:eq(0)').attr("width");
if(imgwidth == 182){
	$('.breadcrumbs').css("width", 576);
	$('#headers td:eq(0)').css("width", 576);
	$('#headers td:eq(1)').css({"width": 182,"text-align": "right"});
}
if(imgwidth > 182){
	$('.breadcrumbs').css("width", 384);
	$('#headers td:eq(0)').css("width", 384);
	$('#headers td:eq(1)').css({"width": 374,"text-align": "right"});
}

var h2width = $('#headers h2').width();
if(h2width > 0){
	$('.breadcrumbs').css("width", 384);
	$('#headers td:eq(0)').css("width", 384);
	$('#headers td:eq(1)').css({"width": 374});
}


//----- 	
// Switch stylesheets starts
//-----

var c = readCookie('style');

if (c) {
	switchStylestyle(c);
}

$('.big').click(function() {

	var relatt = this.getAttribute("rel");
       	switchStylestyle(relatt); 	
	//alert("test");
        return false;
}); 	

$('.small').click(function() {

	var relatt = this.getAttribute("rel");
        
       	switchStylestyle(relatt);
        return false;
});

$('.middle').click(function() {

	var relatt = this.getAttribute("rel");
        
       	switchStylestyle(relatt); 	
   	return false;
});

//-----
// Switch stylesheets ends
//-----

}); // End jQuery onReady

function switchStylestyle(styleName)
{
        $('link[@rel*=style][@title]').each(function(i)
        {
                this.disabled = true;
                if (this.getAttribute('title') == styleName) this.disabled = false;
        });
        createCookie('style', styleName, 365);
}


// Ends all 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 end

