function roundCorner(){
	var mainTpl_set = {
		tl: { radius: 1 },
		tr: { radius: 1 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: true,
		validTags: ["div"]
	}
	var mainTplDiv = document.getElementById("mainTpl");
	var mainTplCorner = new curvyCorners(mainTpl_set, mainTplDiv);
	mainTplCorner.applyCornersToAll();
}

function changeTab(objTab, itemNr){
	var tab = document.getElementById(objTab);
	document.getElementById("tab-2-search").style.position = 'relative';
	document.getElementById("tab-2-search").style.left = '0px';
	document.getElementById("tab-3-search").style.position = 'relative';
	document.getElementById("tab-3-search").style.left = '0px';
	for(var i = 1; i <= 3; i++){
		var tabInfo = document.getElementById('opt'+i);
		var regx = new RegExp("opt" + i + "-sel");
		tabInfo.className = tabInfo.className.replace(regx,'');
	}
	document.getElementById("tab-1-search").style.display = "none";
	document.getElementById("tab-2-search").style.display = "none";
	document.getElementById("tab-3-search").style.display = "none";
	document.getElementById("tab-"+itemNr+"-search").style.display = "block";
	tab.className += ' opt'+itemNr+'-sel';
}

jQuery(function($) {
 	var locationVal = location + '';
	reg = /#offers(\d+)/
	locationVal = locationVal.match(reg);
	if(locationVal != null){
		locationVal = locationVal[1];
		jQuery("#listInfoOfferTypes LI.selected").removeClass("selected");
		jQuery("#listInfoOfferTypes LI").filter(function(index, obj){
			if($(this).attr("rel") == locationVal){
				jQuery(".offerInfoArea").css("display", "none");
				jQuery("#areaInfoOfferType_"+locationVal).css("display", "block");
				return true;
			}
			return false
		}).addClass("selected");
	
	}
	var totalLength = $("ul#listInfoOfferTypes").width();
	var nrOfItems = $("ul#listInfoOfferTypes LI").length;
	if(nrOfItems > 0) {
		var finalSize = Math.ceil(totalLength/nrOfItems)-1;
		var maxHeight = 0;
		var totalElements = $("ul#listInfoOfferTypes LI").length;
		$("ul#listInfoOfferTypes LI").each(function(index){
			if($(this).height() > maxHeight){
				maxHeight = $(this).height();
			}
			$(this).css('width', finalSize-2);
			$("A", this).css('width', finalSize-2);
			$("SPAN", this).css('width', finalSize-2);
			$("SPAN:last", this).css('width', finalSize-10).css("padding-left", "5px");
			if(index+1 == totalElements && maxHeight > 65){
				maxHeight = 70;
				$(this).parent().find("li").css('min-height', maxHeight+"px");
				$(this).parent().find("a").css('min-height', maxHeight+"px");
				$(this).parent().find("span").css('min-height', maxHeight+"px");
			}
		});
		selectOffersTab();
	}
});
