
function hideInputs () {
	var inputs = $$('input');
	for (var i = 0 ; i < inputs.length ; i++) {
	if (Element.hasClassName(inputs[i],'jsHide')) inputs[i].hide();
	}
}

function countrySelectInit() {
/* PROZATIM NEFUNKCNI - dokud se nevyresi redirecty
	//nastavení Linkeru na changeCountry formular
	$('#changeCountry').bind("submit", function (e) {
		if (typeof pT != "undefined") {
			pT._linkByPost(this);
		}
	});
*/
	$('#btnCountrySelect').css('display','none');
	$('#selectCountry').change(
		function() {
			$('#changeCountry').submit();
		}
	);

}

function externalLinks() {
	$('a.new-window').click(function() {
		window.open(this.href);
		return false;
	});
}

function adSearch() {
	var pager = $("div.pager form");
			$("#search").toggleClass("sAdvBg");
	$("#aS").toggleClass("sAdvBg");
	if ($("#search").hasClass("sAdvBg")) {
		if(pager.length > 1) { $("div.pager form:first").hide(); }
		$("#advancedSearch").show();
		$("#sB1").hide();
	}
	else {
		if(pager.length > 1) { $("div.pager form:first").show(); }
		$("#advancedSearch").hide();
		$("#sB1").show();
	}
}

var Accordion =	{
	hideAll : function() { $("div.accordion").hide(); },
	showItem : function(e) {
		if($(this).hasClass("ico_minus")){
			$(this).parent().next().hide();
			$(this).removeClass("ico_minus");
			$(this).addClass("ico_plus");
		}
		else{
			$(this).parent().next().show();
			$(this).removeClass("ico_plus");
			$(this).addClass("ico_minus");
		}
	},
	init : function() {
		var i = 0;
		$("h3.accordion").each(function(index) {
			AccordionTitle=$(this);
			anchor = document.createElement('a');
			anchor.className = "ico_minus";
			anchor.href = "#tail"+i;
			anchor.active = 0;
			AccordionTitle.append(anchor);
			$(anchor).bind("click",Accordion.showItem);
			i++;
		});
		/*
		var hash = window.location.hash.substring(1);
		var tail = document.getElementById(hash);
		if (tail) {
			var a = tail.getElementsByTagName('A')[0];
			$(a).addClass("ico_minus");
			$(tail).next().show();
		}
		*/
	}
}



var DateTime = {

	insertData : function(date) {
		var input = $("input.selectedInput").val(date);
		input.removeClass("selectedInput");
		$("#cal").hide();
	},
	removeCal : function(e) {
		$("#cal").hide();
		$("body").unbind("click");
	},
	showCal : function(e) {	
		$("body").unbind("click");
		$("input.calendar").each(function(index) {
			$(this).removeClass("selectedInput");
		});

		$("#cal").show();
		$(this).addClass("selectedInput");
		var obj = $(this).offset();
	
		$("#cal").css("left",obj.left);
		$("#cal").css("top",obj.top+20);

		var p = $(this).val().split(".");

		if(p==""){
			var mesic=3;
			var rok=2010;
		}
		else{
			var mesic=p[1];
			var rok=p[2];
		}	

		$.ajax({
			url: "/jnp/en/updater-section/index$839-showMonth.html?mode=calendarInput&amp;async=true",
			data: "month="+mesic+"&year="+rok,
			cache: false,
			success: function(html){
				$("#cal").html(html);
				$("body").bind("click",DateTime.removeCal);
			}
		});	
	},

	init : function() {
		$("input.calendar").each(function(index) {
			input=$(this);
			$(this).bind("click",DateTime.showCal);
		});
	}
}

function ajax(place, url) {
	$("body").unbind("click");
	$.ajax({
		url: url,
		cache: false,
		success: function(html){
			$("#"+place).html(html);
			$("body").bind("click",DateTime.removeCal);
		}
	});
}

function redir() {
	window.location.href = ($('filter1').value);
}

/* --- google maps create marker --- */
function createMarker(point, html) {
	bounds.extend(point);

	var tpIcon = new GIcon(G_DEFAULT_ICON);
    	tpIcon.image = "/public/82/b9/be/1500_3627_gmap_icon.png";
        tpIcon.iconSize = new GSize(27, 28);

	// Set up our GMarkerOptions object
	markerOptions = { icon:tpIcon };

	var marker = new GMarker(point, markerOptions);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

	GEvent.addListener(marker,"mouseover", function() {
		marker.openInfoWindowHtml(html);
	});

	map.addOverlay(marker);

	map.setZoom(map.getBoundsZoomLevel(bounds) - 1);
	map.setCenter(bounds.getCenter());
}
function googleMapCenterByCoords(lat, long) {
	if (map) {
		map.setCenter(new GLatLng(lat, long), 13);
	}
}
function googleMapCenterByGeocoder(address) {
	if (map) {
		geocoder.getLatLng(address,function(point){ map.setCenter(point, 13)});
	}
}


/* --- circular carousel functions --- */
function carousel_itemVisibleInCallback(carousel, item, i, state, evt) {
    var idx = carousel.index(i, carousel_itemList.length);
    carousel.add(i, carousel_getItemHTML(carousel_itemList[idx - 1]));
};

function carousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
    carousel.remove(i);
};

function carousel_getItemHTML(item) {
    var itemHTML = '';
    itemHTML += '<div class="image">';
    itemHTML += '<a href="' + item.url + '"><img src="' + item.img + '" width="180" height="180" alt="' + item.title + '" /><\/a>';
    itemHTML += '<\/div>';
    itemHTML += '<div class="info">';
    itemHTML += '<a href="' + item.url + '">' + item.title + '<\/a>';
    itemHTML += '<\/div>';
    return itemHTML;
};

function carousel_initCallback(carousel) {
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

/* nastavení trackovani odchodu na shop */
function trackShopLink(url) {
	if (typeof pT != "undefined") {
		var shopUrl = url.split('/');
		pT._trackPageview('/shop/' + shopUrl[shopUrl.length - 1]);
	}
}

