function toggleDisplay(clicked_link, id_to_slide)
{
	var elem = document.getElementById(clicked_link);
	action = elem.title
	if(elem.title.indexOf("Show") != -1)
	{
		Effect.SlideDown(id_to_slide, {duration: 0.3});
		elem.title = "Hide this";
	}
	else
	{
		Effect.SlideUp(id_to_slide, {duration: 0.3});
		elem.title = "Show this";
	}
}

function salesForceForm()
{
    Effect.Appear("salesForceForm", {duration: 0.7});
    document.location = '#bottom';
}

function defaultifyMainImage(domain_url)
{
    var image = new Image();
    image.src = "http://s3.amazonaws.com/wp4domains/" + domain_url + "/main.jpg";
    image.onload = imageIsNotLoaded(image);
    image.onerror = imageIsNotLoaded(image);
}

function imageIsNotLoaded(imgObj) {
   var invalid = (imgObj.width == 0 || imgObj.height == 0)
   if(typeof(imgObj.naturalWidth) != "undefined")
   {
       invalid = invalid || (imgObj.naturalWidth == 0)
   }

   if(typeof(imgObj.readyState) != "undefined")
   {
        invalid = invalid || (imgObj.readyState == "uninitialized")
   }

   if(invalid)
   {
       var elem = document.getElementsByClassName("element")[0];
       elem.setStyle({'backgroundImage': 'url(http://s3.amazonaws.com/wp4domains/backgrounds/default_background.jpg)'});
   }
}

//window.onload = function(){
//    var elem = document.getElementById("search-bottom-advanced");
//    elem.onclick = function(){
//        toggleDisplay(elem.id, "search-menu");
//        return false;
//    }
//}

/*function imageIsNotLoaded(imgObj) {
   if (typeof (imgObj.naturalWidth) != "undefined") return (imgObj.naturalWidth == 0);
   if (typeof (imgObj.readyState) != "undefined") return (imgObj.readyState == 'uninitialized');
   return ($(imgObj).width() == 0 || $(imgObj).height() == 0);
}*/