﻿// JavaScript Document
var timerCookie;

function openContactUs(){
	$('openContactUs').style.display = "none";
	$('closeContactUs').style.display = "";
	new Effect.BlindDown($('contactustrans'));
}
function closeContactUs(){
	$('closeContactUs').style.display = "none";
	$('openContactUs').style.display = "";
	new Effect.BlindUp($('contactustrans'));
}

function openAreasCovered(){
	$('openAreasCovered').style.display = "none";
	$('closeAreasCovered').style.display = "";
	new Effect.BlindDown($('areascoveredtrans'));
}
function closeAreasCovered(){
	$('closeAreasCovered').style.display = "none";
	$('openAreasCovered').style.display = "";
	new Effect.BlindUp($('areascoveredtrans'));
}
function featureOver(id,pos){
	id.style.backgroundPosition = pos;
	id.style.cursor = "pointer";
}
function featureOut(id,pos){
	id.style.backgroundPosition = pos;
	id.style.cursor = "";
}
function featureClick(id){
	link = $(id).down('a');
	if(link != undefined) {
		location.href = link.href;
	}
}
function headermenu(item){
	if($(item)){
		$(item).addClassName('header-menu-on');
	}
}
function continueShoppingB(cSLink){
	switch (cSLink) {
		case 'blinds':
			$('moreblinds').style.display = "";
		break;
		case 'shutters':
			$('moreshutters').style.display = "";
		break;
	}
}
function additem(itemid){
	
	quty = $('quantity'+itemid).value;

	new Ajax.Request('/modules/shop/add.php', {
	  method: 'get',
	  parameters: {dataid: itemid, orderquantity: quty},
	  onSuccess: cartchanged
	  });
	
}
function cartchanged(transport){
	$('products_cartnote').style.display = "";
	setTimeout("$('products_cartnote').style.display = 'none';", 2000 );
}
function onLoad() {
	// this doesn't help, Opera is currently broken:
	if (window.opera && window.history) {
		history.navigationMode = 'compatible';
	}
	// Set-up the polling:
	timerCookie = window.setTimeout(onTick, 200);
}
function onUnload() {
	if (timerCookie) {
		window.clearTimeout(timerCookie);
	}
}
function galleryZoom(id) {

	imagebox = "gallery_image_"+id;
	imagelink = $(imagebox).select('a');
	popUp(imagelink[0].href,300,400);
//	eval("page" + id + " = window.open('" + imagelink[0].href + "', 'page" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=400');");
//	window.location.href = imagelink[0].href;
	return false;
}

function temporder(width) {
	
	tempsmall = 0;
	
	templarge = Math.floor(width / 1210);
	
	widthleft = width - (templarge * 1210);
	
	if(widthleft < 910) {
		tempsmall = 1;
	}
	else {
		templarge = templarge + 1;
	}
	baskettempsmall += tempsmall;
	baskettemplarge += templarge;
}

function tempExtraOrder() {
	
	baskettempsmall = baskettempsmall - dataid[99];
	baskettemplarge = baskettemplarge - dataid[100];
	
	if(baskettempsmall > 0 || baskettemplarge > 0) {
		$('extraTemps').style.display = "";
		extraTempsTotal = 0;
		if(baskettempsmall > 0)	{
			extraTempsTotal = baskettempsmall * 5;
		}
		if(baskettemplarge > 0)	{
			extraTempsTotal = extraTempsTotal + (baskettemplarge * 8);
		}
		$('extraTempsPrice').innerHTML = extraTempsTotal;
	}
	
	
}
function getDataQuantity(basid) {
	if($('quantity['+basid+']')) {
		return $('quantity['+basid+']').value;
	}
}

function tempExtraOrderAdd() {
	
	if(baskettempsmall > 0)	{
		new Ajax.Request('/modules/shop/add.php', {method: 'get', parameters: {dataid: 99, orderquantity: baskettempsmall}});
	}
	if(baskettemplarge > 0)	{
		new Ajax.Request('/modules/shop/add.php', {method: 'get', parameters: {dataid: 100, orderquantity: baskettemplarge}});
	}
	setTimeout("window.location = '/Basket/'", 1000 )
}
