if((location.href).indexOf('http://www.modico.pl/', 0)=='-1')
{
server='http://modico.pl/';		
}
else
{	
server="http://www.modico.pl/";
}
$(function() {
            $(".topmenu").lavaLamp({
                  fx: "linear",
                speed: 200
				
                
            });
			
			$('#send').click(
						function () 
						{
							if($("#contact_form_form").valid()==true)
							{
							$("#contact_form_form").submit();	
							}
							else
							{
							//alert('stop');	
								
							}
							
						
						});
			
			
			
		
				
				$("#select_district").hover(
  function () {
   $("#select_district ul").show();
  },
  function () {
   $("#select_district ul").hide();
  }
);
				$("#select_town").hover(
  function () {
   $("#select_town ul").show();
  },
  function () {
   $("#select_town ul").hide();
  }
);
			
			$('input[type="text"]').addClass("unfocusField");
       		$('input[type="text"]').focus(function() {
       			$(this).removeClass("unfocusField").addClass("focusField");
				//alert('dsaasd');
    		    if (this.value == this.defaultValue){ 
    		    	this.value = '';
				}
				if(this.value != this.defaultValue){
	    			
	    		}
    		});
    		$('input[type="text"]').blur(function() {
    			$(this).removeClass("focusField").addClass("unfocusField");
    		    if ($.trim(this.value) == ''){
			    	this.value = (this.defaultValue ? this.defaultValue : '');
				}
    		});
        });
	Cufon.replace('.home_list li h3');
	Cufon.replace('.cechy_list li h3');
	Cufon.replace('.modicolor_list li h3');
	Cufon.replace('.modicolor_2 strong');
	Cufon.replace('.h3_modicolor');
	
	
	//Cufon.replace('.topmenu li a',{fontSize:'16px',hover: true});
	Cufon.replace('.slider_title');	
	Cufon.replace('.dark');	
	Cufon.replace('.bright');
	
	
	Cufon.replace('.pieczatki_submenu li a',{hover: true});	
	Cufon.replace('.dlugopisy_submenu li a',{hover: true});	
	
	
	
	
			
	
	
	
	
	//var so = new swfobject("./addons/themes/sunstamper/swf/VideoPlayer.swf", "mymovie", "256", "366", "9.0.0");
  // so.addParam("wmode", "transparent");
  // so.write("flashcontent");

	
swfobject.embedSWF("./addons/themes/sunstamper/swf/VideoPlayer.swf", "flashcontent", "256", "366", "9.0.0",'','',{wmode:"transparent"});



function google_map_load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		
		map.setCenter(new GLatLng([52.21892], [21.17457]), 15);
		map.addControl(new GLargeMapControl());
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.setZoom(15);

		//dodajemy marker do mapki

	var point1 = new GLatLng([52.21892], [21.17457]);
	var marker1 = new GMarker(point1);
		map.addOverlay(marker1);
		//GEvent.addListener(marker1, "click", function() {
		//	marker1.openInfoWindowHtml("<p style='font-size:12px;'>Trattoria Rucola<br/>ul. Francuska 6 03-906 Warszawa<br/>tel. 022 616 12 59<br/>022 462 33 62<br/>czynne codziennie<br/>godz. 12.00 - 22.00</p>");
	//	});

	}
}

function updateNews(){
	$(".news_all").load(server+'news/view_ajax/',function(response, status, xhr) {
  if (status == "error") {
$(".news_all").html('<p>Niestety nie udalo sie zaladowac newsów.</p>')
  }
});


}

function updateDate(){
	$("#last_update").load(server+'users/check_last_date/',function(response, status, xhr) {
  if (status == "error") {
$("#last_update").html('<p>Niestety nie udalo sie załadować newsów.</p>')
  }
});


}

/*
 * 	Easy Slider 1.7 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
/*
 *	markup example for $("#slider").easySlider();
 *	
 * 	<div id="slider">
 *		<ul>
 *			<li><img src="images/01.jpg" alt="" /></li>
 *			<li><img src="images/02.jpg" alt="" /></li>
 *			<li><img src="images/03.jpg" alt="" /></li>
 *			<li><img src="images/04.jpg" alt="" /></li>
 *			<li><img src="images/05.jpg" alt="" /></li>
 *		</ul>
 *	</div>
 *
 */





(function($) {

		$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {			
			prevId: 		'prevBtn',
			currentClicked: 0,
			prevText: 		'',
			nextId: 		'nextBtn',	
			nextText: 		'',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',	
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',	
			lastText: 		'Last',
			lastShow:		false,				
			vertical:		false,
			speed: 			200,
			auto:			false,
			pause:			4000,
			continuous:		false, 
			numeric: 		false,
			numericId: 		'controls',
			atamhak: 		false,
			colors: 		false
			
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			var clickable = true;
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w);			
			
			if(options.continuous){
				$("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px"));
				$("ul", obj).append($("ul li:nth-child(2)", obj).clone());
				$("ul", obj).css('width',(s+1)*w);
			};				
			
			if(!options.vertical) $("li", obj).css('float','left');
								
			if(options.controlsShow){
				var html = options.controlsBefore;				
				if(options.numeric){
					html += '<ol id="'+ options.numericId +'"></ol>';
				} else {
					if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';
					html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';
					html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';
					if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';				
				};
				
				html += options.controlsAfter;						
				$(obj).after(html);										
			};
			
			if(options.numeric){
				temp=options.colors;
				temp=temp.split(',');
				for(var i=0;i<temp.length;i++){						
					$(document.createElement("li"))
						.attr('id',options.numericId + (i+1))
						.html('<img  rel='+ i +' src="http://www.sunstamper.pl/pieczatki2/addons/themes/sunstamper/img/modico_line/'+temp[i]+'.png" width="26" />')
						.appendTo($("#kolory_"+this.id))
						.click(function(){							
							animate($("img",$(this)).attr('rel'),true);
							
						});
						dddd=this.id;
						
						
				};
					
				
				
			} else {
				$("a","#"+options.nextId).click(function(){		
					animate("next",true);
				});
				
				$("a","#"+options.prevId).click(function(){		
					animate("prev",true);				
				});	
				$("a","#"+options.firstId).click(function(){
														  
					animate("first",true);
				});				
				$("a","#"+options.lastId).click(function(){		
					animate("last",true);				
				});				
			};
			
			
			function setCurrent(i){
				i = parseInt(i)+1;
				//alert('kolory_'+dddd);
			
				//alert(aa.id);
				aa=("div", obj).attr('id');
				//alert(aa);
				$('#kolory_'+aa+'>li').removeClass('current');
				$("li#" + options.numericId).removeClass('current');

				$("li#" + options.numericId + i).addClass("current");
			
				
			};
			
			function adjust(){
				if(t>ts) t=0;	
				
					
				
				if(t<0) t=ts;	
				if(!options.vertical) {
					$("ul",obj).css("margin-left",(t*w*-1));
				} else {
					$("ul",obj).css("margin-left",(t*h*-1));
				}
				
				clickable = true;
				$("ul",obj).animate(
							{ opacity: 1 }
						);
				
				if(options.atamhak)
				{
					$(".spec_kolor_box").removeClass('active');
					$("#kolor_"+0).removeClass('active');
					$("#kolor_"+t).addClass('active');
					
				}
				if(options.numeric) setCurrent(t);
				
			};
			
			function animate(dir,clicked){
				if (clickable){
					clickable = false;
					var ot = t;	
					//$("#kolory_slider2").removeClass("current");
					switch(dir){
						case "next":
							t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1;						
							break; 
						case "prev":
							t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1;
							break; 
						case "first":
							t = 0;
							break; 
						case "last":
							t = ts;
							break; 
						default:
							t = dir;
							break; 
					};	
					var diff = Math.abs(ot-t);
					var speed = diff*options.speed;						
					if(!options.vertical) {
						p = (t*w*-1);
						$("ul",obj).animate(
							{ marginLeft: p,opacity: 0.1 }, 
							{ queue:false, duration:speed, complete:adjust }
						);				
					} else {
						p = (t*h*-1);
						$("ul",obj).animate(
							{ marginTop: p }, 
							{ queue:false, duration:speed, complete:adjust }
						);					
					};
					
					if(!options.continuous && options.controlsFade){					
						if(t==ts){
							$("a","#"+options.nextId).hide();
							$("a","#"+options.lastId).hide();
						} else {
							$("a","#"+options.nextId).show();
							$("a","#"+options.lastId).show();					
						};
						if(t==0){
							$("a","#"+options.prevId).hide();
							$("a","#"+options.firstId).hide();
						} else {
							$("a","#"+options.prevId).show();
							$("a","#"+options.firstId).show();
						};					
					};				
					
					if(clicked) clearTimeout(timeout);
					if(options.auto && dir=="next" && !clicked){;
						timeout = setTimeout(function(){
							animate("next",false);
						},diff*options.speed+options.pause);
					};
			
				};
				
			};
		
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};		
			
			if(options.numeric) setCurrent(0);
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				$("a","#"+options.firstId).hide();				
			};
			if(options.currentClicked>0)
			{
				;
			
				animate(options.currentClicked,false);
				t=options.currentClicked;
				adjust();
				
			}
			if(options.atamhak==true){
			$("#kolor_0").click(function(){	
				$(".spec_kolor_box").removeClass('active');					 
				animate(0,false);
				t=0;
				adjust();
				$("#kolor_0").addClass('active');
			});
			$("#kolor_1").click(function(){	
				$(".spec_kolor_box").removeClass('active');	
				animate(1,false);
				t=1;
				adjust();
				$("#kolor_1").addClass('active');
			});
			$("#kolor_2").click(function(){			
				$(".spec_kolor_box").removeClass('active');	
				animate(2,false);
				t=2;
				adjust();
				$("#kolor_2").addClass('active');
			});
			$("#kolor_3").click(function(){			
				$(".spec_kolor_box").removeClass('active');	
				animate(3,false);
				t=3;
				adjust();
				$("#kolor_3").addClass('active');
			});
			$("#kolor_4").click(function(){			
				$(".spec_kolor_box").removeClass('active');	
				animate(4,false);
				t=4;
				adjust();
				$("#kolor_4").addClass('active');
			});
			}
			
		});
		$("a").focus(function(){
  $(this).blur();
});
	  
	};
	
	$.fn.loupe = function (arg) {
		var options = $.extend({
			loupe: 'loupe',
			width: 250,
			height: 250
		}, arg || {});

		return this.length ? this.each(function () {
			var $this = $(this), $big, $loupe,
				$small = $this.is('img') ? $this : $this.find('img:first'),
				move, hide = function () { $loupe.hide(); },
				time;

			if ($this.data('loupe') != null) {
				return $this.data('loupe', arg);
			}

			move = function (e) {
				var os = $small.offset(),
					sW = $small.outerWidth(),
					sH = $small.outerHeight(),
					oW = options.width / 2,
					oH = options.height / 2;

				if (!$this.data('loupe') ||
					e.pageX > sW + os.left + 10 || e.pageX < os.left - 10 ||
					e.pageY > sH + os.top + 10 || e.pageY < os.top - 10) {
					return hide();
				}

				time = time ? clearTimeout(time) : 0;

				$loupe.show().css({
					left: e.pageX - oW,
					top: e.pageY - oH
				});
				$big.css({
					left: -(((e.pageX - os.left) / sW) * $big.width() - oW)|0,
					top: -(((e.pageY - os.top) / sH) * $big.height() - oH)|0
				});
			};

			$loupe = $('<div />')
				.addClass(options.loupe)
				.css({
					width: options.width,
					height: options.height,
					position: 'absolute',
					overflow: 'hidden'
				})
				.append($big = $('<img />').attr('src', $this.attr($this.is('img') ? 'src' : 'href')).css('position', 'absolute'))
				.mousemove(move)
				.hide()
				.appendTo('body');

			$this.data('loupe', true)
				.mouseenter(move)
				.mouseout(function () {
					time = setTimeout(hide, 10);
				});
		}) : this;
	};

})(jQuery);








