// JavaScript Document

//clearing the search box
function clearBox(textBox){
	textBox.value = "";
}
//create global variable to store popup window ref (required when printing popups below)
var winPrint;
//printing current page
function printCurPage(URL){
	//first trim off the URL #anchorlinks
	if(URL.indexOf("#") >= 0)
	{
		URL = URL.substring(0,URL.indexOf("#"));
	}
	
	//open page as printer-friendly version
	winPrint = window.open(URL + '?ver=print','pageprint','scrollbars=yes,width=600,height=400');
	
//first make sure print method is supported by current browser
	if(window.print)
	{
		setTimeout('winPrint.print()', 4000);
		
	}
	else
	{
		alert("Your browser does not support this feature!!\n\nPlease use your Browser Toolbar to print Current Page!!");
	}
		setTimeout('winPrint.close()',7000);
}

//emailing current page
function emailCurPage(URL,title){
	//first trim off the URL #anchorlinks
	if(URL.indexOf("#") >= 0)
	{
		URL = URL.substring(0,URL.indexOf("#"));
	}
	else if(URL.indexOf("?") >= 0)
	{
		URL = URL.substring(0,URL.indexOf("?"));
	}
	//MM_openBrWindow('page_mailer.php?pageURL=' + URL + '&pageTitle=' + title + '','pagemailer','scrollbars=yes,width=400,height=390')
	top.location.href = 'https://www.buildingcentre.com/emailtoafriend.php?pageURL=' + URL + '&pageTitle=' + title;
}
function MM_openBrWindow(theURL,winName,features){ //v2.0
  window.open(theURL,winName,features);
}
//on click of a button open cart in the new window
function viewPayPalCart(){
	paypalWindow = MM_openBrWindow('https://www.paypal.com/cart/display=1&business=admin@buildingcentre.com&target=paypal&page_style=BCcart','MyShoppingCart','scrollbars=yes,resizable=yes,location=yes');
}

//this function expands/contracts the selected block contained by the clicked parent element
//in relies on /prototype-1.6.0.3.js and effects.js (must be loaded!!)
function slideInOutBlock(targetId,parentTableId){
	var targetDiv = document.getElementById(targetId);
	var parentTable = document.getElementById(parentTableId);

	if(targetDiv.style.display == "none"){
		Effect.SlideDown(targetDiv.id, { duration: 0.3 });
		parentTable.style.backgroundColor = "#D7E7F1";
	}else{
		Effect.SlideUp(targetDiv.id, { duration: 0.3 });
		parentTable.style.backgroundColor = "";
	}
}