// Variabels for Slider in the middle



/* duration of all animation */

var animation_duration = 150;







// Variables for changing Moodimages



//total number of imgages to be changed 

var mood_image_length = 0;

//actual showed mood image

var actual_mood_image = 0;

//old showed mood image

var old_mood_image = 0;

// duration of Loop

var duration_of_loop = 8500;

// duraation of fade_in when a click is done

var fadein_duration_click = 500;

//Period which it takes to slide in new Image

var fadein_duration = 2000;

//true if change should be performed 

var do_moodarea_image_change = true;

//true if UserAgent is a mobile Browser (iPad, iPhone)

var browser_is_ipad = false;

var browser_is_iphone = false;

var browser_is_ie_6_or_7 = false;

var first_call = true;

var google_account;



var link_bg = 0;

function change_link_img(){
	
	$('.initiativ_link a img:eq('+link_bg+')').fadeOut();
	link_bg ++;
	if(link_bg > 1){
		link_bg = 0;
	}
	$('.initiativ_link a img:eq('+link_bg+')').fadeIn();
	
}





//init function 

$(document).ready(function() {	

	

	//alert (document.URL);

	// putting correct URL to Facebook

	$(".left_inner_content iframe.facebookLikeIframe").attr({'src': 'http://www.facebook.com/plugins/like.php?href=' + document.URL + '&amp;layout=standard&amp;show-faces=true&amp;width=500&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:400px; height:30px'});

	

	

	// function for changing moodimages

	init_change_moodarea_image();

	

	setInterval( "change_moodarea_image()", duration_of_loop );
	setInterval( "change_link_img()", duration_of_loop );

	$('.initiativ_link').css('height', $('.initiativ_link a img').height()+'px');
	$('.initiativ_link a').css('position','relative');
	$('.initiativ_link a img:eq(1)').css('display','none');
	$('.initiativ_link a img').each(function(){
		$(this).css('position','absolute');
	});

	

	// functions for slider

	var total_width = 945;

	

	//width of each element without any mouseover

	var fastlink_slider_default = parseInt(total_width / 4);

	

	// width of element mouse is over 

	var fastlink_slider_out = parseInt(fastlink_slider_default * 1.25);

	

	// width of element / left position of middle div for elements mouse is over an other element

	var fastlink_slider_in =  parseInt((total_width - fastlink_slider_out) / 3 );



	

	/*

	 * init slider

	 */

	//slide_default(fastlink_slider_default);

	

	

	

	

	/* init content_area */

	$(".content_area_container").css({"display" : "block"});



	

	// applies corners to specified elements 

	apply_corners();

	

	

	

	

	$("div.right_inner_content div.contenttag ul").hover(

			function(){

				tag_enter_hovers($(this));

			},

			function(){

				tag_leave_hovers($(this));

			}	

	);

	

	

	$("div.bottom_menu_area_container_col_head_parent").hover(

			function(){

				bottom_menu_head_enter_hovers($(this));

			},

			function(){

				bottom_menu_head_leave_hovers($(this));

			}	

	);	

	

	

	$("div.linkBtn_parent").hover(

			function(){

				bottom_menu_head_enter_hovers($(this));

			},

			function(){

				bottom_menu_head_leave_hovers($(this));

			}	

	);

	

	$("div.teaserlinks_parent").hover(

			function(){

				bottom_menu_head_enter_hovers($(this));

			},

			function(){

			bottom_menu_head_leave_hovers($(this));

			}	

	);

	

	

	$("div.teaserlinks_parent_moodarea").hover(

			function(){

				bottom_menu_head_enter_hovers($(this));

			},

			function(){

				bottom_menu_head_leave_hovers($(this));

			}	

	);

	

	$("div.pagebrowser_parent").hover(

			function(){

				bottom_menu_head_enter_hovers($(this));

			},

			function(){

				bottom_menu_head_leave_hovers($(this));

			}	

	);

	

	

	

	

	$("table.formtable input").focus(function() {  

		$(this).addClass("active");   

	});  

	$("table.formtable input").blur(function() {  

		$(this).removeClass("active");   

	});  

	

	$("table.formtable textarea").focus(function() {  

		$(this).addClass("active");   

	});  

	$("table.formtable textarea").blur(function() {  

		$(this).removeClass("active");   

	}); 

	

	$("table.formtable select").focus(function() {  

		$(this).addClass("active");   

	});  

	$("table.formtable select").blur(function() {  

		$(this).removeClass("active");   

	}); 



	$(".left_inner_content div.hr:last").not(".left_inner_content .search-list-container div.hr:last").remove();

	//$(".left_inner_content div.hr:last").remove();

	

	//Handling horizontal Line right site if no Content

	// if there is no content between Teaser and TopThemen, the horizontal Line will

	// be removed

	if ($("div.container_teaserlinks").next().hasClass("container_topthemen"))

	{

		$("div.container_topthemen").children("div.hr:first").remove();

	}

	

	//handling for memberform

	handle_memberform();



	// Banner Handling

	var cookiestring = /CVPPDCBottomBanner=hide/g;

	var cookiecontent = document.cookie;



	//check if Cookie ist set

	if (cookiestring.test(cookiecontent)) {

		$("#container .bottom_banner_bg").hide();

	}

	else

	{			

		$("#container .bottom_banner_bg").hide();

		$("#container .bottom_banner_bg").wait(1500);

		$("#container .bottom_banner_bg").fadeIn(500);				

//elmar
//		$('.bottom_banner_bg div.linkBtn_parent div.linkBtnMore').corner(settings_hover_button).next().corner(settings_hover_button);

//elmar
//		$('.bottom_banner_bg div.linkBtn_parent div.linkBtnMore_hover').corner(settings_hover_button).next().corner(settings_hover_button);

	}			



	// Settin gOption for Scrolling 

	var agent = navigator.userAgent.toLowerCase(); 

	

	

	if (agent.match(/msie 6.0/))

	{

		browser_is_ie_6_or_7 = true;

		

		if (first_call)

		{

			$(window).scrollTop();

			first_call = false;	

		}

		apple_scroll();

	}

	

	

	if (agent.match(/mobile/) && agent.match(/safari/) && agent.match(/ipad/))

	{

		browser_is_ipad = true;

		if (first_call)

		{

			$(window).scrollTop();

			first_call = false;	

		}

		apple_scroll();

		$('.bottom_banner_bg').remove();

	}	

	if (agent.match(/mobile/) && agent.match(/safari/) && agent.match(/iphone/))

	{

		browser_is_iphone = true;

		if (first_call)

		{

			$(window).scrollTop();

			first_call = false;

		}

		apple_scroll();	

		$('.bottom_banner_bg').remove();

	}	

	$(window).scroll(function () { 

			apple_scroll();

    });

	

	google_analytics()

	



});



function apple_scroll()

{

	var $_noscroll_height;

	var $_scroll_height;

	if (browser_is_ipad)

	{

		if ($(window).height() > $(window).width())

		{

			//alert ("hochformat iPad");

			$_noscroll_height = 53;

			$_scroll_height = 53;

		}

		else

		{

			//alert ("querformat iPad");

			$_noscroll_height = 30;

			$_scroll_height = 30;

		}		

	}	

	if (browser_is_iphone)			

	{

		if ($(window).height() > $(window).width())

		{

			//alert ("hochformat iPhone");

			$_noscroll_height = 53;

			$_scroll_height = 250;

		}

		else

		{

			//alert ("querformat iPhone");

			$_noscroll_height = 27;

			$_scroll_height = 150;

		}

	}

	if (browser_is_ipad || browser_is_iphone)

	{

		if ($(window).scrollTop() == 0)

		{

			$(".bottom_banner_bg").css({"position":"absolute", "top": ($(window).scrollTop() +  $(window).height() + $_noscroll_height ) - $(".bottom_banner_bg").height()  });

		}

		else

		{

			$(".bottom_banner_bg").css({"position":"absolute", "top": ($(window).scrollTop() +  $(window).height() + $_scroll_height ) - $(".bottom_banner_bg").height()  });

		}

	}

	

	if( browser_is_ie_6_or_7 ){

		$(".bottom_banner_bg").css({"width":$(window).width()});

		$(".bottom_banner_bg").css({"position":"absolute" ,"top": ($(window).scrollTop() +  $(window).height() ) - $(".bottom_banner_bg").height()  });

	}

	

	

}





// function reset slider

function slide_default(fastlink_slider_default)

{

	//stop all animation

	$("#fastlink_slider div:animated").stop();

	

	// loop each div in .fastlink_slider_middle

	$("#fastlink_slider .fastlink_slider_middle div").each( function() {

		// set fastlink_slider_default 

		$(this).animate({"width": fastlink_slider_default + "px"},animation_duration);

	});



	// set left position div.fastlink_slider_middle

	slide_middle_left_position(fastlink_slider_default);

	

	// reset img hover

	hover_img_default();

}





//set left position div.fastlink_slider_middle

function slide_middle_left_position(fastlink_slider_in)

{

	$("#fastlink_slider .fastlink_slider_middle").animate({"left": fastlink_slider_in + "px"},animation_duration);

}









//reset img hover

function hover_img_default()

{

	// loop all div in slider

	$("#fastlink_slider div").each( function(){

		// even img are css = block

		$("#fastlink_slider div img:even").css({"display": "block"});

		

		// even img are css = none

		$("#fastlink_slider div img:odd").css({"display": "none"});

	});

}









/*

 * MOODAREA

 * 

 * Image Change effect

 * 

 */



/* Init-function

 * called when page is loaded

 */

function init_change_moodarea_image()

{

	// set total number of images to be slided

	mood_image_length =  ($("#container_moodarea_image div.moodimage").length);

	

	if (mood_image_length > 1)

	{

	

		// set actual img to front 

		$("#container_moodarea_image div.moodimage").css({"z-index": "30"});

		$("#container_moodarea_image div.moodimage:first").css({"z-index": "32"});

		$("#container_moodarea_image div.moodimage:last").css({"z-index": "31"});

		

		for (i=1; i<=mood_image_length; i++)

		{			

			$("div.moodarea_img_changer").append("<div class=\"moodarea_img_changer_element_parent\" onclick=\"change_moodarea_image_onclick(" + (i-1) + ")\" onmouseover=\"hover_img_changer_element_enter(" + (i-1) + ")\" onmouseout=\"hover_img_changer_element_leave(" + (i-1) + ")\"><div class=\"moodarea_img_changer_element\">" + i + "</div><div class=\"moodarea_img_changer_element_hover\">" + i + "</div></div>")

		}

		moodarea_img_changer_set_active(0);

	}

	else

	{

		do_moodarea_image_change = false;

	}



}







function change_moodarea_image()

{	

	if (do_moodarea_image_change)

	{

	

		// set the old images of last loop (pre pre images to back)

		$("#container_moodarea_image div.moodimage").each(function(){

			

			if ($(this).css("z-index") == "31")

			{

				$(this).css({"z-index" : "30", "opacity" : "1.0"});

			}

			else if ($(this).css("z-index") == "32")

			{

				$(this).css({"z-index" : "31", "opacity" : "1.0"});

			}

		});

		

		// checks which images is next

		//if it is last image set it to first, otherwise set it plus one (++)

		if (actual_mood_image == mood_image_length-1)

		{

			actual_mood_image = 0;

		}

		else 

		{

			actual_mood_image++;

		}



		// set image to faded in to front an set opacity to 0.0

		// fade in actual image in front 

		$("#container_moodarea_image div.moodimage:eq(" + actual_mood_image + ")").css({"display": "none", "z-index": "32"}).fadeIn(fadein_duration);

		

		// hover of small box right side is switched, when new item is faded in 50%

		setTimeout(function(){		

			moodarea_img_changer_set_active(actual_mood_image);			

		},fadein_duration/2);

	}	

}





function change_moodarea_image_onclick(clicked_moodarea_image)

{



		do_moodarea_image_change = false;	

		$("#container_moodarea_image div.moodimage:animated").stop();

		

		

		// clones the clicked image an fades it in

		$("#container_moodarea_image div.moodimage:eq(" + clicked_moodarea_image + ")")

									.clone()

									.css({"display": "none", "z-index": "33"})

									.appendTo("#container_moodarea_image")

									.fadeIn(fadein_duration_click, function(){

			

			// after cloned image is fully visible, all other images are et to background

			$("#container_moodarea_image div.moodimage").each(function(){

				

				if ($(this).css("z-index") == "31")

				{

					$(this).css({"z-index" : "30"});

				}

				else if ($(this).css("z-index") == "32")

				{

					$(this).css({"z-index" : "31"});

				}

			});

			

			// image wihich was cloned is set to visible and z-index is behind cloned item

			$("#container_moodarea_image div.moodimage:eq(" + clicked_moodarea_image + ")").css({"display": "block", "z-index":"32", "opacity" : "1.0"});

			// cloned image will be removed, image, which was cloned is now actual

			$("#container_moodarea_image div.moodimage:last").remove();		

		});

		

		// hover of small box right side is switched, when cloned item is faded in 50%

		setTimeout(function(){	

			moodarea_img_changer_set_active(clicked_moodarea_image);	

			actual_mood_image = clicked_moodarea_image;

		},fadein_duration_click/2);	

	

	

	setTimeout(function (){do_moodarea_image_change = true;}, duration_of_loop);

}



function hideBottomBanner() {

	$.ajax({

		url: '/?eID=ajaxbottomba&hideBottomBanner=1'

	});

	/* 

	var delete_time = new Date();

	//12 hours

	var interval = delete_time.getTime() + (1 * 12 * 60 * 60 * 1000);

	delete_time.setTime(interval);

	//document.cookie = "CVPPDCBottomBanner=hide; expires=" + delete_time.toGMTString();

	document.cookie = "CVPPDCBottomBanner=hide";

	*/

	$('.bottom_banner_bg').fadeOut(500);

}



function reload_captcha()

{

	$('span.captcha_img').html('<img width="140" height="40" alt="" src="typo3conf/ext/captcha/captcha/captcha.php?time=' + new Date() + '">');



}



function set__setAccount(_account) {

	google_account =  _account;

	

}



function google_analytics() {

/*	var _gaq = _gaq || [];     

	_gaq.push(['_setAccount', google_account]);     

	_gaq.push(['_trackPageview']);     

	(function() {     

		var ga = document.createElement('script'); 

		ga.type = 'text/javascript'; 

		ga.async = true; 

		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';  

		var s = document.getElementsByTagName('script')[0]; 

		s.parentNode.insertBefore(ga, s);   

		

		})();

*/}







/***************************************************

 * Hovers and Corners

 ***************************************************/







function apply_corners()

{	

	$("ul.mood_menu_elements ul").each(function(){

		$(this).children("li:first").each(function(){
//elmar

		//	$(this).children("div.div_second:first").css({"border-top":"0px solid transparent"});	

		//	$(this).children("div.div_first:first").css({"border-top":"0px solid transparent"});

		});

	});

	



	

	

	$("ul.mood_menu_elements ul").each(function(){

		var index_of_li = 0

		var length_of_li = $(this).children("li").length;		

		if (length_of_li == 0)

		{

			

		}		

		else if (length_of_li == 1)

		{

			$(this).children("li").each(function(){	

				$(this).children("li div.div_first").after( function() {

					return $(this).clone().addClass("menu_hover first_singleline");

				});

				$(this).children("li div.div_second").after( function() {

					return $(this).clone().addClass("menu_hover second_singleline");

				});

				

			});

		}

		else

		{

			$(this).children("li").each(function(){	

				if (index_of_li == 0)

				{

					$(this).children("li div.div_first").after( function() {

						return $(this).clone().addClass("menu_hover first_top");

					});

					$(this).children("li div.div_second").after( function() {

						return $(this).clone().addClass("menu_hover second_top");

					});

				}

				else if (index_of_li < (length_of_li-1))

				{

					$(this).children("li div.div_first").after( function() {

						return $(this).clone().addClass("menu_hover first_nocorner");

					});

					$(this).children("li div.div_second").after( function() {

						return $(this).clone().addClass("menu_hover second_nocorner");

					});

				}

				else if (index_of_li == (length_of_li-1))

				{

					$(this).children("li div.div_first").after( function() {

						return $(this).clone().addClass("menu_hover first_bottom");

					});

					$(this).children("li div.div_second").after( function() {

						return $(this).clone().addClass("menu_hover second_bottom");

					});

				}	

				index_of_li++;

			});

		}		

	});	

	

	

	

	

	//corner of megadropdown menu in moodarea

	settings_menu = {tl: { radius: 0 },	tr: { radius: 4 }, bl: { radius: 4 }, br: { radius: 4 }, antiAlias: true, autoPad: true, validTags: ["ul"]}

//elmar	
//$('ul.mood_menu_elements ul').corner(settings_menu);  

	

		

	

	//corner moodarea_img_changer in moodarea

	settings_moodarea_img_changer = {tl: { radius: 4 }, tr: { radius: 0 }, bl: { radius: 4 }, br: { radius: 0 }, antiAlias: true, autoPad: true, validTags: ["ul"] }

//elmar
//	$('div.moodarea_img_changer').corner(settings_moodarea_img_changer);  

	

	settings_moodarea_img_changer_element_first = {tl: { radius: 2 }, tr: { radius: 0 }, bl: { radius: 0 }, br: { radius: 0 }, antiAlias: true, autoPad: true, validTags: ["div"] }

//elmar
//	$("div.moodarea_img_changer_element_parent:first").children("div").corner(settings_moodarea_img_changer_element_first);

		

	settings_moodarea_img_changer_element_last = {tl: { radius: 0 }, tr: { radius: 0 }, bl: { radius: 2 }, br: { radius: 0 }, antiAlias: true, autoPad: true, validTags: ["div"]  }

//elmar
//	$("div.moodarea_img_changer_element_parent:last").children("div").corner(settings_moodarea_img_changer_element_last);

	

	

	

	

	// News

	$(".news-list-morelink a").addClass("linkBtnMore");

	$(".news-single-backlink a").addClass("linkBtnBack").removeClass("news-single-backlink");	

	

	

	// back an forward buttons	

	$("a.linkBtnBack").each(function() {

		$(this).wrap("<div class=\"linkBtn_parent\"><div class=\"linkBtnBack\"> </div></div>");

	});

	$('div.linkBtn_parent div.linkBtnBack').each(function(){

		$(this).after(function() {

			 return $(this).clone().removeClass("linkBtnBack").addClass("linkBtnBack_hover");

		});

	});		

	

	$("a.linkBtnMore").each(function() {

		$(this).wrap("<div class=\"linkBtn_parent\"><div class=\"linkBtnMore\"> </div></div>");

	});

	

	

	$(".bottom_banner_bg a.linkBtnMore").html("<span class=\"before_moreButton\"> </span><span class=\"btnText\">"+$(".bottom_banner_bg a.linkBtnMore").html()+"</span><span class=\"after_moreButton\"> </span>");

	$(".bottom_banner_bg_fr a.linkBtnMore").html("<span class=\"before_moreButton\"> </span><span class=\"btnText\">"+$(".bottom_banner_bg_fr a.linkBtnMore").html()+"</span><span class=\"after_moreButton\"> </span>");

	

	

	$('div.linkBtn_parent div.linkBtnMore').each(function(){

		$(this).after(function() {

			 return $(this).clone().removeClass("linkBtnMore").addClass("linkBtnMore_hover");

		});

	});	

	

	//table.formtable input.submit

	$("table.formtable input.submit").each(function() {

		$(this).wrap("<div class=\"linkBtn_parent\"><div class=\"formtable_submit\"> </div></div>");

	});

	$('div.linkBtn_parent div.formtable_submit').each(function(){

		$(this).after(function() {

			 return $(this).clone().removeClass("submit_default").addClass("formtable_submit_hover");

		});

	});	

	



	

	

	$("a.teaserlinks").each(function() {

		$(this).wrap("<div class=\"teaserlinks_parent2\"><div class=\"teaserlinks\"> </div></div>");

	});

	$('div.teaserlinks_parent div.teaserlinks').each(function(){

		$(this).after(function() {

			 return $(this).clone().removeClass("teaserlinks").addClass("teaserlinks_hover");

		});

	});	

	

	if ($("div.pagebrowser_inactive:first a").html() == 'Zurück' || $("div.pagebrowser_inactive:first a").html() == 'Précédent')

	{

		$("div.pagebrowser_inactive:first").prependTo($("div.news-list-browse")).removeClass("pagebrowser_inactive").addClass("pagebrowser_back");

	}

	if ($("div.pagebrowser_inactive:last a").html() == 'Vorwärts' || $("div.pagebrowser_inactive:last a").html() == 'Suivant')

	{

		$("div.pagebrowser_inactive:last").removeClass("pagebrowser_inactive").addClass("pagebrowser_next");

	}

	if ($('#tabContent0 div.pagebrowser_inactive:first a').html() == 'Zurück'  || $("div.pagebrowser_inactive:first a").html() == 'Précédent') {

		$('#tabContent0 div.pagebrowser_inactive:first').remove();

	}

	if ($('#tabContent0 div.pagebrowser_inactive:last a').html() == 'Vorwärts' || $("div.pagebrowser_inactive:last a").html() == 'Suivant') {

		$('#tabContent0 div.pagebrowser_inactive:last').remove();

	}

	

	$("div.pagebrowser_inactive").each(function() {

		$(this).wrap("<div class=\"pagebrowser_parent\"> </div>");

	});

	$('div.pagebrowser_inactive').each(function(){

		$(this).after(function() {

			 return $(this).clone().removeClass("pagebrowser_inactive").addClass("pagebrowser_inactive_hover");

		});

	});	

	

	$("div.pagebrowser_next").appendTo( $("div.news-list-browse") );

	

	$('p.bodytext img.imgThumbShadow').wrap('<div class="imgShadowContainerThumb"> </div>');

	$('p.bodytext img.img_person_inline').wrap('<div class="img_person_inline_Container"> </div>');

	

			

	settings_hover_button = {tl: { radius: 4 }, tr: { radius: 4 }, bl: { radius: 4 }, br: { radius: 4 }, antiAlias: true, autoPad: true, validTags: ["div"] }

//elmar	alle 5
        //$('div.linkBtn_parent div').corner(settings_hover_button);

	//$('div.teaserlinks_parent div').corner(settings_hover_button);	

	//$('div.pagebrowser_inactive_hover').corner(settings_hover_button);

	//$('div.pagebrowser_inactive').corner(settings_hover_button);	

	//$('div.pagebrowser_active').corner(settings_hover_button);	

	//$('div.pagebrowser_inactive_hover').css({"display" : "none"});



	

	

	//corner of content-container (orange background)

	settings_content = {tl: { radius: 4 }, tr: { radius: 4 }, bl: { radius: 4 }, br: { radius: 4 }, antiAlias: true, autoPad: true, validTags: ["div"]  }

	//$('.content_area_container').corner(settings_content); 	

	//$('.bottom_menu_area_container').corner(settings_content);

	//$("span.bookmark_footer").corner(settings_content);

	

	 

	

	//corner of tabs in content-container (white background, rounded top, edge bottom)

	settings_content_area_inner_content_tab = {tl: { radius: 4 }, tr: { radius: 4 },  bl: { radius: 0 }, br: { radius: 0 }, antiAlias: true, autoPad: true, validTags: ["div"] }

	//$('.content_area_inner_content_tab').corner(settings_content_area_inner_content_tab);  

	//$('.content_area_inner_content_tab_active').corner(settings_content_area_inner_content_tab); 

	

	

	//Corner for breadcrumb

	var breadcrum_index = 40;

	$('#breadcrumb_area .breadcrumb_area_start_item').css({"z-index" : breadcrum_index});	

	$('#breadcrumb_area .breadcrumb_area_item').each(function(){		

		breadcrum_index--;

		$(this).css({"z-index" : breadcrum_index});

	});

	breadcrum_index--;	

	$('#breadcrumb_area .breadcrumb_area_spacer_item').css({"z-index" : breadcrum_index});

	breadcrum_index--;	

	$('#breadcrumb_area .breadcrumb_area_active_item').css({"z-index" : breadcrum_index})

	

	

	settings_breadcrumb_area_item = {tl: { radius: 5 }, tr: { radius: 5 },  bl: { radius: 5 }, br: { radius: 5 }, antiAlias: true, autoPad: true, validTags: ["div"] }

//elmar
	//$('#breadcrumb_area .breadcrumb_area_item').corner(settings_breadcrumb_area_item);  

//	$('#breadcrumb_area .breadcrumb_area_start_item').corner(settings_breadcrumb_area_item);

//	$('#breadcrumb_area .breadcrumb_area_spacer_item').corner(settings_breadcrumb_area_item);

	

	settings_breadcrumb_area_active_item = {tl: { radius: 0 }, tr: { radius: 4 },  bl: { radius: 0 }, br: { radius: 4 }, antiAlias: false, autoPad: true, validTags: ["div"] }

//	$('#breadcrumb_area .breadcrumb_area_active_item').corner(settings_breadcrumb_area_active_item);

	

	//$('#breadcrumb_area .breadcrumb_area_container').corner(settings_breadcrumb_area_item); 

	

	

	//corner

	$('.bottom_menu_area_container_col_head:first').css({"background-color" : "#999999", "width" : "102px"});	

	settings_bottom_menu_area_container_col_head = {tl: { radius: 4 }, tr: { radius: 4 }, bl: { radius: 4 }, br: { radius: 4 }, antiAlias: true, autoPad: true, validTags: ["div"] }

	$('.bottom_menu_area_container_col_head_parent').each(function(){

		$(this).children("div").after(function() {

			 return $(this).clone().css({"background-color": "#F18D20", "display" : "none", "width" : "102px"});

		});

	});	

//elmar
//	$('.bottom_menu_area_container_col_head').corner(settings_bottom_menu_area_container_col_head);

//elmar
//	$('.bottom_menu_area_container_col_head_active').corner(settings_bottom_menu_area_container_col_head);

	

	



	

	//clone function for tag, li ist cloned an after active element insertet (display: none)

	// function "li_hovers(obj)" changes li onevent

	$('div.right_inner_content li').each(function(){

		$(this).after(function() {

			 return $(this).clone().addClass("hover");

		});

	});	

	//apply corners to tag (native an cloned)

	settings_bottom_menu_area_container_col_head = {tl: { radius: 4 }, tr: { radius: 4 }, bl: { radius: 4 }, br: { radius: 4 }, antiAlias: true, autoPad: true, validTags: ["li"] }

//elmar
//	$('div.right_inner_content ul li').corner(settings_bottom_menu_area_container_col_head);

	

	

	



	$('div.left_inner_content table.contenttable thead tr').each(function(){

		$(this).children("th:first").addClass("bold firstcol");

	});

	$('div.left_inner_content table.contenttable tbody tr').each(function(){

		$(this).children("td:first").addClass("bold firstcol");

	}); 

	$('div.left_inner_content table.tableDownload2Col tbody tr').each(function(){

		$(this).children("td:first").addClass("firstcol");

		$(this).children("td:last").addClass("td-last");

	});

	$('div.left_inner_content table.tableKantone3Col tbody tr').each(function(){

		$(this).children("td:first").addClass("firstcol");

		$(this).children("td:last").addClass("td-last");

	});

	

	// Content-Tabelle: abwechselnd grau Zeilen

	jQuery("div.left_inner_content table.contenttable tbody tr:odd").addClass("trOdd");

	jQuery("div.left_inner_content table.tableDownload2Col tbody tr:odd").addClass("trOdd");

	jQuery("div.left_inner_content table.tableKantone3Col tbody tr:odd").addClass("trOdd");

	jQuery("div.left_inner_contenttable.formtable tr:even").addClass("trOdd");

	

	//adding class to td:first 

	$('div.left_inner_content table.formtable tbody tr').each(function(){

		$(this).children("td:first").addClass("bold firstcol");

	}); 

	

	

	// Removing Headline for Tag if Tags are empty

	if ( ($('div.left_inner_content div.news_keywords_tag').length > 0 ) && ($('div.left_inner_content .news_keywords_title').length > 0 ))

	{

		if ($('div.left_inner_content div.news_keywords_tag').html().length == 0)

		{

			$('div.left_inner_content .news_keywords_title').remove();

			$('div.left_inner_content .news_keywords_tag').remove();

		}

	}

	

	$('div.left_inner_content table.formtable select.spenden option').addClass("spenden");

	$('div.left_inner_content table.formtable select.spenden option:first').removeClass("spenden").addClass("spenden_first");

	

	

	$(".table_veranstaltungen_headline tr").each(function(){		

		$(this).children("th:eq(0)").addClass("table_veranstaltungen_headline_firstcol");

		$(this).children("th:eq(1)").addClass("table_veranstaltungen_headline_secondcol");

		$(this).children("th:eq(2)").addClass("table_veranstaltungen_headline_thirdcol");

		$(this).children("th:eq(3)").addClass("table_veranstaltungen_headline_fourthcol");

	});

	

	$(".table_veranstaltungen_monate tbody").each(function(){		

		$(this).children("tr:even").addClass("trOdd");

	});

	

	$(".table_veranstaltungen_monate tr").each(function(){		

		$(this).children("th:eq(0)").addClass("table_veranstaltungen_headline_firstcol");

		$(this).children("th:eq(1)").addClass("table_veranstaltungen_headline_secondcol");

		$(this).children("th:eq(2)").addClass("table_veranstaltungen_headline_thirdcol");

		$(this).children("th:eq(3)").addClass("table_veranstaltungen_headline_fourthcol");

		$(this).children("td:eq(0)").addClass("table_veranstaltungen_headline_firstcol");

		$(this).children("td:eq(1)").addClass("table_veranstaltungen_headline_secondcol");

		$(this).children("td:eq(2)").addClass("table_veranstaltungen_headline_thirdcol");

		$(this).children("td:eq(3)").addClass("table_veranstaltungen_headline_fourthcol");

	});	

	

	

	/**

	 * Table Parolen

	 */

	$(".table_parolen_headline tr").each(function(){		

		$(this).children("th:eq(0)").addClass("table_parolen_headline_firstcol");

		$(this).children("th:eq(1)").addClass("table_parolen_headline_secondcol");

		$(this).children("th:eq(2)").addClass("table_parolen_headline_thirdcol");

		$(this).children("th:eq(3)").addClass("table_parolen_headline_fourthcol");

	});

	

	$(".table_parolen_body tbody").each(function(){		

		$(this).children("tr:even").addClass("trOdd");

	});

	

	$(".table_parolen_subheadline tr").each(function(){		

		$(this).children("th:eq(0)").addClass("table_parolen_headline_firstcol");

		$(this).children("th:eq(1)").addClass("table_parolen_headline_secondcol");

		$(this).children("th:eq(2)").addClass("table_parolen_headline_thirdcol");

		$(this).children("th:eq(3)").addClass("table_parolen_headline_fourthcol");

		$(this).children("td:eq(0)").addClass("table_parolen_headline_firstcol");

		$(this).children("td:eq(1)").addClass("table_parolen_headline_secondcol");

		$(this).children("td:eq(2)").addClass("table_parolen_headline_thirdcol");

		$(this).children("td:eq(3)").addClass("table_parolen_headline_fourthcol");

	});	

	

	$(".table_parolen_body tr").each(function(){		

		$(this).children("th:eq(0)").addClass("table_parolen_headline_firstcol");

		$(this).children("th:eq(1)").addClass("table_parolen_headline_secondcol");

		$(this).children("th:eq(2)").addClass("table_parolen_headline_thirdcol");

		$(this).children("th:eq(3)").addClass("table_parolen_headline_fourthcol");

		$(this).children("td:eq(0)").addClass("table_parolen_headline_firstcol");

		$(this).children("td:eq(1)").addClass("table_parolen_headline_secondcol");

		$(this).children("td:eq(2)").addClass("table_parolen_headline_thirdcol");

		$(this).children("td:eq(3)").addClass("table_parolen_headline_fourthcol");

	});	



	

	

	

	$(".contenttable tr:odd").addClass("trOdd");

	$(".contenttable tr").each(function(){		

		$(this).children("td:eq(0)").addClass("table_contenttable_firstcol");

		$(this).children("th:eq(0)").addClass("table_contenttable_firstcol");

	});

	



}









function tag_enter_hovers(obj)

{	

	$(obj).children("li:first").css({"display" : "none"});

	$(obj).children("li:last").css({"display" : "block"});

}



function tag_leave_hovers(obj)

{	

	$(obj).children("li:first").css({"display" : "block"});

	$(obj).children("li:last").css({"display" : "none"});

}



function bottom_menu_head_enter_hovers(obj)

{
//elmar230211
	$(obj).children("div:first").css({"display" : "none"});

	$(obj).children("div:last").css({"display" : "block"});

}



function bottom_menu_head_leave_hovers(obj)

{

	$(obj).children("div:first").css({"display" : "block"});

	$(obj).children("div:last").css({"display" : "none"});

}





/*******************************************************************

 * Menu.js

 ***********************************************************/



function show(element)

{

	$(element).addClass("hover");

	

	/*if ($(".popup_overlay").length == 0)

	{

		$("body").append("<div class=\"popup_overlay\"></div>");

		$(".popup_overlay").css({"top" : $("html").scrollTop() + "px"});

		$("#moodarea").append('<div id="logo_cvp_hover_black"></div>');

		$("#moodarea_contentpage").append('<div id="logo_cvp_hover_black"></div>');

	}*/

}



function hide(element)

{

	$(element).removeClass("hover");	

	if ($(".popup_overlay").length > 0)

	{

		$("#logo_cvp_hover_black").remove();

		$(".popup_overlay").remove();

	}

}



function moodarea_menu_switch(element)

{

	$(element).children("div.div_second:eq(0)").css({"display":"none"});

	$(element).children("div.div_second:eq(1)").css({"display":"block"});

	$(element).children("div.div_first:eq(0)").css({"display":"none"});

	$(element).children("div.div_first:eq(1)").css({"display":"block"});

//elmar	
//$(element).next().children("div.div_second").css({"border-top":"0px solid #ADADAD"});

}



function moodarea_menu_switch_back(element)

{

	$(element).children("div.div_second:eq(1)").css({"display":"none"});

	$(element).children("div.div_second:eq(0)").css({"display":"block"});

	$(element).children("div.div_first:eq(1)").css({"display":"none"});

	$(element).children("div.div_first:eq(0)").css({"display":"block"});

//elmar	

//	$(element).next().children("div.div_second").css({"border-top":"1px solid #ADADAD"});

	

}





function moodarea_img_changer_set_active(active_moodarea_image)

{

	$("div.moodarea_img_changer_element").css({"display" : "block"});

	$("div.moodarea_img_changer_element_hover").css({"display" : "none"});

	$("div.moodarea_img_changer_element_parent:eq(" + active_moodarea_image + ")").children("div.moodarea_img_changer_element").css({"display" : "none"});

	$("div.moodarea_img_changer_element_parent:eq(" + active_moodarea_image + ")").children("div.moodarea_img_changer_element_hover").css({"display" : "block"});

}



function hover_img_changer_element_enter(hover_element)

{	

	if (actual_mood_image != hover_element)

	{

		$("div.moodarea_img_changer_element_parent:eq(" + hover_element + ")").children("div.moodarea_img_changer_element").css({"display" : "none"});

		$("div.moodarea_img_changer_element_parent:eq(" + hover_element + ")").children("div.moodarea_img_changer_element_hover").css({"display" : "block"});

	}		

}





function hover_img_changer_element_leave(hover_element)

{	

	if (actual_mood_image != hover_element)

	{

		$("div.moodarea_img_changer_element_parent:eq(" + hover_element + ")").children("div.moodarea_img_changer_element").css({"display" : "block"});

		$("div.moodarea_img_changer_element_parent:eq(" + hover_element + ")").children("div.moodarea_img_changer_element_hover").css({"display" : "none"});

	}		

}





/* Handler for Menu in CONTENT_AREA (middle, orange border, News of

 * National, Kantone And Gemeinden

 * 

 */

function set_this_active(index)

{			

		//attached content (white background)

		$(".content_area_container").css({"display" : "block"});

}



/**

 * handler for click on arrow right of searchbox in headline

 * searchbox in a form, the button submits the form

 */

function sumbit_search()

{

	if ($("#tx-indexedsearch-searchbox-sword_macina").val().length > 1)

	{

		$('div.tx-macinasearchbox-pi1 form').submit();

	}

	return false;

}



function CheckInput() {

	if ($("#tx-indexedsearch-searchbox-sword_macina").val().length > 1)

	{

		return true;

	}	

	return false;

}





function handle_memberform() {

	if ($("#formhandler_memberform_form #singleorcouple option:selected").val() == 'couple') {

		$("#formhandler_memberform_form div.data_second_person").css({"display":"block"});

	}

	else {		

		$("#formhandler_memberform_form div.data_second_person").css({"display":"none"});

	}
	if ($("#formhandler_memberform_form #singleorcouple option:selected").val() == 'standard') {

		$("#azubi_tr").css({"display":"	table-row"});

	}

	else {		

		$("#azubi_tr").css({"display":"none"});

	}


}



/********************************************************************************

 * curvy corners

 */

/****************************************************************

 *                                                              *

 *  JQuery Curvy Corners by Mike Jolley                         *

 *  http://blue-anvil.com                                       *

 *  http://code.google.com/p/jquerycurvycorners/                *

 *  ==========================================================  *

 *                                                              *

 *  Version 2.1 (Based on CC 2.1 beta)                          *

 *                                                              *

 *  Original by: Terry Riegel, Cameron Cooke and Tim Hutchison  *

 *  Website: http://www.curvycorners.net                        *

 *                                                              *

 *  This library is free software; you can redistribute         *

 *  it and/or modify it under the terms of the GNU              *

 *  Lesser General Public License as published by the           *

 *  Free Software Foundation; either version 2.1 of the         *

 *  License, or (at your option) any later version.             *

 *                                                              *

 *  This library is distributed in the hope that it will        *

 *  be useful, but WITHOUT ANY WARRANTY; without even the       *

 *  implied warranty of MERCHANTABILITY or FITNESS FOR A        *

 *  PARTICULAR PURPOSE. See the GNU Lesser General Public       *

 *  License for more details.                                   *

 *                                                              *

 *  You should have received a copy of the GNU Lesser           *

 *  General Public License along with this library;             *

 *  Inc., 59 Temple Place, Suite 330, Boston,                   *

 *  MA 02111-1307 USA                                           *

 *                                                              *

 ****************************************************************/



/*

Usage:

	To use this plugin just apply borders via CSS Rules and include this plugin - it will automatically detect styles and apply corners.

	

	Opera and Chrome support rounded corners via border-radius

	

	Safari and Mozilla support rounded borders via -webkit-border-radius and -moz-border-radius

		

	IE (any version) does not support border-radius - this is all we need to support.

		

	So to make curvycorners work with any major browser simply add the following CSS declarations:

	

	.round { 

		border-radius: 3px;

		-webkit-border-radius: 3px;

		-moz-border-radius: 3px;

	}

	

	----

	

	If you don't want to use the above method, you can still use the direct syntax if you want:



		$('.myBox').corner();

		

	The script will still use border-radius for those which support it.

*/  

(function($) { 



	// object that parses border-radius properties for a box

	function curvyCnrSpec(selText) {

		this.selectorText = selText;

		this.tlR = this.trR = this.blR = this.brR = 0;

		this.tlu = this.tru = this.blu = this.bru = "";

		this.antiAlias = true; // default true

	};

	curvyCnrSpec.prototype.setcorner = function(tb, lr, radius, unit) {

		if (!tb) { // no corner specified

			this.tlR = this.trR = this.blR = this.brR = parseInt(radius);

			this.tlu = this.tru = this.blu = this.bru = unit;

		} else { // corner specified

			propname = tb.charAt(0) + lr.charAt(0);

			this[propname + 'R'] = parseInt(radius);

			this[propname + 'u'] = unit;

		}

	};

	curvyCnrSpec.prototype.get = function(prop) {

		if (/^(t|b)(l|r)(R|u)$/.test(prop)) return this[prop];

		if (/^(t|b)(l|r)Ru$/.test(prop)) {

			var pname = prop.charAt(0) + prop.charAt(1);

			return this[pname + 'R'] + this[pname + 'u'];

		}

		if (/^(t|b)Ru?$/.test(prop)) {

			var tb = prop.charAt(0);

			tb += this[tb + 'lR'] > this[tb + 'rR'] ? 'l' : 'r';

			var retval = this[tb + 'R'];

			if (prop.length === 3 && prop.charAt(2) === 'u')

		  		retval += this[tb = 'u'];

			return retval;

		}

		throw new Error('Don\'t recognize property ' + prop);

	};

	curvyCnrSpec.prototype.radiusdiff = function(tb) {

		if (tb !== 't' && tb !== 'b') throw new Error("Param must be 't' or 'b'");

		return Math.abs(this[tb + 'lR'] - this[tb + 'rR']);

	};

	curvyCnrSpec.prototype.setfrom = function(obj) {

		this.tlu = this.tru = this.blu = this.bru = 'px'; // default to px

		if ('tl' in obj) this.tlR = obj.tl.radius;

		if ('tr' in obj) this.trR = obj.tr.radius;

		if ('bl' in obj) this.blR = obj.bl.radius;

		if ('br' in obj) this.brR = obj.br.radius;

		if ('antiAlias' in obj) this.antiAlias = obj.antiAlias;

	};

	curvyCnrSpec.prototype.cloneOn = function(box) { // not needed by IE

		var props = ['tl', 'tr', 'bl', 'br'];

		var converted = 0;

		var i, propu;	

		for (i in props) if (!isNaN(i)) {

			propu = this[props[i] + 'u'];

			if (propu !== '' && propu !== 'px') {

				converted = new curvyCnrSpec;

				break;

			}

		}

		if (!converted)

			converted = this; // no need to clone

		else {

			var propi, propR, save = curvyBrowser.get_style(box, 'left');

			for (i in props) if (!isNaN(i)) {

				propi = props[i];

				propu = this[propi + 'u'];

				propR = this[propi + 'R'];

				if (propu !== 'px') {

					var save = box.style.left;

					box.style.left = propR + propu;

					propR = box.style.pixelLeft;

					box.style.left = save;

				}

				converted[propi + 'R'] = propR;

				converted[propi + 'u'] = 'px';

			}

			box.style.left = save;

		}

		return converted;

	};

	curvyCnrSpec.prototype.radiusSum = function(tb) {

		if (tb !== 't' && tb !== 'b') throw new Error("Param must be 't' or 'b'");

		return this[tb + 'lR'] + this[tb + 'rR'];

	};

	curvyCnrSpec.prototype.radiusCount = function(tb) {

		var count = 0;

		if (this[tb + 'lR']) ++count;

		if (this[tb + 'rR']) ++count;

		return count;

	};

	curvyCnrSpec.prototype.cornerNames = function() {

		var ret = [];

		if (this.tlR) ret.push('tl');

		if (this.trR) ret.push('tr');

		if (this.blR) ret.push('bl');

		if (this.brR) ret.push('br');

		return ret;

	};

	

	if (typeof redrawList === 'undefined') redrawList = new Array;

	

	$.fn.corner = function(options) {

		

		// Check for Native Round Corners

		var nativeCornersSupported = false;

		var checkWebkit, checkMozilla, checkStandard;

		try {	checkWebkit = (document.body.style.WebkitBorderRadius !== undefined);	} catch(err) {}

		try {	checkMozilla = (document.body.style.MozBorderRadius !== undefined);	} catch(err) {}

		try {	checkStandard = (document.body.style.BorderRadius !== undefined);	} catch(err) {}		

		if (checkWebkit || checkMozilla || checkStandard) nativeCornersSupported = true;

		

		if (options instanceof curvyCnrSpec) {

			settings = options;

		}

		else {

		

			var options = jQuery.extend({

				tl: { radius: 8 },

				tr: { radius: 8 },

				bl: { radius: 8 },

				br: { radius: 8 },

				antiAlias: true

			}, options);

			

			var settings = new curvyCnrSpec(this);

			settings.setfrom(options);

		

		}

		

  		// Apply the corners to the passed object!

		function curvyObject()

		{				

			// Setup Globals

			this.box              = arguments[1];

			this.settings         = arguments[0];

			var $$ 						= $(this.box);

			var boxDisp;

			

			this.masterCorners 			= new Array();

			//this.contentDIV 				= null;			

			this.topContainer = this.bottomContainer = this.shell = boxDisp = null;

		

			// Get CSS of box and define vars

			var boxWidth = $$.innerWidth(); // Does not include border width



			if ($$.is('table'))

				throw new Error("You cannot apply corners to " + this.box.tagName + " elements.", "Error");

			

			// try to handle attempts to style inline elements
//elmar
			if ($$.css('display') === 'inline') {

				$$.css('display', 'inline-block');

			}

			

			// all attempts have failed

			

			if (!boxWidth) {

				this.applyCorners = function() {}; // make the error harmless

				return;

			}

			if (arguments[0] instanceof curvyCnrSpec) {

				this.spec = arguments[0].cloneOn(this.box); // convert non-pixel units

			} else {

				this.spec = new curvyCnrSpec('');

				this.spec.setfrom(this.settings); // no need for unit conversion, use settings param. directly

			}

			

			// Get box formatting details

			var borderWidth     = $$.css("borderTopWidth") ? $$.css("borderTopWidth") : 0;

			var borderWidthB    = $$.css("borderBottomWidth") ? $$.css("borderBottomWidth") : 0;

			var borderWidthL    = $$.css("borderLeftWidth") ? $$.css("borderLeftWidth") : 0;

			var borderWidthR    = $$.css("borderRightWidth") ? $$.css("borderRightWidth") : 0;

			var borderColour    = $$.css("borderTopColor");

			var borderColourB   = $$.css("borderBottomColor"); 

			var borderColourL   = $$.css("borderLeftColor"); 

			var borderColourR   = $$.css("borderRightColor"); 

			var borderStyle     = $$.css("borderTopStyle");

			var borderStyleB    = $$.css("borderBottomStyle");

			var borderStyleL    = $$.css("borderLeftStyle");

			var borderStyleR    = $$.css("borderRightStyle");

			

			var boxColour       = $$.css("backgroundColor");

			var backgroundImage = $$.css("backgroundImage");			

			var backgroundRepeat= $$.css("backgroundRepeat");

				

			var backgroundPosX, backgroundPosY;

			

			backgroundPosX  = $$.css("backgroundPositionX") ? $$.css("backgroundPositionX") : 0;

			backgroundPosY  = $$.css("backgroundPositionY") ? $$.css("backgroundPositionY") : 0;



			var boxPosition     = $$.css("position");

			var topPadding      = $$.css("paddingTop");

			var bottomPadding   = $$.css("paddingBottom");

			var leftPadding     = $$.css("paddingLeft");

			var rightPadding    = $$.css("paddingRight");

			var border          = $$.css("border");

			var filter = jQuery.browser.version > 7 && $.browser.msie ? $$.css("filter") : null; // IE8 bug fix

			

			var topMaxRadius    = this.spec.get('tR');

			var botMaxRadius    = this.spec.get('bR');

			

			var styleToNPx = function(val) {

				if (typeof val === 'number') return val;

				if (typeof val !== 'string') throw new Error('unexpected styleToNPx type ' + typeof val);

				var matches = /^[-\d.]([a-z]+)$/.exec(val);

				if (matches && matches[1] != 'px') throw new Error('Unexpected unit ' + matches[1]);

				if (isNaN(val = parseInt(val))) val = 0;

				return val;

			};

			var min0Px = function(val) {

				return val <= 0 ? "0" : val + "px";

			};

			

			// Set formatting properties

			try {

				this.borderWidth     = styleToNPx(borderWidth);

				this.borderWidthB    = styleToNPx(borderWidthB);

				this.borderWidthL    = styleToNPx(borderWidthL);

				this.borderWidthR    = styleToNPx(borderWidthR);

				this.boxColour       = curvyObject.format_colour(boxColour);

				this.topPadding      = styleToNPx(topPadding);

				this.bottomPadding   = styleToNPx(bottomPadding);

				this.leftPadding     = styleToNPx(leftPadding);

				this.rightPadding    = styleToNPx(rightPadding);

				this.boxWidth        = boxWidth;

				this.boxHeight       = $$.innerHeight(); // No border

				this.borderColour    = curvyObject.format_colour(borderColour);

				this.borderColourB   = curvyObject.format_colour(borderColourB);

				this.borderColourL   = curvyObject.format_colour(borderColourL);

				this.borderColourR   = curvyObject.format_colour(borderColourR);

				this.borderString    = this.borderWidth + "px" + " " + borderStyle + " " + this.borderColour;

				this.borderStringB   = this.borderWidthB + "px" + " " + borderStyleB + " " + this.borderColourB;

				this.borderStringL   = this.borderWidthL + "px" + " " + borderStyleL + " " + this.borderColourL;

				this.borderStringR   = this.borderWidthR + "px" + " " + borderStyleR + " " + this.borderColourR;

				this.backgroundImage = (backgroundImage != "none" && backgroundImage!="initial") ? backgroundImage : "";

				this.backgroundRepeat= backgroundRepeat;

			}

			catch(e) {}

			

			var clientHeight = this.boxHeight;

			var clientWidth = boxWidth; // save it as it gets trampled on later

			if ($.browser.opera) {

				backgroundPosX = styleToNPx(backgroundPosX);

				backgroundPosY = styleToNPx(backgroundPosY);

				if (backgroundPosX) {

					var t = clientWidth + this.borderWidthL + this.borderWidthR;

					if (backgroundPosX > t) backgroundPosX = t;

					backgroundPosX = (t / backgroundPosX * 100) + '%'; // convert to percentage

				}

				if (backgroundPosY) {

					var t = clientHeight + this.borderWidth + this.borderWidthB;

					if (backgroundPosY > t) backgroundPosY = t;

					backgroundPosY = (t / backgroundPosY * 100) + '%'; // convert to percentage

				}

			}



			// Create content container

			this.contentContainer = document.createElement("div");

			if (filter) this.contentContainer.style.filter = filter; // IE8 bug fix

			while (this.box.firstChild) this.contentContainer.appendChild(this.box.removeChild(this.box.firstChild));

			

			if (boxPosition != "absolute") $$.css("position", "relative");

			this.box.style.padding = '0';

			this.box.style.border = this.box.style.backgroundImage = 'none';

			this.box.style.backgroundColor = 'transparent';

			

			this.box.style.width   = (clientWidth + this.borderWidthL + this.borderWidthR) + 'px';

			this.box.style.height  = (clientHeight + this.borderWidth + this.borderWidthB) + 'px';

			

			// Ok we add an inner div to actually put things into this will allow us to keep the height

			

			var newMainContainer = document.createElement("div");

			$(newMainContainer).css({

				width: clientWidth + 'px',

				'padding':			"0",

				position:			"absolute", 

				height:				min0Px(clientHeight + this.borderWidth + this.borderWidthB - topMaxRadius - botMaxRadius),

				top:				topMaxRadius + "px",

				left:				"0",

				'backgroundColor':	boxColour,

				'backgroundImage':	this.backgroundImage,

				'backgroundRepeat':	this.backgroundRepeat,

				'direction':		'ltr'

			});

			

			if (filter) $(newMainContainer).css('filter', 'filter'); // IE8 bug fix



			if (this.borderWidthL)

				$(newMainContainer).css('borderLeft', this.borderStringL);

			if (this.borderWidth && !topMaxRadius)

				$(newMainContainer).css('borderTop', this.borderString);

			if (this.borderWidthR)

				$(newMainContainer).css('borderRight', this.borderStringR);

			if (this.borderWidthB && !botMaxRadius)

				$(newMainContainer).css('borderBottom', this.borderStringB);

				

			this.shell = this.box.appendChild(newMainContainer);

			

			boxWidth = $(this.shell).css("width");

			

			if (boxWidth === "" || boxWidth === "auto" || boxWidth.indexOf("%") !== -1) throw Error('Shell width is ' + boxWidth);

			

			this.boxWidth = (boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1) ? parseInt(boxWidth) : $(this.shell).width();

			

			this.applyCorners = function() {

				/*

				Set up background offsets. This may need to be delayed until

				the background image is loaded.

				*/

				this.backgroundPosX = this.backgroundPosY = 0;

				if (this.backgroundObject) {

					var bgOffset = function(style, imglen, boxlen) {

						if (style === 0) return 0;

						var retval;

						if (style === 'right' || style === 'bottom') return boxlen - imglen;

						if (style === 'center') return (boxlen - imglen) / 2;

						if (style.indexOf('%') > 0) return (boxlen - imglen) * 100 / parseInt(style);

						return styleToNPx(style);

					};

					this.backgroundPosX  = bgOffset(backgroundPosX, this.backgroundObject.width, clientWidth);

					this.backgroundPosY  = bgOffset(backgroundPosY, this.backgroundObject.height, clientHeight);

				}

				else if (this.backgroundImage) {

					this.backgroundPosX = styleToNPx(backgroundPosX);

					this.backgroundPosY = styleToNPx(backgroundPosY);

				}

				/*

				Create top and bottom containers.

				These will be used as a parent for the corners and bars.

				*/

				// Build top bar only if a top corner is to be drawn

				if (topMaxRadius) {

					newMainContainer = document.createElement("div");

					

					$(newMainContainer).css({

						width: 				this.boxWidth + "px",

						'fontSize':			"1px",

						overflow:			"hidden", 

						position:			"absolute", 

						'paddingLeft':		this.borderWidth + "px",

						'paddingRight':		this.borderWidth + "px",						

						height:				topMaxRadius + "px",

						top:				-topMaxRadius + "px",

						left:				-this.borderWidthL + "px"

					});					

					this.topContainer = this.shell.appendChild(newMainContainer);

				}

				// Build bottom bar only if a bottom corner is to be drawn

				if (botMaxRadius) {

					var newMainContainer = document.createElement("div");

					

					$(newMainContainer).css({

						width: 				this.boxWidth + "px",

						'fontSize':			"1px",

						overflow:			"hidden", 

						position:			"absolute", 

						'paddingLeft':		this.borderWidthB + "px",

						'paddingRight':		this.borderWidthB + "px",					

						height:				botMaxRadius + "px",

						bottom:				-botMaxRadius + "px",

						left:				-this.borderWidthL + "px"

					});

					this.bottomContainer = this.shell.appendChild(newMainContainer);

				}

			

				var corners = this.spec.cornerNames();  // array of available corners

			

				/*

				Loop for each corner

				*/

				for (var i in corners) if (!isNaN(i)) {

					// Get current corner type from array

					var cc = corners[i];

					var specRadius = this.spec[cc + 'R'];

					// Has the user requested the currentCorner be round?

					// Code to apply correct color to top or bottom

					var bwidth, bcolor, borderRadius, borderWidthTB;

					if (cc == "tr" || cc == "tl") {

						bwidth = this.borderWidth;

						bcolor = this.borderColour;

						borderWidthTB = this.borderWidth;

					} else {

						bwidth = this.borderWidthB;

						bcolor = this.borderColourB;

						borderWidthTB = this.borderWidthB;

					}

					borderRadius = specRadius - borderWidthTB;

					

					var newCorner = document.createElement("div");

					

					$(newCorner).css({

						position:"absolute",

						"font-size":"1px", 

						overflow:"hidden"

					}).height(this.spec.get(cc + 'Ru')).width(this.spec.get(cc + 'Ru'));

			//elmar 220211		

					// THE FOLLOWING BLOCK OF CODE CREATES A ROUNDED CORNER

					// ---------------------------------------------------- TOP

					var intx, inty, outsideColour;

				var regExpFilter = /alpha\(opacity.(\d+)\)/;

				var trans = regExpFilter.test(filter)[1] ? parseInt(regExpFilter.exec(filter)[1]) : 100; // IE8 bug fix



					// Cycle the x-axis

					for (intx = 0; intx < specRadius; ++intx) {

						// Calculate the value of y1 which identifies the pixels inside the border

						var y1 = (intx + 1 >= borderRadius) ? -1 : Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx + 1, 2))) - 1;

						// Calculate y2 and y3 only if there is a border defined

						if (borderRadius != specRadius) {

							var y2 = (intx >= borderRadius) ? -1 : Math.ceil(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx, 2)));

							var y3 = (intx + 1 >= specRadius) ? -1 : Math.floor(Math.sqrt(Math.pow(specRadius, 2) - Math.pow((intx+1), 2))) - 1;

						}

						// Calculate y4

						var y4 = (intx >= specRadius) ? -1 : Math.ceil(Math.sqrt(Math.pow(specRadius, 2) - Math.pow(intx, 2)));

						// Draw bar on inside of the border with foreground colour

						if (y1 > -1) this.drawPixel(intx, 0, this.boxColour, trans, (y1 + 1), newCorner, true, specRadius);

						// Draw border/foreground antialiased pixels and border only if there is a border defined

						if (borderRadius != specRadius) {

							// Cycle the y-axis

							if (this.spec.antiAlias) {

								for (inty = y1 + 1; inty < y2; ++inty) {

									// For each of the pixels that need anti aliasing between the foreground and border colour draw single pixel divs

									if (this.backgroundImage != "") {

										var borderFract = curvyObject.pixelFraction(intx, inty, borderRadius) * 100;

										this.drawPixel(intx, inty, bcolor, trans, 1, newCorner, borderFract >= 30, specRadius);

									}

									else if (this.boxColour !== 'transparent') {

										var pixelcolour = curvyObject.BlendColour(this.boxColour, bcolor, curvyObject.pixelFraction(intx, inty, borderRadius));

										this.drawPixel(intx, inty, pixelcolour, trans, 1, newCorner, false, specRadius);

									}

									else this.drawPixel(intx, inty, bcolor, trans >> 1, 1, newCorner, false, specRadius);

								}

								// Draw bar for the border

								if (y3 >= y2) {

									if (y2 == -1) y2 = 0;

									this.drawPixel(intx, y2, bcolor, trans, (y3 - y2 + 1), newCorner, false, 0);

								}

								outsideColour = bcolor;  // Set the colour for the outside AA curve

								inty = y3;               // start_pos - 1 for y-axis AA pixels

							}

							else { // no antiAlias

								if (y3 > y1) { // NB condition was >=, changed to avoid zero-height divs

									this.drawPixel(intx, (y1 + 1), bcolor, trans, (y3 - y1), newCorner, false, 0);

								}

							}

						}

						else {

							outsideColour = this.boxColour;  // Set the colour for the outside curve

							inty = y1;               // start_pos - 1 for y-axis AA pixels

						}

						// Draw aa pixels?

						if (this.spec.antiAlias && this.boxColour !== 'transparent') {

							// Cycle the y-axis and draw the anti aliased pixels on the outside of the curve

							while (++inty < y4) {

								// For each of the pixels that need anti aliasing between the foreground/border colour & background draw single pixel divs

								this.drawPixel(intx, inty, outsideColour, (curvyObject.pixelFraction(intx, inty , specRadius) * trans), 1, newCorner, borderWidthTB <= 0, specRadius);

							}

						}

					}

					// END OF CORNER CREATION

					// ---------------------------------------------------- END

				

					/*

					Now we have a new corner we need to reposition all the pixels unless

					the current corner is the bottom right.

					*/

					// Loop through all children (pixel bars)

					for (var t = 0, k = newCorner.childNodes.length; t < k; ++t) {

						// Get current pixel bar

						var pixelBar = newCorner.childNodes[t];

						// Get current top and left properties

						var pixelBarTop    = parseInt($(pixelBar).css('top'));

						var pixelBarLeft   = parseInt($(pixelBar).css('left'));

						var pixelBarHeight = parseInt($(pixelBar).css('height'));

						// Reposition pixels

						if (cc == "tl" || cc == "bl") {

							$(pixelBar).css('left', (specRadius - pixelBarLeft - 1) + "px"); // Left

						}

						if (cc == "tr" || cc == "tl"){

							$(pixelBar).css('top', (specRadius - pixelBarHeight - pixelBarTop) + "px"); // Top

						}

						$(pixelBar).css('backgroundRepeat', this.backgroundRepeat);

	

						if (this.backgroundImage) switch(cc) {

							case "tr":

								$(pixelBar).css('backgroundPosition',(this.backgroundPosX - this.borderWidthL + specRadius - clientWidth - pixelBarLeft) + "px " + (this.backgroundPosY + pixelBarHeight + pixelBarTop + this.borderWidth - specRadius) + "px");

							break;

							case "tl":

								$(pixelBar).css('backgroundPosition',(this.backgroundPosX - specRadius + pixelBarLeft + 1 + this.borderWidthL) + "px " + (this.backgroundPosY - specRadius + pixelBarHeight + pixelBarTop + this.borderWidth) + "px");

							break;

							case "bl":

								$(pixelBar).css('backgroundPosition',(this.backgroundPosX - specRadius + pixelBarLeft + 1 + this.borderWidthL) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + (!jQuery.support.boxModel ? pixelBarTop : -pixelBarTop) + specRadius) + "px");

							break;

							case "br":

								// Quirks mode on?

								if (!jQuery.support.boxModel) {

									$(pixelBar).css('backgroundPosition',(this.backgroundPosX - this.borderWidthL - clientWidth + specRadius - pixelBarLeft) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + pixelBarTop + specRadius) + "px");

								} else {

									$(pixelBar).css('backgroundPosition',(this.backgroundPosX - this.borderWidthL - clientWidth + specRadius - pixelBarLeft) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + specRadius - pixelBarTop) + "px");

								}

							//break;

						}

					}

				

					// Position the container

					switch (cc) {

						case "tl":

							$(newCorner).css('top', newCorner.style.left = "0");

							this.topContainer.appendChild(newCorner);

						break;

						case "tr":

							$(newCorner).css('top', newCorner.style.right = "0");

							this.topContainer.appendChild(newCorner);

						break;

						case "bl":

							$(newCorner).css('bottom', newCorner.style.left = "0");

							this.bottomContainer.appendChild(newCorner);

						break;

						case "br":

							$(newCorner).css('bottom', newCorner.style.right = "0");

							this.bottomContainer.appendChild(newCorner);

						//break;

					}

				}

			

				/*

				The last thing to do is draw the rest of the filler DIVs.

				*/

				

				// Find out which corner has the bigger radius and get the difference amount

				var radiusDiff = {

					t : this.spec.radiusdiff('t'),

					b : this.spec.radiusdiff('b')

				};

				

				for (z in radiusDiff) {

					if (typeof z === 'function') continue; // for prototype, mootools frameworks

					if (!this.spec.get(z + 'R')) continue; // no need if no corners

					if (radiusDiff[z]) {

						// Get the type of corner that is the smaller one

						var smallerCornerType = (this.spec[z + "lR"] < this.spec[z + "rR"]) ? z + "l" : z + "r";

				

						// First we need to create a DIV for the space under the smaller corner

						var newFiller = document.createElement("div");	

						

						$(newFiller).css({

							'height':			radiusDiff[z] + "px",

							'width':			this.spec.get(smallerCornerType + 'Ru'),

							'position':			"absolute",

							'fontSize':			"1px",

							'overflow':			"hidden",

							'backgroundColor':	this.boxColour,

							'backgroundImage':	this.backgroundImage,

							'backgroundRepeat':	this.backgroundRepeat

						});					

						

						if (filter) $(newFiller).css('filter', 'filter'); // IE8 bug fix

				

						// Position filler

						switch (smallerCornerType) {

							case "tl":

								$(newFiller).css({

									'bottom':				'',

									'left':					'0',

									'borderLeft':			this.borderStringL,

									'backgroundPosition':	this.backgroundPosX + "px " + (this.borderWidth + this.backgroundPosY - this.spec.tlR) + "px"

								});

								this.topContainer.appendChild(newFiller);

							break;

							case "tr":

								$(newFiller).css({

									'bottom':				'',

									'right':					'0',

									'borderRight':			this.borderStringR,

									'backgroundPosition':	(this.backgroundPosX - this.boxWidth + this.spec.trR) + "px " + (this.borderWidth + this.backgroundPosY - this.spec.trR) + "px"

								});

								this.topContainer.appendChild(newFiller);

							break;

							case "bl":

								$(newFiller).css({

									'top':					'',

									'left':					'0',

									'borderLeft':			this.borderStringL,

									'backgroundPosition':	this.backgroundPosX + "px " + (this.backgroundPosY - this.borderWidth - this.boxHeight + radiusDiff[z] + this.spec.blR) + "px"

								});

								this.bottomContainer.appendChild(newFiller);

							break;

							case "br":

								$(newFiller).css({

									'top':					'',

									'right':				'0',

									'borderRight':			this.borderStringR,

									'backgroundPosition':	(this.borderWidthL + this.backgroundPosX - this.boxWidth + this.spec.brR) + "px " + (this.backgroundPosY - this.borderWidth - this.boxHeight + radiusDiff[z] + this.spec.brR) + "px"

								});

								this.bottomContainer.appendChild(newFiller);

							//break;

						}

					}

				

					// Create the bar to fill the gap between each corner horizontally

					var newFillerBar = document.createElement("div");

					if (filter) $(newFillerBar).css('filter', 'filter'); // IE8 bug fix

					$(newFillerBar).css({

						'position':					"relative",

						'fontSize':					"1px",

						'overflow':					"hidden",

						'width':					this.fillerWidth(z),

						'backgroundColor':			this.boxColour,

						'backgroundImage':			this.backgroundImage,

						'backgroundRepeat':			this.backgroundRepeat

					});

				

					switch (z) {

						case "t":

							// Top Bar

							if (this.topContainer) {

								if (!jQuery.support.boxModel) {

									$(newFillerBar).css('height', 100 + topMaxRadius + "px");

								} else {

									$(newFillerBar).css('height', 100 + topMaxRadius - this.borderWidth + "px");

								}

								$(newFillerBar).css('marginLeft', this.spec.tlR ? (this.spec.tlR - this.borderWidthL) + "px" : "0");

								$(newFillerBar).css('borderTop', this.borderString);

								if (this.backgroundImage) {

									var x_offset = this.spec.tlR ?

										(this.borderWidthL + this.backgroundPosX - this.spec.tlR) + "px " : this.backgroundPosX + "px ";

									

									$(newFillerBar).css('backgroundPosition', x_offset + this.backgroundPosY + "px");

				

									// Reposition the box's background image

									$(this.shell).css('backgroundPosition', this.backgroundPosX + "px " + (this.backgroundPosY - topMaxRadius + this.borderWidthL) + "px");

								}

								this.topContainer.appendChild(newFillerBar);

							}

						break;

						case "b":

							if (this.bottomContainer) {

								// Bottom Bar

								if (!jQuery.support.boxModel) {

									$(newFillerBar).css('height', botMaxRadius + "px");

								} else {

									$(newFillerBar).css('height', botMaxRadius - this.borderWidthB + "px");

								}

								$(newFillerBar).css('marginLeft', this.spec.blR ? (this.spec.blR - this.borderWidthL) + "px" : "0");

								$(newFillerBar).css('borderBottom', this.borderStringB);

								if (this.backgroundImage) {

									var x_offset = this.spec.blR ?

										(this.backgroundPosX + this.borderWidthL - this.spec.blR) + "px " : this.backgroundPosX + "px ";

									$(newFillerBar).css('backgroundPosition', x_offset + (this.backgroundPosY - clientHeight - this.borderWidth + botMaxRadius) + "px");

								}

								this.bottomContainer.appendChild(newFillerBar);

							}

						//break;

					}

				}			

			

				// style content container

				z = clientWidth;				

				if (jQuery.support.boxModel) z -= this.leftPadding + this.rightPadding;

				

				$(this.contentContainer).css({

					'position':			'absolute',

					'left':				this.borderWidthL + "px",

					'paddingTop':		this.topPadding + "px",

					'top':				this.borderWidth + "px",

					'paddingLeft':		this.leftPadding + "px",

					'paddingRight':		this.rightPadding + "px",

					'width':			z + "px",

					'textAlign':		$$.css('textAlign')

				}).addClass('autoPadDiv');

				

				$$.css('textAlign', 'left').addClass('hasCorners');

	

				this.box.appendChild(this.contentContainer);

				if (boxDisp) $(boxDisp).css('display', boxDispSave);

			};

			

			if (this.backgroundImage) {

				backgroundPosX = this.backgroundCheck(backgroundPosX);

				backgroundPosY = this.backgroundCheck(backgroundPosY);

				if (this.backgroundObject) {

					this.backgroundObject.holdingElement = this;

					this.dispatch = this.applyCorners;

					this.applyCorners = function() {

						if (this.backgroundObject.complete) this.dispatch();

						else this.backgroundObject.onload = new Function('curvyObject.dispatch(this.holdingElement);');

					};

				}

			}

		};

		

		curvyObject.prototype.backgroundCheck = function(style) {

		  if (style === 'top' || style === 'left' || parseInt(style) === 0) return 0;

		  if (!(/^[-\d.]+px$/.test(style))  && !this.backgroundObject) {

		    this.backgroundObject = new Image;

		    var imgName = function(str) {

		      var matches = /url\("?([^'"]+)"?\)/.exec(str);

		      return (matches ? matches[1] : str);

		    };

		    this.backgroundObject.src = imgName(this.backgroundImage);

		  }

		  return style;

		};

		

		curvyObject.dispatch = function(obj) {

		  if ('dispatch' in obj)

		    obj.dispatch();

		  else throw Error('No dispatch function');

		};

		

		/*

		This function draws the pixels

		*/	

		curvyObject.prototype.drawPixel = function( intx, inty, colour, transAmount, height, newCorner, image, cornerRadius ) {			

			//var $$ = $(box);			

		    var pixel = document.createElement("div");

		    

		    $(pixel).css({	

		    	"height" :			height + "px",

		    	"width" :			"1px", 

		    	"position" :		"absolute", 

		    	"font-size" :		"1px", 

		    	"overflow" :		"hidden",

		    	"top" :				inty + "px",

		    	"left" :			intx + "px",

		    	"background-color" :colour

		    });

		    

		    var topMaxRadius = this.spec.get('tR');

		    

		    // Dont apply background image to border pixels

			if(image && this.backgroundImage != "")

			{

				$(pixel).css({

					"background-position":"-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) - this.borderWidth) + "px",

					"background-image":this.backgroundImage				 

				});

			}		    

		    if (transAmount != 100)

		    	$(pixel).css({opacity: (transAmount/100) });



		    newCorner.appendChild(pixel);

		};

		

		curvyObject.prototype.fillerWidth = function(tb) {

			var b_width, f_width;

			b_width = !jQuery.support.boxModel ? 0 : this.spec.radiusCount(tb) * this.borderWidthL;

			

			if ((f_width = this.boxWidth - this.spec.radiusSum(tb) + b_width) < 0)

				throw Error("Radius exceeds box width");

			return f_width + 'px';

		};			

		

		// Gets the computed colour.

		curvyObject.getComputedColour = function(colour) {

		  var d = document.createElement('DIV');

		  d.style.backgroundColor = colour;

		  document.body.appendChild(d);

		

		  if (window.getComputedStyle) { // Mozilla, Opera, Chrome, Safari

		    var rtn = document.defaultView.getComputedStyle(d, null).getPropertyValue('background-color');

		    d.parentNode.removeChild(d);

		    if (rtn.substr(0, 3) === "rgb") rtn = curvyObject.rgb2Hex(rtn);

		    return rtn;

		  }

		  else { // IE

		    var rng = document.body.createTextRange();

		    rng.moveToElementText(d);

		    rng.execCommand('ForeColor', false, colour);

		    var iClr = rng.queryCommandValue('ForeColor');

		    var rgb = "rgb("+(iClr & 0xFF)+", "+((iClr & 0xFF00)>>8)+", "+((iClr & 0xFF0000)>>16)+")";

		    d.parentNode.removeChild(d);

		    rng = null;

		    return curvyObject.rgb2Hex(rgb);

		  }

		};

				

		curvyObject.BlendColour = function(Col1, Col2, Col1Fraction) 

		{

			

			if (Col1 === 'transparent' || Col2 === 'transparent') throw Error('Cannot blend with transparent');

			if (Col1.charAt(0) !== '#') {

				Col1 = curvyObject.format_colour(Col1);

			}

			if (Col2.charAt(0) !== '#') {

				Col2 = curvyObject.format_colour(Col2);

			}

			var red1 = parseInt(Col1.substr(1, 2), 16);

			var green1 = parseInt(Col1.substr(3, 2), 16);

			var blue1 = parseInt(Col1.substr(5, 2), 16);

			var red2 = parseInt(Col2.substr(1, 2), 16);

			var green2 = parseInt(Col2.substr(3, 2), 16);

			var blue2 = parseInt(Col2.substr(5, 2), 16);

			

			if (Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1;

			

			var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction)));

			if (endRed > 255) endRed = 255;

			if (endRed < 0) endRed = 0;

			

			var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction)));

			if (endGreen > 255) endGreen = 255;

			if (endGreen < 0) endGreen = 0;

			

			var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction)));

			if (endBlue > 255) endBlue = 255;

			if (endBlue < 0) endBlue = 0;

			

			return "#" + curvyObject.IntToHex(endRed) + curvyObject.IntToHex(endGreen)+ curvyObject.IntToHex(endBlue);

			

		};

	

		curvyObject.IntToHex = function(strNum)

		{			

			var hexdig = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];

			return hexdig[strNum >>> 4] + '' + hexdig[strNum & 15];

		};

	

		/*

		For a pixel cut by the line determines the fraction of the pixel on the 'inside' of the

		line.  Returns a number between 0 and 1

		*/

		curvyObject.pixelFraction = function(x, y, r) 

		{

  			var fraction;

 			var rsquared = r * r;



			/*

			determine the co-ordinates of the two points on the perimeter of the pixel that the

			circle crosses

			*/

			var xvalues = new Array(2);

			var yvalues = new Array(2);

			var point = 0;

			var whatsides = "";



			// x + 0 = Left

			var intersect = Math.sqrt(rsquared - Math.pow(x, 2));

			

			if (intersect >= y && intersect < (y + 1)) {

				whatsides = "Left";

				xvalues[point] = 0;

				yvalues[point] = intersect - y;

				++point;

			}

			// y + 1 = Top

			intersect = Math.sqrt(rsquared - Math.pow(y + 1, 2));

			

			if (intersect >= x && intersect < (x + 1)) {

				whatsides += "Top";

				xvalues[point] = intersect - x;

				yvalues[point] = 1;

				++point;

			}

			// x + 1 = Right

			intersect = Math.sqrt(rsquared - Math.pow(x + 1, 2));

			

			if (intersect >= y && intersect < (y + 1)) {

				whatsides += "Right";

				xvalues[point] = 1;

				yvalues[point] = intersect - y;

				++point;

			}

			// y + 0 = Bottom

			intersect = Math.sqrt(rsquared - Math.pow(y, 2));

			

			if (intersect >= x && intersect < (x + 1)) {

				whatsides += "Bottom";

				xvalues[point] = intersect - x;

				yvalues[point] = 0;

			}



			/*

			depending on which sides of the perimeter of the pixel the circle crosses calculate the

			fraction of the pixel inside the circle

			*/

			switch (whatsides) {

				case "LeftRight":

					fraction = Math.min(yvalues[0], yvalues[1]) + ((Math.max(yvalues[0], yvalues[1]) - Math.min(yvalues[0], yvalues[1])) / 2);

				break;

				

				case "TopRight":

					fraction = 1 - (((1 - xvalues[0]) * (1 - yvalues[1])) / 2);

				break;

				

				case "TopBottom":

					fraction = Math.min(xvalues[0], xvalues[1]) + ((Math.max(xvalues[0], xvalues[1]) - Math.min(xvalues[0], xvalues[1])) / 2);

				break;

				

				case "LeftBottom":

					fraction = yvalues[0] * xvalues[1] / 2;

				break;

				

				default:

					fraction = 1;

			}			

			return fraction;

		};

  

  

		// This function converts CSS rgb(x, x, x) to hexadecimal

		curvyObject.rgb2Hex = function(rgbColour) 

		{

			try{

			

				// Get array of RGB values

				var rgbArray = curvyObject.rgb2Array(rgbColour);

				

				// Get RGB values

				var red   = parseInt(rgbArray[0]);

				var green = parseInt(rgbArray[1]);

				var blue  = parseInt(rgbArray[2]);

				

				// Build hex colour code

				var hexColour = "#" + curvyObject.IntToHex(red) + curvyObject.IntToHex(green) + curvyObject.IntToHex(blue);

			}

			catch(e){			

				alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");

			}

			

			return hexColour;

		};

		

		// Returns an array of rbg values

		curvyObject.rgb2Array = function(rgbColour) 

		{

			// Remove rgb()

			var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));



			// Split RGB into array

			return rgbValues.split(", ");

		};



		// Formats colours

		curvyObject.format_colour = function(colour) 

		{

			// Make sure colour is set and not transparent

			if (colour != "" && colour != "transparent") {

			  // RGB Value?

			  if (colour.substr(0, 3) === "rgb") {

			    // Get HEX aquiv.

			    colour = curvyObject.rgb2Hex(colour);

			  }

			  else if (colour.charAt(0) !== '#') {

			    // Convert colour name to hex value

			    colour = getComputedColour(colour);

			  }

			  else if (colour.length === 4) {

			    // 3 chr colour code add remainder

			    colour = "#" + colour.charAt(1) + colour.charAt(1) + colour.charAt(2) + colour.charAt(2) + colour.charAt(3) + colour.charAt(3);

			  }

			}

			return colour;

		};	

		  

		return this.each(function() {

			if (!$(this).is('.hasCorners')) {

				/*if (nativeCornersSupported) {

					if (settings.get('tlR')) {

						$(this).css({

							'border-top-left-radius' : settings.get('tlR') + 'px',

							'-moz-border-radius-topleft' : settings.get('tlR') + 'px',

							'-webkit-border-top-left-radius' : settings.get('tlR') + 'px'

						});

					}

					if (settings.get('trR')) {

						$(this).css({

							'border-top-right-radius' : settings.get('trR') + 'px',

							'-moz-border-radius-topright' : settings.get('trR') + 'px',

							'-webkit-border-top-right-radius' : settings.get('trR') + 'px'

						});

					}

					if (settings.get('blR')) {

						$(this).css({

							'border-bottom-left-radius' : settings.get('blR') + 'px',

							'-moz-border-radius-bottomleft' : settings.get('blR') + 'px',

							'-webkit-border-bottom-left-radius' : settings.get('blR') + 'px'

						});

					}

					if (settings.get('brR')) {

						$(this).css({

							'border-bottom-right-radius' : settings.get('brR') + 'px',

							'-moz-border-radius-bottomright' : settings.get('brR') + 'px',

							'-webkit-border-bottom-right-radius' : settings.get('brR') + 'px'

						});

					}

				} else {*/

					if (!$(this).is('.drawn')) {						

						$(this).addClass('drawn');

						

						thestyles = $(this).attr('style');

						if (thestyles == 'undefined') {

							thestyles = '';

						}

						

						redrawList.push({

						  node : this,

						  spec : settings,

						  style : thestyles,

						  copy : $(this).clone(true)

						});

					}

					var obj = new curvyObject(settings, this);

					obj.applyCorners();

				//}			

			}			

		});

			

	};

	

	$.fn.removeCorners = function() { 

		return this.each(function(i, e) {

			thisdiv = e;

			$.each(

				redrawList,

				function( intIndex, list ){	

					if (list.node==thisdiv) {

						$('div:not(.autoPadDiv)', thisdiv).remove();

						$('.autoPadDiv', thisdiv).replaceWith( $('.autoPadDiv', thisdiv).contents() );	

						style = list.style == 'undefined' ? list.style : ''; 

						$(thisdiv).removeClass('hasCorners').attr('style', style );						

						return false;

					}

				}

			);

		});

	};

	

	$.fn.redrawCorners = function() { 

		return this.each(function(i, e) {

			thisdiv = e;

			$.each(

				redrawList,				

				function( intIndex, list ){	

					if (list.node==thisdiv) {

						$('div:not(.autoPadDiv)', thisdiv).remove();

						$('.autoPadDiv', thisdiv).replaceWith( $('.autoPadDiv', thisdiv).contents() );	

						

						$(thisdiv).removeClass('hasCorners').attr('style', style );	

						$(thisdiv).corner(list.spec);

						return false;

					}

				}

			);

		});

	};

	

	$(function(){

		

		// Detect styles and apply corners in browsers with no native border-radius support

		if ($.browser.msie) {	

			/* Force caching of bg images in IE6 */

			try {	document.execCommand("BackgroundImageCache", false, true);	}	catch(e) {};

			

			function units(num) {

				if (!parseInt(num)) return 'px'; // '0' becomes '0px' for simplicity's sake

				var matches = /^[\d.]+(\w+)$/.exec(num);

				return matches[1];

			};

			

			/* Detect and Apply Corners */

			var t, i, j;

			

			function procIEStyles(rule) {

				var style = rule.style;

			

				if (jQuery.browser.version > 6.0) {

					var allR = style['-moz-border-radius'] || 0;

					var tR   = style['-moz-border-radius-topright'] || 0;

					var tL   = style['-moz-border-radius-topleft'] || 0;

					var bR   = style['-moz-border-radius-bottomright'] || 0;

					var bL   = style['-moz-border-radius-bottomleft'] || 0;

				}

				else {

					var allR = style['moz-border-radius'] || 0;

					var tR   = style['moz-border-radius-topright'] || 0;

					var tL   = style['moz-border-radius-topleft'] || 0;

					var bR   = style['moz-border-radius-bottomright'] || 0;

					var bL   = style['moz-border-radius-bottomleft'] || 0;

				}

				if (allR) {

					var t = allR.split('/'); // ignore elliptical spec.

					t = t[0].split(/\s+/);

					if (t[t.length - 1] === '') t.pop();

					switch (t.length) {

						case 3:

							tL = t[0];

							tR = bL = t[1];

							bR = t[2];

							allR = false;

						break;

						case 2:

							tL = bR = t[0];

							tR = bL = t[1];

							allR = false;

						case 1:

						break;

						case 4:

							tL = t[0];

							tR = t[1];

							bR = t[2];

							bL = t[3];

							allR = false;

						break;

						default:

							alert('Illegal corners specification: ' + allR);

					}

				}

				if (allR || tL || tR || bR || bL) {

					var settings = new curvyCnrSpec(rule.selectorText);

					if (allR)

						settings.setcorner(null, null, parseInt(allR), units(allR));

					else {

						if (tR) settings.setcorner('t', 'r', parseInt(tR), units(tR));

						if (tL) settings.setcorner('t', 'l', parseInt(tL), units(tL));

						if (bL) settings.setcorner('b', 'l', parseInt(bL), units(bL));

						if (bR) settings.setcorner('b', 'r', parseInt(bR), units(bR));

					}

					$(rule.selectorText).corner(settings);

				}

			}

			for (t = 0; t < document.styleSheets.length; ++t) {

				try {

					if (document.styleSheets[t].imports) {

						for (i = 0; i < document.styleSheets[t].imports.length; ++i) {

							for (j = 0; j < document.styleSheets[t].imports[i].rules.length; ++j) {

								procIEStyles(document.styleSheets[t].imports[i].rules[j]);

							}

						}

					}

					for (i = 0; i < document.styleSheets[t].rules.length; ++i)

						procIEStyles(document.styleSheets[t].rules[i]);

				}

				catch (e) {} 

			}

		} else if ($.browser.opera) {

			

			// Apply if border radius is not supported

			try {	checkStandard = (document.body.style.BorderRadius !== undefined);	} catch(err) {}

			

			if (!checkStandard) {

		

				function opera_contains_border_radius(sheetnumber) {

					return /border-((top|bottom)-(left|right)-)?radius/.test(document.styleSheets.item(sheetnumber).ownerNode.text);

				};

				

				rules = [];

			

				for (t = 0; t < document.styleSheets.length; ++t) {

					if (opera_contains_border_radius(t)) {

				   	

				   		var txt = document.styleSheets.item(sheetnumber).ownerNode.text;

				   		txt = txt.replace(/\/\*(\n|\r|.)*?\*\//g, ''); // strip comments

				   		

				   		var pat = new RegExp("^\\s*([\\w.#][-\\w.#, ]+)[\\n\\s]*\\{([^}]+border-((top|bottom)-(left|right)-)?radius[^}]*)\\}", "mg");

				   		var matches;				   		

				   		while ((matches = pat.exec(txt)) !== null) {

				   			var pat2 = new RegExp("(..)border-((top|bottom)-(left|right)-)?radius:\\s*([\\d.]+)(in|em|px|ex|pt)", "g");

				   			var submatches, cornerspec = new curvyCnrSpec(matches[1]);

				   			while ((submatches = pat2.exec(matches[2])) !== null) {

				   				if (submatches[1] !== "z-")

				   				    cornerspec.setcorner(submatches[3], submatches[4], submatches[5], submatches[6]);

				   				rules.push(cornerspec);

				   			}

				   		}

				   	}

				}				

				for (i in rules) if (!isNaN(i))

					$(rules[i].selectorText).corner(rules[i]);

					

					

			}

		}

	});		

	

})(jQuery);

	

	

	/*

	CSS Browser Selector v0.3.5 (Feb 05, 2010)

	Rafael Lima (http://rafael.adm.br)

	http://rafael.adm.br/css_browser_selector

	License: http://creativecommons.org/licenses/by/2.5/

	Contributors: http://rafael.adm.br/css_browser_selector#contributors

	*/

	function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);







	// Delay Plugin for jQuery

	// - http://www.evanbot.com

	// - copyright 2008 Evan Byrne

	/*

	 * Jonathan Howard

	 * jQuery Pause

	 * version 0.2

	 * Requires: jQuery 1.0 (tested with svn as of 7/20/2006)

	 * Feel free to do whatever you'd like with this, just please give credit where

	 * credit is do.

	 * pause() will hold everything in the queue for a given number of milliseconds,

	 * or 1000 milliseconds if none is given.

	 */

	// Wait Plugin for jQuery

	// http://www.inet411.com

	// based on the Delay and Pause Plugin

	 (function($) {

	    $.fn.wait = function(option, options) {

	        milli = 1000; 

	        if (option && (typeof option == 'function' || isNaN(option)) ) { 

	            options = option;

	        } else if (option) { 

	            milli = option;

	        }

	        // set defaults

	        var defaults = {

	            msec: milli,

	            onEnd: options

	        },

	        settings = $.extend({},defaults, options);



	        if(typeof settings.onEnd == 'function') {

	            this.each(function() {

	                setTimeout(settings.onEnd, settings.msec);

	            });

	            return this;

	        } else {

	            return this.queue('fx',

	            function() {

	                var self = this;

	                setTimeout(function() { $.dequeue(self); },settings.msec);

	            });

	        }



	    }

	})(jQuery);









