﻿function checkSearch(){
		if ( document.search.searchField.value == "" ) {
		alert("Please enter a search query.")
		document.search.searchField.focus()
		return false
	}
	else
		return true
}
function bookmark(){
	if (document.all){
		window.external.AddFavorite('http://www.drinkstuff.com','Drinkstuff.com - Home to all Gadgets, Gifts & Bar Stuff related to booze')
	}
	else{
		alert("With your current browser we can not add this page to your favourites automatically. Please set manually.")
	}
}
function checkAdd(intQuantity, strProduct){
	//if (confirm("Do you want to add "+intQuantity+" x \""+strProduct+"\" to your basket?"))
		return true;
	//else
	//	return false;
}
function collectionOnly(intQuantity, strProduct)
{

	alert("Sorry, the "+strProduct+" is only available for collection or local delivery, please phone <%= strDrinkstuffPhoneNumber%> to check if we can deliver to your area.");
	return false;
}
function checkAddoption(intQuantity, strProduct, frm){
	var selectedItem = frm.selectedIndex;
	var selectedText = frm.options[selectedItem].text;
	var selectedValue = frm.options[selectedItem].value;
	if (selectedValue > 0){
		//if (confirm("Do you want to add "+intQuantity+" x \""+strProduct+" ("+selectedText+")\" to your basket?"))
			return true;
		//else
		//	return false;
	}
	else{
		alert("Please select which type of \""+strProduct+"\" to add\nby clicking the drop down box next to the add button.");
		return false;
	}
}
function GenEmail(user, domain, suffix){
	return(user + '@' + domain + '.' + suffix)
}
function PrintEmail(user, domain, suffix, url){
	if (url=="")
		document.write('<A HREF=mail'+'to:' + user + '@' + domain + '.' + suffix + '>' + user + '@' + domain + '.' + suffix + '</A>')
	else
		document.write('<A HREF=' + url + '>' + user + '@' + domain + '.' + suffix + '</A>')
}
function newwin(url,width,height)
{
	window.open(url,'','menubar=0, tollbar=0, scrollbar=0, status=0, height='+height+', width='+width)
}
function showCurrency(){
	el = document.getElementById('currencydd');
	
	if (el) {
		if (el.style.display != 'block')
			el.style.display = 'block';
		else
			el.style.display = 'none';
	}
}
function closeAddedToBasket(){
	document.getElementById('addedToBasket').style.display = 'none';
}



function initTreepodia () { 
  var product = Treepodia.getProduct('UA-DRINKSTUFF',strTreepodiaProductID);
  product.requestVideo(videoHandlerFunc);
  if(queryString('added')=='true') {
    handleAddToCart(product);
  } 
} 
function videoHandlerFunc(videoController) { 
  if(videoController.hasVideos()) {
    videoController.show('video-player-location'); 
  } else { } 
} 
function handleAddToCart (product) { 
  try { 
    product.logAddToCart(); 
  } catch (e) {}
}

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
	for(var j=0; j < this.keyValuePairs.length; j++) {
		if(this.keyValuePairs[j].split("=")[0] == s)
		return this.keyValuePairs[j].split("=")[1];
	}
	return false;
	}
	this.getParameters = function() {
	var a = new Array(this.getLength());
	for(var j=0; j < this.keyValuePairs.length; j++) {
	a[j] = this.keyValuePairs[j].split("=")[0];
	}
	return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}