$(document).ready(function() {
	
	$("#top h2").click(function() {
		location.href = "/";
		
	});
	

	$("a.link").each(function() {
		var itemId = $(this).attr("id").split("_")[1];
		$(this).attr("href", "/click/" + itemId);
	});
	
	$("h3").each(function() {
		var h = $(this).text();
		var newText = "";
		for(i=0; i<h.length; i++) {
			//newText += '<img src="/images/char/a/'+h.charAt(i).toLowerCase()+'.gif" alt="'+h.charAt(i)+'">';
			newText += h.charAt(i).toLowerCase();
		}
		$(this).html(newText);

	});
	
	
	$(".fontSize2").each(function() {
		var h = $(this).text();
		var newText = "";
		var code = "space";
		for(i=0; i<h.length; i++) {
			code = h.charAt(i).toLowerCase();
			if (code == " ") code = "space";
			newText += '<div class="fontSize2_'+code+'"></div>';
			//newText += h.charAt(i).toLowerCase();
		}
		newText += '<br style="clear:both;">';
		//alert(newText);
		$(this).html(newText);
	});
	
	
	$("#giftFinder form, #bigGiftFinder form").submit(function() {
		var gender = $(this).find("input[name=gender]:checked").val();
		var age = $("#age").val();
		var category = $("#category").val();
		var categories = '';
		var i = 0;
		var categories_count = $("#bigGiftFinder .category:checked").length;
		$("#bigGiftFinder .category:checked").each(function() {
			i++;
			categories += $(this).val();
			if (i < categories_count) categories += '|';
		});
		var price = $("#price_from").val() + "-" + $("#price_to").val();
		var url = "/christmas-gift-ideas/gender("+gender+")/";
		if (category != undefined && category != '') {
			url += "category("+category+")/";
		} else if (categories != '') {
			url += "category("+categories+")/";
		}
		if (age != '') {
			url += "age("+age+")/";
		}
		url += "price("+price+")/";
		
		//alert(url);
		location.href = url;
		return false;
	});
	/*
	$("#giftFinder a").click(function() {
		var box = $("#giftFinder");
		var w = $("#giftFinder").css("width").substr(0,3);
		//alert(w);
		$("#feature").hide();
		expandGiftFinder(w);
		
	});
	*/
});
/*
function expandGiftFinder(w) {
	var w2 = 802-13-13;
	$("#giftFinder").css("width", w + "px");

	if (w < w2) {
		w = parseInt(w) + 10;
		
		setTimeout(function() {expandGiftFinder(w) }, 0);
	} else {
		expandGiftFinder(w2);
	}
}
*/
