if(typeof jQuery == 'function') {
		$(function(){			

			$('.button').each(function() {
				//$(this).wrap('<i><i></i></i>');
				$(this).html('<i></i><span><i></i><span></span>'+$(this).html()+'</span>');
			});
			
			$('h1').each(function() {
				//$(this).wrap('<i><i></i></i>');
				$(this).html('<div class="leftbox"></div>'+$(this).html()+'<div class="rightbox"></div>');
			});
			
			$('.notice').fadeIn('slow');
			
		});
}

var contentitemid;

function set_pos(elem) {
	
		var docViewTop = $(window).scrollTop();
		var docViewBottom = docViewTop + $(window).height();
	
		var elemTop = $('#'+elem).offset().top;
		var elemBottom = elemTop + $('#'+elem).height();
		
		if (elemBottom >= docViewBottom) { 
		
			$('#'+elem).css('margin-top','-'+($('#'+elem).height()*0.5)+'px');
		}

}



function validate_integer(value) {
	var validcharacters = '0123456789';
	var isinteger = true;
	var i;
	for (i = 0; i < value.length && isinteger == true; i++)  { 
		character = value.charAt(i); 
		if (validcharacters.indexOf(character) == -1) {
			isinteger = false;
		}
	}
	return isinteger;
}


function edit_content(itemid,areaid,pageid) {
	contentitemid = itemid;
	if (shadowboxstatus == 'open') {
		toggle('shadowbox_overlay','on');
		toggle('shadowbox_container','on');
	} else {
		open_shadowbox('Edit Content','admin/index.php?com=content&action=update&popup=true&itemid='+itemid+'&areaid='+areaid+'&pageid='+pageid,800,700);
	}
}


function preview_content(description) {
	contentpreview = true;
	document.getElementById('content'+ contentitemid).innerHTML = description;
	toggle('shadowbox_overlay','off');
	toggle('shadowbox_container','off');
}

function check_shipping_method(refreshform) {
	flash_loader('shipzip');
	$.getJSON(websiteaddress+"helpers/lookup.php",{value: document.getElementById('method[]').value, ajax: 'true', datasource: 'auspostcalculator'}, function(j){
	  if(j.showpostcode == '1') {
		  toggle('containershipzip','on');
	  } else {
		  toggle('containershipzip','off');
		  if (refreshform) { refresh_form('orders'); }
	  }
	});
	setTimeout('cancel_flash_loader(\'shipzip\')',400);
	
}

function set_countries() {
	region = document.getElementById('region[]').value;
	if (set_selection('shipcountries[]',region,'byname')) {
		$('#containershipcountries').fadeOut('slow');	
	} else {
		$('#containershipcountries').fadeIn('slow');
	}
}


		
function show_review(id) {
	toggle('shortdesc'+id,'off');
	$('#description'+id).slideToggle('fast');
}

function review_useful(itemid,type) {
	$.post('helpers/reviews.php?itemid='+itemid+'&type='+type);
	var total = 0;
	useful = parseInt($('#useful' + itemid).html());
	total = parseInt($('#total' + itemid).html());
	
	if (type == 'yes') {
		$('#useful' + itemid).html(useful + 1);
	}
	$('#total' + itemid).html(total + 1);
	$('#yesno' + itemid).fadeOut('slow');
	
}


