﻿$(document).ready(function() {
	$('a[href*="(snabela)"]').each(function(index) {
		//console.log("test");
		var url = $(this).attr('href');
		//if ("url:contains('(snabela)')") {
		$(this).attr('href', url.replace("(snabela)", "@"));
		if($(this).html().indexOf("(snabela)") > -1){
			$(this).html($(this).html().replace("(snabela)","@"));
		}
		//	}
	});
});
(function($) {
	$(window).load(function(){
	
		
	$("#chained").scrollable({
		circular: true,
		easing: 'easeInOutQuad',
		speed: 1200,
		onSeek: function(e, index) {
			var items = this.getItems();
			items.removeClass('currentSlide');
			items.eq(index).addClass('currentSlide');
		},
		onBeforeSeek: function(e, index) {
			var IntTime = $(".currentSlide").attr("duration");
			//alert(IntTime);
			if (IntTime == "undefined"){
				IntTime = 3000;
			}
		}
	}).navigator().autoscroll({
			interval: 3000,
			autopause: false
	});			
	$('a#prev').click(function() {
		alert("test");
		$("span#disableprev").css("display", "block");
		$("span#disablenext").css("display", "block");
	});
	$('a#next').click(function() {
		$("span#disableprev").css("display", "block");
		$("span#disablenext").css("display", "block");
	});
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	if(isiPad){
		//alert("test");
	}else{
		$("#menu li").append("<span></span>");
		$("#menu a").each(function() { 
			$(this).css("position", "absolute"); 
			$(this).css("top", "0px"); 
			$(this).css("left", "0px"); 
		}); 
		$("#menu span").each(function() { 
			$(this).css("position", "absolute"); 
			$(this).css("top", "0px"); 
			$(this).css("left", "0px"); 
		}); 
		$("#menu li").each(function() { //For each list item...
			linkWidth = $(this).find('a').outerWidth(false);
			var linkText = $(this).find("a").html(); //Find the text inside of the a tag
			$(this).find("span").show().html(linkText); //Add the text in the span tag
			$(this).find('a').css("left", linkWidth); 
			Cufon.replace($(this).find('span'));
			$(this).find('span').width(linkWidth);
			$(this).width(linkWidth);
		}); 
		$("#menu li").hover(function() {	//On hover...
			linkWidth = $(this).find('a').outerWidth(false);
			if($(this).hasClass('active')) {
			
			}else {
				$(this).find("span").stop().animate({ 
					left: -(linkWidth)-1
				}, 150);
				$(this).find("a").stop().animate({ 
					left: 0
				}, 150);
			}
		} , function() { //On hover out...
			if($(this).hasClass('active')) {
				
			}else {
				$(this).find("span").stop().animate({
					left: "0" //Move the span back to its original state (0px)
				}, 150);
				$(this).find("a").stop().animate({
					left: linkWidth //Move the span back to its original state (0px)
				}, 150);
			}
		});
	
	
		$("#submenu li").append("<span></span>"); //Throws an empty span tag right before the a tag	
		$("#submenu a").each(function() { 
			$(this).css("position", "absolute"); 
			$(this).css("top", "0px"); 
			$(this).css("left", "0px"); 
		}); 
		$("#submenu span").each(function() { 
			$(this).css("position", "absolute"); 
			$(this).css("top", "0px"); 
			$(this).css("left", "0px"); 
		}); 
		$("#submenu li").each(function() { //For each list item...
			linkWidth = $(this).find('a').width();
			var linkText = $(this).find("a").html(); //Find the text inside of the a tag
			$(this).find("span").show().html(linkText); //Add the text in the span tag
			$(this).find('a').css("left", linkWidth); 
			$(this).find('span').width(linkWidth);
			$(this).width(linkWidth);
		}); 
		
		$("#submenu li").hover(function() {	//On hover...
			linkWidth = $(this).find('a').width();
			if($(this).hasClass('active')) {
			
			}else {
				$(this).find("span").stop().animate({ 
					left: -linkWidth
				}, 150);
				$(this).find("a").stop().animate({ 
					left: 0
				}, 150);
			}
		} , function() { //On hover out...
			if($(this).hasClass('active')) {
				
			}else {
				$(this).find("span").stop().animate({
					left: "0" //Move the span back to its original state (0px)
				}, 150);
				$(this).find("a").stop().animate({
					left: linkWidth //Move the span back to its original state (0px)
				}, 150);
			}
		});
	}
		$("a[rel]").each(function(i) {		
			var position = $("#flags").position();
			var overlay = $(this).overlay({
				// common configuration for each overlay
				oneInstance: false, 
				closeOnClick: false, 
				
				mask: {
					color: '#fff',
					loadSpeed: 200,
					opacity: 0.7
				},
				
				// setup custom finish position
				top: position.bottom,
				left: position.left-122,
				
				// use apple effect
				effect: 'apple',
				fixed: false
			});				
		});
	});	
})(jQuery);	

function myFocus(form, defaultTxt) {
	if(form.value == defaultTxt) {
		form.value = '';
		form.style.color = "#656565";
	}
}

function myBlur(form, defaultTxt) {
	if(form.value == '') {
		form.value = defaultTxt;
		form.style.color = "#656565";
	}
}

