function show(id){
	var dropId = id + "_drop_container";
	var dropContainer = document.getElementById(dropId);
	dropContainer.style.display = "block";
	return;
}
function hide(id){
	var dropId = id + "_drop_container";
	var dropContainer = document.getElementById(dropId);
	dropContainer.style.display = "none";
}

function events(){
	var pageName = document.URL.substring(document.URL.lastIndexOf("/")+1).split(".")[0];
	var btnName = document.getElementById(pageName + "_btn");
	btnName.className = "on";
	
	var titleText = document.getElementById("title").innerHTML;
	var calendarContainer = document.getElementById("calendar_link_container");
	var calendarLinks = calendarContainer.getElementsByTagName("a");
	var yearText = titleText.substring(titleText.lastIndexOf(" ")+1);

	var i;
	for(i=0;i<calendarLinks.length;i++)
		{
			calendarBtns = calendarLinks[i];
			if(calendarBtns != null)
				{	
				calendarBtns.title = calendarBtns.title + " " + yearText
				}
		}
}

function ie6(){
	if(navigator.userAgent.toLowerCase().indexOf("msie 6")!==-1){
		return true;	
	}
	else
	{
		return false;	
	}
}
function checkExtension(img){
	if(ie6()){
		alert(1);
		img.src.replace("png", "gif");
	}
}

var parentElement;

function getParent(tag, parentTagName){
	if(tag.parentNode.tagName.toLowerCase() == parentTagName.toLowerCase()){
		parentElement = tag.parentNode;
	}
	else {
		getParent(tag.parentNode, parentTagName);	
	}
}



function addFeaturedToBasket(button){
	getParent(button, "FORM");
	var form = parentElement;
	//var size = form.featured_size;
	//var colour = form.featured_colour;
	//alert(colour)
	//var qty = form.featured_quantity;
	//var code = form.product_code.value;
	//var productCode = form.add_item.value
	//productCode = code;
	/*if(size !="undefined"){
		alert(1);
		if(size.value != 0){
			productCode = productCode + size.value;
		}
		else {
			alert("You must select a size");	
			return;
		}
	}
	alert(colour);
	if(colour !="undefined" || colour !==null){
		alert(2);
		if(colour.value != 0){
			productCode = productCode + colour.value;	
			alert(productCode);
		}
		else {
			alert("You must select a colour");	
			return;
		}
	}
	if(qty !="undefined"){
		alert(3);
		if(qty.value != 0 ){
			form.add_quantity.value = qty.value;	
		}
		else{
			alert("You must select a quantity to add to your basket");
			return;
		}	
	}
	form.add_item.value = productCode;
	alert(form.add_item.value, form.add_quantity.value);*/
	form.submit();
}

var image_set;

function setImageSet(linkBtn){
	image_set = [{'caption': linkBtn.getAttribute("zoomTitle"), 'url': linkBtn.href}];	
}
/*
GB_myShow = function(imgLink) {
var options = {
caption: imgLink.getAttribute("zoomTitle"),
//height: height || 500,
//width: width || 500,
fullscreen: true,
show_loading: true,
//callback_fn: callback_fn
}
var win = new GB_Window(options);
return win.show(imgLink.href);
}
*/
function clearForm(formElement){
	if(formElement.tagName.toLowerCase() == "input"){
		if(formElement.value == formElement.getAttribute("defaultValue")){
			formElement.value = "";
			formElement.className = "on";
			return;
		}
		if(formElement.value == ""){
			formElement.value = formElement.getAttribute("defaultValue")
			formElement.className = "off";
			return;
		}
	}
	if(formElement.tagName.toLowerCase() == "textarea"){
		if(formElement.innerHTML == formElement.getAttribute("defaultValue")){
			formElement.innerHTML = "";
			formElement.className = formElement.className.replace("off", "on");
			return;
		}
		if(formElement.innerHTML == formElement.getAttribute("defaultValue")){
			formElement.innerHTML = formElement.getAttribute("defaultValue");
			formElement.className = formElement.className.replace("off", "on");
			return;
		}
	}																													  
}
function clearForm_(formElement){
if(formElement.tagName.toLowerCase() == "input"){
		if(formElement.value == ""){
			formElement.value = formElement.getAttribute("defaultValue")
			formElement.className = formElement.className.replace("on", "off");
			return;
		}
	}
	if(formElement.tagName.toLowerCase() == "textarea"){
		if(formElement.innerHTML == ""){
			formElement.innerHTML = formElement.getAttribute("defaultValue");
			formElement.className = formElement.className.replace("on", "off");
			return;
		}
	}		
}

function submitReview(submitBtn){
	getParent(submitBtn, "FORM");
	var form = parentElement;
	var allFormElements = form.elements;
	var i;
	for(i=0; i<allFormElements.length; i++){
		allFormElements[i].className = allFormElements[i].className.replace(" error", "");
		if(allFormElements[i].getAttribute("required") == "true"){
			if(allFormElements[i].tagName.toLowerCase() == "input"){
				if(allFormElements[i].value == allFormElements[i].getAttribute("defaultValue") || allFormElements[i].value == ""){
					allFormElements[i].className = allFormElements[i].className + " error";	
					alert("You must leave a " + allFormElements[i].name);
					return;
				}
			}
			if(allFormElements[i].tagName.toLowerCase() == "textarea"){
				if(allFormElements[i].innerHTML == allFormElements[i].getAttribute("defaultValue") || allFormElements[i].innerHTML == ""){
					allFormElements[i].className = allFormElements[i].className + " error";	
					alert("You must leave a " + allFormElements[i].name);
					return;
				}
			}
		}
		if(allFormElements[i].tagName.toLowerCase() == "select"){
			if(allFormElements[i].value == "0"){
				alert("You must leave a " + allFormElements[i].name + " for the product");
				return;
			}
		}
	}
	form.submit();
	return;
}