// these example method has to be implemented by fully functional methods

//THE: id="location-selector" -> width breiter, sonst funktioniert ui-slider-handler nicht infolge Umbruch von langen Country-Namen

EXAMPLE_RATED = false;

$.extend(RatingManager, {

	rate: function(grade) {
		// do something
		if (EXAMPLE_RATED) {
			RatingManager.displayError(_.rating.error);
			EXAMPLE_RATED = false;
		} else {
			RatingManager.displaySuccess(_.rating.success, grade);
			EXAMPLE_RATED = true;
		}
	}

});

$.extend(LocationSelector.prototype, {

	getContent: function() {
		//original width: 140px
		var content = '\
			<div id="location-selector" style="width: 200px; ">\
				<p id="location-selector-close-handle" style="background-image: url(_resources/img/en/roche-worldwide.gif); width: 96px; ">\
					<span class="access">Roche Worldwide</span>\
				</p>\
			    <div class="slider"><div class="handle ui-slider-handle"></div></div>\
			    <div id="location-list-wrapper">\
					<ul>' + this.getCountrylistAsHtml() + '\
					</ul>\
				</div>\
			</div>';
		$("a#location-selector-handle").parent().append(content);
		this.toggleWith("p#location-selector-close-handle");
		return $("div#location-selector");
	}//,

	/*
	DISSABLED. FUNCTION EXPORTED TO OUR TEMPLATE AS IT'S USED FOR CONTENT POPULATION
	getCountrylistAsHtml: function() {
		var list = [];
		for (var i=0; i < _.countries.length; i++) {
			list.push('<li><a href="roche_worldwide.htm?mz_id='+_.countries[i].mz_id+'">' +  _.countries[i].title + '</a></li>');
		}
		return list.join("");
	}
	*/

});

/***********************************************************************/
/* START: switch between tabs and repaint sIFR elements inside         */
// replace following code with custom functions to switch between tabs
$(document).ready(function() {
	$("ul.tab-nav-addAjaxFunc li").click(
		function(event){
			if($(this).is("li.active")){ // return when tab is already shown
				event.stopPropagation();
				event.preventDefault(); // prevent browser to trigger link
				return;
			}
			
			$(this).siblings(".active").removeClass("active").each(function(){
				var tabContentId = $(this).children("a:first").attr("href");
				if(/^#[-_\w]+$/.test(tabContentId)){
					$(tabContentId).get(0).alreadySifred = true; // set flag that this container was already repainted
					$(tabContentId).hide();
				}
			});
			
			$(this).addClass("active");
			var tabContentId = $(this).children("a:first").attr("href");
			if(/^#[-_\w]+$/.test(tabContentId)){ // check whether href is a container id
				$(tabContentId).show();

				if(!$(tabContentId).get(0).alreadySifred){ // check if this container was already repainted
					if(SifrManager) SifrManager.paint("div"+tabContentId); // repaint sIFR elements
					$(tabContentId).get(0).alreadySifred= true;
				}
			}
			event.stopPropagation();
			event.preventDefault(); // prevent browser to trigger link
		}
	);
/* END: switch between tabs and repaint sIFR elements inside         */
/***********************************************************************/

});
			
