$(document).ready(function(){

    //highlight current button
	b = $(document).getUrlParam("buttonID");
	if(b)
		o = $("#menu li.buttonID_" + b).addClass("highlight");
	else
    	o = $("#menu li:first").addClass("highlight");

	m = $("#container").attr("class").split('_')[1];

	//highlight current main tab
	$("#menu li.buttonID_" + m).addClass("tab_high").find("a:first").addClass("tab_high").wrap("<span class=\"tab\"><span class=\"tab_left\"><span class=\"tab_right\"></span></span></span>");

    //show current submenu
	$("#menu li.buttonID_" + m).find("ul:eq(0)").css('display','block').addClass('currentSubmenu');

	//over tabs
	$("#menu ul li:not(.buttonID_" + m + ")").hover(
    	function(){
    		if($(this).find("ul:hidden").html()){
				$("#menu ul li.buttonID_" + m + " ul:first").fadeOut('slow');
				$(this).find("ul:hidden").css('z-Index','100').fadeIn('slow');
    		}
    	},
    	function(){
    		if($(this).find("ul:visible").html()){
				$("#menu ul li.buttonID_" + m + " ul:first").fadeIn('slow');
				$(this).find("ul:visible").fadeOut('slow');
    		}
    	}
	);

	//forms
	$("form input:submit,form input:button").addClass("roundedButton").wrap("<div class=\"roundedButton\"><div class=\"roundedButton_left\"><div class=\"roundedButton_right\"></div></div></div>")
    $("form div.roundedButton").click(function(){
    	$(this).parents("form")[0].submit();
    });
	$("form input:text,form input:password").addClass("roundedInput").wrap("<div class=\"roundedInput\"><div class=\"roundedInput_left\"><div class=\"roundedInput_right\"></div></div></div>")
	$("form textarea").addClass("roundedArea").addClass("clear").attr('style','').wrap("<div class=\"roundedArea clear\"><div class=\"roundedArea_top\"><div class=\"roundedArea_bottom\"><div class=\"roundedArea_left\"><div class=\"roundedArea_right\"><div class=\"roundedArea_tl\"><div class=\"roundedArea_tr\"><div class=\"roundedArea_bl\"><div class=\"roundedArea_br\"></div></div></div></div></div></div></div>");


	//catalogus
	$(".catalog_module div.item").corner("round 5px");
	$(".catalog_module div.more_info_link a,.catalog_module div.order_link a").addClass("roundedButton").wrap("<div class=\"roundedButton\"><div class=\"roundedButton_left\"><div class=\"roundedButton_right\"></div></div></div>")


	//change the stupid HR behavour of IE...
	if($.browser.msie)
		$("#content hr").css('display','none').wrap("<div class=\"hr\"></div>");

	//change boxed template
	$("div.boxed").corner("round 10px");

	//change half
	$("div.half:odd").css("margin-right",'0px');
	$(".catalog_module .item:odd").css("margin-right",'0px').addClass('floatRight');//css("float",'right');

	//change link classnames
	$(".article a").each(function(){
		if($(this).attr("href")){
			p = $(this).attr("href").split('.');
			if(p[p.length - 1].toLowerCase() == 'pdf')
				$(this).addClass('pdfLink');
		}
	});

	//change the blockUI overlay
	$('#pepperWindow div.module_contents').corner("round 5px");

});

function pepperPopup(){
	$('#pepperWindow').clone().appendTo('body').displayBox();
}

//emulate popup function...
function popWindow(u,w,h){
	e = u.substring(u.lastIndexOf('.')+1).toLowerCase();
	if(e == 'png' || e == 'gif' || e == 'jpg')
		popEl = $("<div class=\"popWindowDiv\" style=\"display:block;\"><img src=\""+ u +"\" width=\"" + w + "\" height=\"" + h + "\" border=\"0\" /></div>");
	else
		popEl = $("<div class=\"popWindowDiv\" style=\"display:block;\"><iframe src=\""+ u +"\" width=\"" + w + "\" height=\"" + h + "\" border=\"0\" frameborder=\"0\"></iframe></div>");
	popEl.modal({
		onOpen: function (dialog) {
					dialog.overlay.fadeIn('slow', function () {
						dialog.container.slideDown('slow', function () {
							dialog.data.fadeIn('slow'); // See Other Notes below regarding
													   // data display property and
													   // iframe details
						});
					});
				},
		onClose: function (dialog) {
					dialog.data.fadeOut('slow', function () {
					  dialog.container.slideUp('slow', function () {
						dialog.overlay.fadeOut('slow', function () {
						  $.modal.close(); // must call this to have SimpleModal
										   // re-insert the data correctly and
										   // clean up the dialog elements
						});
					  });
					});
				}
				
	});
	$("#modalContainer").css('height',h).css('width',w).css('margin-left',(w / 2) * -1);
}
