// JavaScript Document
//want $ to work with other libs
$.noConflict();
//function searchbox (){
	//$("#searchtxt").val(">");
//};

//$(document).ready(homeboxes);

//function homeboxes(){
	//$(".details").equalizeCols(0);
//};

$(document).ready(studybox);

function studybox(){
	$(".studycontent").equalizeCols(0);
};

$(document).ready(cols);

function cols(){
	$(".innerinfo").equalizeCols(0);
};

$(document).ready(sidebar);

function sidebar(){
	$("#sidebar1, #innercontent, #sidebar2").equalizeCols(0);
	$('#rating ul').before($('#rating span'));
};

function dropshadow(){
	$("div.dropshadow").wrap("<div class='wrap1'><div class='wrap2'>" +
   	"<div class='wrap3'></div></div></div>");
};
//used by filter drop down 
$(document).ready(filterRedirect);
function filterRedirect(){

	$('#filter').change(function(){

		document.location.href=document.location.href.split('?')[0] + '?filter=' + encodeURIComponent($('#filter option:selected').val());
	 //have to do this to stop the post back which occurs
	 //return false;
 });

};

//
$(document).ready(redirectToStockistsSearch);
function redirectToStockistsSearch(){
  $('#stockistSearch').click(function(){
	//if($('#location option:selected').val()!='' && $('#location option:selected').val()!='Please select filter'){
  	  document.location.href = $('#searchFormRedirect').val() + "?location=" + encodeURIComponent($('#location option:selected').val());
	//}
	//else{
	//	alert("Please select location");
	//}
     }
  );
}


$(document).ready(function() {
	$('#paypal').submit(function(){
	if($('#region option:selected').val() == 'default')
	{
		$('#error').css('display','inline');
		return false;
	}
	else { 
		$('#buyNow').attr("disabled", "true");
		$('#wait').show();
		return true; 
	}
	});
	$('#region').change(function(){
	if($(this).val() == 'default')
	{
		$('#error').css('display','inline');
	}
	else {
		$('#error').hide();
		$('#shipping').val($(this).val());	
	}	
	});
	$('#buyNow').click(function(){
	if($('#region option:selected').val() == 'default')
	{
		$('#error').css('display','inline');
		return false;
	}
	else {

		$('#buyNow').attr("disabled", "true");
		$('#wait').show();
		$('#paypal').submit();
 	}
	});
});



$(document).ready(alterTable);
function alterTable()
{
if($('#AutoForm_8_PanelInput').length == 0) /*if page isn't submit cliche*/
{
	$('fieldset p:eq(2) input').after("<br />&nbsp;(optional - remember http://)<br /><br />");
}
else if($('#AutoForm_9_PanelInput').length > 0)// 9
{
/*$('fieldset p:eq(4)').append($('.umbCaptchaHolder #AutoForm_9_captchaImage'));*/
	$('span:contains("(not shown)")').hide();
	$('span:contains("optional")').hide();

} 
else if($('#AutoForm_12_PanelInput').length > 0)// 12
{
	$('fieldset p:eq(4)').append($('#AutoForm_12_captchaImage'));
	$('#AutoForm_12_PanelInput #umbracoAutoForm fieldset p:eq(4) label').css('margin-right','0');
} 

/*else
{
	$('fieldset p:eq(2) input').after("<br /><br />");
}*/
$('fieldset p:eq(4)').append($('.umbCaptchaHolder input'));

$('span:contains("human")').after($('.umbCaptchaHolder'));
$('span:contains("(not shown)")').hide();
$('span:contains("optional")').hide();

$('fieldset p:eq(1) input').after("<br />&nbsp;(Personalise your comments with a <a href=\"http://en.gravatar.com\" target=\"blank\" title=\"Get yourself a Gravatar\">Gravatar</a>)<br />");

}