﻿$(function() {

	$("a.external").bind("click", function() {
		
		window.open($(this).attr('href'));
		return false;
		
	});
	
	// if($("img[title='collage']").length>0) {
		// $("img[title='collage']")
		// .css('cursor','pointer')
		// .wrap("<div class=\"m gal\"><a href=\"" + $("div.m.gal ul li:first div a").attr("href") + "\"></a></div>")
		// .attr('rel',$("div.m.gal ul li:first div a").attr('rel')).attr('title','Click to start gallery')
		// .addClass('gal');
		// alert($("div.m.gal ul li:first div a").attr('rel'));
	// }

	if($("img[title='collage']").length>0) {
		$("div.m.gal ul").prepend(
			"<li><div class=\"content_block\">" +
			"<a href=\"" + $("div.m.gal ul li:first div a").attr("href") + "\" class=\"gal\" rel=\"" + $("div.m.gal ul li:first div a").attr('rel') + "\">" + 
				"<img src=\"" + $("img[title='collage']").attr('src') + "\" />" +
			"</a>" + 
			"</div></li>"
		);
		$("img[title='collage']").remove();
		$("div.m.gal ul li:first").next().remove();
	}	
	//traverse active
	jQuery.each($(".dropdown .active"), function() {
	
		$($(this).parent("ul").parents("li:eq(0)")).parent("ul").parents("li:eq(0)").addClass("active");
		$(this).parent("ul").parents("li:eq(0)").addClass("active");

	});
	
	// lang box
	// if(document.getElementById("m_lang_selector")) {
		// jQuery.each($("#m_lang_selector img"), function() {
			// switch($(this).attr('class')) {
				// case 'langFlag':
					// $(this).attr('title', 
						// fLang.m.lang.switchToLang.replace("{langName}",$(this).attr('rel'))
					// );
				// break;
				// case 'langFlag noLang':
					// $(this).attr('title', 
						// fLang.m.lang.noLanguageVersion.replace("{langName}",$(this).attr('rel'))
					// );
				// break;
				// case 'langFlag currLang':
					// $(this).attr('title', 
						// fLang.m.lang.chosenLangIsCurrentLang
					// )
					// .css('cursor','default');
				// break;				
			// }
			
		// });
		
	// }
	
	// * lang box
	
	// search
	//$("#ajaxSearch").bind("focus", function() { $(this).attr('value',''); });
	//$('input[name="ajaxSearch"]').liveSearch({ajaxURL: '/inc/modules/ajax/search.asp?q='});
	// * search


	// gallery start
	if($("div.gal").length>0) {
		
		$("#gal_switch_label").html(fLang.m.gal.switchView);
		
		// gallery type 1
		// $("div.gal img").css("opacity",0.5);
		// $("div.gal img").hover(
			// function() { $(this).stop().animate({ 'opacity' : 1}, 300); },
			// function() { $(this).stop().animate({ 'opacity' : 0.5}, 300); }
		// );
		
		// init images

		$.fn.colorbox.settings.transition = "fade";
		$.fn.colorbox.settings.bgOpacity = "1";
		$.fn.colorbox.settings.overlayClose = false;
		$.fn.colorbox.settings.contentCurrent = fLang.m.gal.imageCurrentOutOfTotal;
		$("div.gal a").colorbox();		

		// switch view		
		$("a.switch_thumb").toggle(
			function(){
				$(this).addClass("swap");
				$("ul.display").fadeOut("fast", function() {
					if($("ul.display").hasClass("thumb_view")) {
						$(this).fadeIn("fast").removeClass("thumb_view");
					} else {
						$(this).fadeIn("fast").addClass("thumb_view");
					}
				});
			}, 
			function () {
				$(this).removeClass("swap");
				$("ul.display").fadeOut("fast", function() {
					if($("ul.display").hasClass("thumb_view")) {
						$(this).fadeIn("fast").removeClass("thumb_view");
					} else {
						$(this).fadeIn("fast").addClass("thumb_view");
					}
				});
			}
		); 


				
				
		
	}

	
});﻿




