
function pic_replace(newpic,layout){
	eval('document.getElementById("imagelarge").src="' + newpic + '"');
	if (layout == "l") {
		document.getElementById('mainpic').style.paddingTop="50px";
	} else {
		document.getElementById('mainpic').style.paddingTop="0px";
	}
}

function popup(sitepath,filename,winwidth,winheight) {
	var file= sitepath + filename;
	if (winheight < 10) {
		winheight = 200;
	}
	window.open(file,"popupwin","scrollbars=yes,width=" + winwidth + ",height=" + winheight);
}

function searchnav(pageno) {
	eval('document.searchresultselector.pg.value="' +  pageno + '"');
	document.searchresultselector.submit();
}


function price_check_pop(){
	window.open('ad_cost_pop.php','ad_cost','height=600,width=750,scrollbars=yes');

}
function sellmy_price_check_pop(instr,siteurl){
	var win ='http://' + siteurl + '/ad_cost_pop.php?s=' + instr;
	window.open(win,'ad_cost','alwaysRaised=yes,height=400,width=650,scrollbars=yes,location=no,toolbar=no');
}

function js_price_guide(){
	document.getElementById('price_check_pop_link').href="JavaScript:price_check_pop()";
	document.getElementById('price_check_pop_link').target='';
	if (document.getElementById('price_check_pop_link1')) {
		document.getElementById('price_check_pop_link1').href="JavaScript:price_check_pop()";
		document.getElementById('price_check_pop_link1').target='';
	}

}

function showSellerInfoBox(){
	document.getElementById('home_seller_show').style.display="none";
	document.getElementById('home_seller_info').style.display="block";
	document.getElementById('home_seller_hide').style.display="block";
	document.getElementById('home_seller_info').style.padding ="10px";
 	document.getElementById('home_seller_info').style.marginTop="25px";
	document.getElementById('home_seller_info').style.border="1px solid #CACACA";
//	document.getElementById('home_seller_info').style.borderTop="none";
}

function hideSellerInfoBox(){
	document.getElementById('home_seller_show').style.display="block";
	document.getElementById('home_seller_info').style.display="none";
	document.getElementById('home_seller_hide').style.display="none";
}


function SearchAllInstrumentBtn(){
	document.searchform._searchkeyword.value='';
	document.searchform._searchpostcode.value='';
	document.searchform.viewall.value='view';
	document.searchform.submit();
}
function SearchAllMusicBtn(){
	document.printsearchform._searchtitle.value='';
	document.printsearchform._searchcomposer.value='';
	document.printsearchform._searchpublisher.value='';
	document.printsearchform._searchkeyword.value='';
	document.printsearchform.viewall.value='view';
	document.printsearchform.submit();
}

// check the user has correctly populated the fields before they submit the form
function check_invoice_rqform(){
	var err = new Array();
	var error_msg = '';
	var errormessage = '';
	var j=0;

		var email    = document.request_invoice_form._buyer_email.value;
		var name     = document.request_invoice_form._buyer_name.value;
		var address  = document.request_invoice_form._buyer_address.value;
		var sec_code = document.request_invoice_form._sec_code.value;
		var tandc    = document.request_invoice_form.agree_box.checked;

		if (name.length < 3) {
			err[j] = 'Your name';
			j++;
		}
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (! filter.test(email)) {
			err[j] = "Valid email address";
			j++;
		}
		if (address.length < 3) {
			err[j] = 'Your address';
			j++;
		}

		if (sec_code.length < 3 || sec_code.length > 3) {
			err[j] = 'The 3 digit anti-spam code ';
			j++;
		}
		if (tandc == false) {
			err[j] = '\nPlease tick the box to confirm that you are dealing directly with the seller ';
			j++;
		}

 	for (i=0; i < err.length; i++) {
 		error_msg += err[i] + ', ';
 	}

	error_message = error_msg.substr(0,(error_msg.length)-2);
	if (error_message.length > 0) {
		error_msg = "Please check the following fields:\n\n" + error_message;
 		alert (error_msg);
	} else {
		document.request_invoice_form.submit();
	}
}
function check_pp_rqform(){

	var errormessage = '';



		var tandc    = document.paypal_buynow_form.agree_box.checked;


		if (tandc == false) {
			errormessage = 'Please tick the box to confirm that you are dealing directly with the seller ';
		}


	if (errormessage.length > 0) {
//		error_msg = "Please check the following fields:\n\n" + error_message;
 		alert (errormessage);
	} else {
		document.paypal_buynow_form.submit();
	}
}


function register_teacher(){
	document.getElementById('_registerform').action = 'place_an_ad.php?r=9';
	document.getElementById('_registerform').submit();

}