function sidebarHeight() {
	//makes sidebar extend the length of the page content
	homeHeight = $(".narrowcolumn").height();
	otherHeight = $(".widecolumn").height();
	sideBar = $(".sidebar_general").height();
		if(homeHeight > sideBar) {
		$(".sidebar_general").height(homeHeight);
	}
		if(otherHeight > sideBar) {
		$(".sidebar_general").height(otherHeight);	
	}
}

function showCategories() {
	$("#categories_list").toggle();
}

//page initialize functions
function initSheFinds() {
	sidebarHeight();	
}

function testXML(url) {
	$.ajax({
	  type: "GET",
	  url: url,
	  dataType: "text",
	  success:function(data){alert(data)}
	});
}

//pronto xml functionality 
function getPronto(url,placement,searchTerm) {
		$.ajax({
			url:url,
			dataType: "text",
			success: function(data){ 
			     var xml;
			     if ($.browser.msie) { 
			       xml = new ActiveXObject("Microsoft.XMLDOM");
			       xml.async = false;
			       xml.loadXML(data);
			     } else {
			       xml = data;
			     }

			$('item',xml).each(function(){

			productImage = $(this).find("imageURL").text();
			productPrice = $(this).find("totalPrice").text();
			productMinPrice = $(this).find("minPrice").text();
			productLink = $(this).find("productURL").text();
			productName = $(this).find("title").text();


			//fix screwy pronto pricing model
			if(productPrice == "") { productPrice = productMinPrice }

			//carousel placement
			if(placement == 0) {
			$("#pronto").append("<div class=pronto_product><a href="+productLink+" target=_blank><img src="+productImage+" />"+productName+"</a><br>$"+productPrice+"</div>");

			} 

			//sidebar placement
			if(placement == 1) {
			$("#pronto").append("<div class=pronto_sidebar><a href="+productLink+" target=_blank><img width=100 height=80 src="+productImage+" /><br><strong>"+productName+"</strong></a><p>$"+productPrice+"</p></div>");
			} 

			//full page placement
			if(placement == 2) {
			$("#pronto").append("<div class=pronto_main><a href="+productLink+" target=_blank><img src="+productImage+" /><br><strong>"+productName+"</strong></a>$"+productPrice+"</div>");		
			}

			})	
			//more products button
			if(placement == 1) {
				searchFriendly = searchTerm.replace("-","&nbsp;");
				$("#pronto").append("<a href=http://www.shefinds.com/shop/?shop_term="+searchTerm+" class=pronto_pagination>Show all in "+searchFriendly+"</a>");
    		}
		}	
	});
}

/* sends an email to notify shefinds that something is sold out */
function soldOut() {
	var email = "tips@shefinds.com";
	var soldOutGuide = document.location;
	var emailMsg = "sold out tip"
	var emailBody = "Thanks for letting us know you found something that was sold out! Let us know the item in the space below you wanted and we'll let you know when it's back in stock. Buying Guide:"+soldOutGuide;
	var emailString = 'mailto:'+email+'?subject='+emailMsg+'&body='+emailBody;
	window.open(emailString,'soldout');
}

/*create a string pronto can use to search for products */

function sendProntoSearch(value) {
	prontoValue = value.replace(/\s+/g,'-');
	document.location = '/shop/?shop_term='+prontoValue+'&title='+value;
}