/**
 * 2009 - Schwarz & Weiss - Dacian Stanciu - built for
 * Pensiuni Agroturism
 */

$(document).ready(function(){
	//$("cortina").css("display","hidden");
	var isIE=(document.all?true:false);
	
	//fix png
		$.ifixpng('imgs/pixel.gif');
		$('img[src$=.png], #panel').ifixpng();
	
	// Zones disable head click
		$("#zones li a.head").click(function(){ return false; });
				
	//CheckBoxes
  		$('input:checkbox').checkbox({empty: '../jQuery/checkbox/empty.png'});

	//Image List
		$.fn.colorbox.settings.bgOpacity = "0.95";		
		$("a[class='imgList']").colorbox({contentCurrent:"{current}/{total}"});

 	//SuW Calcul Rute
		$(".textLinks a:eq(1)").colorbox({"iframe":true,"title":false,"fixedWidth":"1030px","fixedHeight":"620px"});
		
	//Promo
		$('#suwScr').suwPagPromo();
		$('#suwPromoTxt').newsTicker(10000);
		
});

/**
 * Promotii
 */
$.fn.suwPagPromo = function(){
	var containerWidth=$(this).width();
	var childWidth=$(this).children(":first").width();
	var maxChildrens=$(this).children().size();
	var visMax=parseInt(containerWidth/childWidth);
	var scrMax=parseInt(childWidth*maxChildrens)+1;
	var scrMinPos=parseInt((maxChildrens-visMax)*childWidth)*-1;
	var animSpeed=300;
	var moves=maxChildrens-visMax;
	var direction=scrMinPos;
	var obj=$(this);
	
	$(this).css({"width":scrMax+"px"});

	var suwPMove = function(){
		var actLeft=parseInt(obj.css("marginLeft"));
		
		if(moves==0){
			direction=(actLeft<=scrMinPos?0:scrMinPos);
			moves=maxChildrens-visMax;
		}
		moves--;
		
		switch(direction){
			case 0:
				var nextPos = actLeft+childWidth; 
				break;
			default:
			 	var nextPos = actLeft-childWidth;
		}
		
		$.timer(5000, function (timer) {
			$(obj).animate({ marginLeft:nextPos+"px"}, animSpeed, null,suwPMove);
   			timer.stop();
   		});
	};
	
	suwPMove();
}

/**
 * Redirectioneaza url
 * @param {Object} loc
 */
function redir(loc){ document.location=loc;}
