function redirect (url) {

	location.href = url;

	return false;

}

function confirm_redirect (url, message) {

	if (confirm (message))
		redirect (url);

	return false;

}

function confirm_delete (url, message)
{
	if (confirm (message))
		redirect (url);
}

function show (id)
{
	$('#' + id).show();
}

function hide (id)
{
	$('#' + id).hide();
}

function toggle_visibility(id)
{
	$('#' + id).toggle();
}

function get_XML_element_content(tag, xmlString){

	var startTag = "<"+tag+">";
	var endTag = "</"+tag+">";

	return xmlString.substring( (xmlString.indexOf(startTag)+startTag.length) , (xmlString.indexOf(endTag,xmlString.indexOf(startTag)+startTag.length)) );
}

function nl2br(str){
	return str.replace(/\n/g,'<br/>');
}

function urlencode(str) {
	var result = "";

	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") result += "+";
		else result += str.charAt(i);
	}

	return escape(result);
}

function urldecode(str) {
	return unescape(str.replace(/\+/g, " "));
}

$(document).ready(function()
{
	//Clear the search box on focus
	$('#search, #newsletter_full_name, #newsletter_email, .clear-on-focus').bind('focus',function(){
		this.value = '';
	});
	
	$('#print-page').bind('click',function(){
		window.print();
	});
	
	$('a.popup-window').bind('click',function(){
		window.open(this.href);
		return false;
	});
	
	$('span.podCastAudioWidget').hide();
	
	$('a.podCastLink').bind('click',function(){
		$('span.podCastAudioWidget').toggle('slow');		
		return false;
	});
	
	
	
	$('form.newsletterForm').submit(function(){
					var email=$('form.newsletterForm input#email').val();
					
					$('form.newsletterForm input#email').val('');
					
					$('p.signupConfirm').html('Thank you for signing up for email updates from Growing Tree Toys!');
					$('p.signupConfirm').append('<img src="http://app.bronto.com/public/?q=direct_add&fn=Public_DirectAddForm&id=aqpjrsrrhmcqbucccopvtfdebbnkbfm&email='+email+'&sendWelcome=always&messageId=62d67017dd3ba5a4148ccb068243b3ce&fromName=Growing+Tree+Toys&fromAddress=info%40growingtreetoys.com&list1=0bba03ec000000000000000000000002e93d&field1=S_Site_Footer,set,Yes" width="0" height="0" border="0" alt=""/>');
												   
			    /*    var url = '/json/index/newsletter_subscribe/?email='+email;
			        $.getJSON(url,function(data){
			                        if(data.result == '0')
			                        { */
			     //                           $('div.signupConfirm').show();
			     //                           $('form.newsletterForm').hide();
			                        //}
			                //});
			                return false;
		});
});

