$(document).ready(pb_init);
function pb_init(){
	$("#pbtitlereviewslink").click(function(){ 
		if ($('.pbtitlereview').length > 0) {$('#pbtitlereviews').toggle('fast');}
		else {pb_load_data('#pbtitlereviews',$(this));}
		return false;
	});
}
function pb_load_data(strTo,oThis) {
	var toLoad = $(oThis).attr('href'); 
	$(strTo).html('<div>LOADING...</div>');
	$(strTo).show('fast');
	$(strTo).load(toLoad,'');
}
function pbWinOpen(file,win,w,h,left,top) {
	Win=window.open(file,win,'width='+w+',height='+h+',left='+left+',top='+top+',location=0,directories=0,status=0,toolbar=0,menubar=0,scrollbars=1,resizable=1');
	Win.focus();
}
function pbPrintThis(sURL) {
	var printWin = window.open(sURL,'_blank','height=400,width=600');
    	printWin.print();
}
function pbstars(iNum) {for (i=1;i<=5;i++){if (i <= iNum) {$('#star' + i).removeClass('stars1').addClass('stars2');}else{$('#star' + i).removeClass('stars2').addClass('stars1');}$('#pbgff8').attr('value', iNum);}}
function pbaddreviewfn(sURL){ 
	$('#pbaddreviewfrmid').submit(function() {
		var sGF="&GENFIELD", sData="PBFORMTYPE="+$('#pbgff1').attr('value') +"&SQS=" + $('#pbgff3').attr('value') + "&TITLEID=" + $('#pbgff2').attr('value') +"&TPART=" + $('#pbgff4').attr('value')+sGF+"1=" + $('#pbgff5').attr('value')+ sGF+"2="+$('#pbgff6').attr('value')+sGF+"3=" + $('#pbgff7').attr('value')+sGF+"4=" + $('#pbgff8').attr('value')+sGF+"5=" + $('#pbgff9').attr('value');
		$.ajax({
			type: "POST",
			url: sURL,
			data: sData,
			success: function(myData) {
				$('.pbreviewdone').show();
				$('.pbreviewadd').hide();
				$('.pbreviewdone').html(myData);
				$('.pbpopreview').show()
				$('.pbreviewdone').show(function() {setTimeout(function(){$('.pbreviewdone').fadeOut('fast');},5000);});
			}
			
		}); return false;
	});
}

function getBasketItems(params) {
	$.get("src", params, function(data) 
	{
		if( $('#basketcontent2').length) {$('#basketcontent2').empty();$('#basketcontent2').append(data);}
		else {$('#basketcontent').empty();$('#basketcontent').append(data);}

		
	});
}
function setPBB2(d, f) {
	if( $('#basketcontent2').length) {$('#basketcontent2').empty();$('#basketcontent2').append(d);}
	else {$('#basketcontent').empty();$('#basketcontent').append(d);}
	if (f==1) {
	$("#pbtbremove").hide();
	$("#pbtbadd").show();
	} else {
	$("#pbtbremove").show();
	$("#pbtbadd").hide(); 
	}
}
function ProcessGBSBookInfo(d) {
	var entrycount=0;
	for (i in d) { 
		entrycount++;
		var bookentry=d[i];
	}
	if (entrycount == 0) {
		$('#pbgooglebooklink').parent().parent().hide();
	}

}
