// JavaScript Document
var timerCookie;

var infoArray = new Array();

var topBanners = [
	['t-save-realwood.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['code','loadPriceComparison'],
	['t-save-faux.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['t-custom-made.jpg','http://www.theshutterstore.com/Our-shutters/'],
	['t-blinds.jpg','http://www.theshutterstore.com/Window-blinds/']
];
var bottomBanners = [
	['b-no-sales-tax.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['b-save.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['b-save.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['b-blinds.jpg','http://www.theshutterstore.com/Window-blinds/']
];

var topBannersNOTSHOWING = [
	['t-SAVE-shutters.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['t-promise.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['t-easy-installation.jpg','http://www.theshutterstore.com/Our-shutters/DIY-shutters/'],
	['t-quality.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['t-here-to-help.jpg','http://www.theshutterstore.com/Discount-shutters/'],
	['b-love-prices.jpg','http://www.theshutterstore.com/Discount-shutters/'],
];

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 featureOver2(id,pos){
	id.style.backgroundPosition = pos;
}
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){
	linkss = cSLink.split(" ")
	linkss.each(function(item) {
   		if((item) == 'blinds'){
   			$('moreblinds').show();
   		}
   		if((item) == 'shutters'){
   			$('moreshutters').show();
   		}  	
	});
}
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,700,700);
//	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;
}

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 )
}


var wait = true;
var displayTime = 2;
var speed = 8;
var scrollitem;
var currentitem = 0;
var totalitems;
var back = false;

function scrollcasestudies(){
	var position = parseInt(scrollitem.style.left);
	if(!wait){
		if(back)
  			position = position + speed;
  		else
 			position = position - speed;
  		
  		scrollitem.style.left = position + "px";
  		
  		if(back){
	 		if((currentitem * -100) < position){
	 			scrollitem.style.left = (currentitem * -100) + "px";
	 			if(currentitem == 0)
	 				back = false;
				wait = true;
			}
		}
		else {
	 		if((currentitem * -100) > position){
	 			scrollitem.style.left = (currentitem * -100) + "px";
	 			if(currentitem == (totalitems - 1))
	 				back = true;
				wait = true;
			}
		}
		setTimeout("scrollcasestudies()",100);
    } else{
    	if(back)
    		currentitem--;
    	else
   			currentitem++;
    		
   	    wait = false;
		setTimeout("scrollcasestudies()", displayTime * 1000);
	}
}

function scrollcasestudiesInit(lenght){
	totalitems = lenght;
	scrollitem = document.getElementById('casestudiesscroll');
	scrollitem.style.left = "0px";
	scrollitem.style.width = (100 * lenght) + "px";
	scrollcasestudies();
}
function loadQuestion(id) {
	$('hank_text').replace('<div id="hank_text">'+$('faqA'+id).innerHTML+'</div>');
	
	$$('.questionanswer_list li a').each(function(value, index) { value.removeClassName('select');});
	$("faqQ"+id).addClassName('select');

}
function loadFirstQuestion() {
	questions = $$('.questionanswer_list li a');
	loadQuestion(questions[0].id.replace(/faqQ/, ""))
}

function hookMovies() {
//	$$('a[href~="movies"]').each(function(value, index) { value.observe('click', openMoviePanel); alert('H');});

	$$('a').each(function(value, index) { if(value.href.search(/\/sitestyle\/movies\/index.php/) != -1) {value.observe('click', openMoviePanel);value.target = "";} });
}
//addLoadEvent(hookMovies);

function openMoviePanel(event) {
	var element = event.element();
	if(!element.href){
		element = event.findElement('a');
	}
	event.stop(event);
	new Ajax.Request(element.href+'&script=Yes', {method: 'get', onSuccess: setUpMoviePanel});
	
	return false;
}
function setUpMoviePanel(response) {

	Effect.ScrollTo('doc');
	$$('body')[0].insert(response.responseText,{ position: 'bottom' });
	
	var arrayWebViewSize = getWebViewSize();
	$('movie_bg').style.height = arrayWebViewSize[1]+"px";
	
	$$('#movie_player_holder ul a').each(function(value, index) { value.observe('click', changeMovieTab);});
	$$('.panelMovies').each(function(value, index) { value.observe('click', changeMovie);});
	$$('.panelMovies').each(function(value, index) { value.observe('mouseover', changeNameOver);});
	$$('.panelMovies').each(function(value, index) { value.observe('mouseout', changeNameOut);});
	
	$('movie_close').observe('click', closeMoviePanel);
	
	$('movie_name').innerHTML = $$('.thumbs .select')[0].title;
	$$('.panelMovies').each(function(value, index) { value.observe('onmouseover', changeName);});
}
function changeMovieTab(event) {
	$$('#movie_player_holder ul a').each(function(value, index) { value.removeClassName('select');});
	$$('.panelMovies').each(function(value, index) { value.removeClassName('select');});
	var element = event.element();
	if(!element.href){
		element = event.findElement('a');
	}
	event.stop(event);
	
	var section = getURLVarFromString(element.href,'section');
	
	$$('.thumbs').each(function(value, index) { value.hide();});

	$('movieTab'+section).addClassName('select');
	$('thumbs'+section).show();
	element.addClassName('select');
	movie = playVideo(640,360,'file=/sitestyle/movies/flv/'+getURLVarFromString(element.href,'movie')+'.flv&skin=/sitestyle/movies/bekle.swf&controlbar=over','movies');
	$('movie_player').replace('<div id="movie_player">'+movie+'</div>');
	
	$$('#thumbs'+section+' a')[0].addClassName('select');
	return false;
}
function changeNameOver(event) {
	var element = event.element();
	if(!element.href){
		element = event.findElement('a');
	}
	$('movie_name').innerHTML = element.title;
}
function changeNameOut(event) {
	$('movie_name').innerHTML = $$('.thumbs .select')[0].title;
}
function changeMovie(event) {
	$$('.panelMovies').each(function(value, index) { value.removeClassName('select');});
	var element = event.element();
	if(!element.href){
		element = event.findElement('a');
	}
	event.stop(event);
	element.addClassName('select');
	movie = playVideo(640,360,'file=/sitestyle/movies/flv/'+getURLVarFromString(element.href,'movie')+'.flv&skin=/sitestyle/movies/bekle.swf&controlbar=over','movies');
	$('movie_player').replace('<div id="movie_player">'+movie+'</div>');
		
	return false;
}

function closeMoviePanel(event) {
	event.stop(event);
	$('movie_bg').remove();
	$('moviepanelholder').remove();
}

function getURLVarFromString(string,urlVarName) {
	//divide the URL in half at the '?' 
	var urlHalves = String(string).split('?');
	var urlVarValue = '';
	if(urlHalves[1]){
		//load all the name/value pairs into an array 
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable 
		for(i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				//load the name/value pair into an array 
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
					//I found a variable that matches, load it's value into the return variable 
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}
function setupProductTab() {
	addLoadEvent(moveDetails);
	changeProductTab('description');
}
function moveDetails() {
	$('right_coloumn').insert({ top: $('detailview') });
	$('detailview').show();
}

var readMoreRaady = false;

function changeProductTab(id) {
	$$('.tab').each(function(value, index) { value.removeClassName('on');});
	$$('.tabarea').each(function(value, index) { value.hide();});
	
	$('tab_'+id).addClassName('on');
	$('area_'+id).show();
	
	if(id == 'reviews' && !readMoreRaady){
		readMoreSetup();
	}
}

// Read more
function readMoreSetup(){
	$$('.apost .text').each(function(value, index) {
			if(value.getHeight() > 58){
				value.addClassName('short');
				value.insert({ after: '<a class="moretext" onClick="readMoreOpen(this);">read more...</a>' });
			}
		}
	);
	
}
function readMoreOpen(id){
	id.previous().removeClassName('short');
	id.replace('<a class="moretext" onClick="readMoreClose(this);">close</a>');
}
function readMoreClose(id){
	id.previous().addClassName('short');
	id.replace('<a class="moretext" onClick="readMoreOpen(this);">read more...</a>');
}

function compleateNSI(){
	new Ajax.Request('/sitestyle/modules/code/nsi/sendemails.php', {method: 'get'});
}

String.prototype.trim = function() {  return this.replace(/^\s+|\s+$/g, '');  }


var Slideshow = Class.create({
	initialize: function(id, delay, speed, items, action) {
		this.id = id;
		this.delay = delay;
		this.speed = speed;
		this.totalElmt = items.length;
		this.action = action;
		
		this.paused = 0;
		this.arrSlideElmt = [this.totalElmt];
		this.curElmtNum = 0
		this.forward = 1;
		this.curEffect1;
		this.curEffect2;
				
		block = '';
		//preload all elements into array and preload all images within element
		for (i = 0; i < this.totalElmt; i++) {
			if(items[i][0] != 'code'){	
				this.arrSlideElmt[i] = new Element('a', { href: items[i][1], 'class':'banner' });
				if(i != 0){
					this.arrSlideElmt[i].hide();
				}
				this.arrSlideElmt[i].insert({ top: new Element('img', {src: '/sitestyle/images/homepage-banners/'+items[i][0]}) });
	
				$(id+'banners').insert({ top: this.arrSlideElmt[i] });
				this.arrSlideElmt[i].observe('mouseover', function() { this.paused = 0;this.pause(); }.bind(this));  //pause on mouseover
				this.arrSlideElmt[i].observe('mouseout', function() { this.paused = 1;this.pause(); }.bind(this));  //resume on mouseout
				
				$$(this.arrSlideElmt[i].img).each(function(img) {	
					img = new Image();
				});
			}else{ // we want to execute the function call.
				
				//this.arrSlideElmt[i] = new Element('a', { href: items[i][1] });
				this.arrSlideElmt[i] = new Element('div', { id: "pricecompare" });
				$(id+'banners').insert({ top: this.arrSlideElmt[i] });
				$('pricecompare').hide();
				this.arrSlideElmt[i].observe('mouseover', function() { this.paused = 0;this.pause(); }.bind(this));  //pause on mouseover
				this.arrSlideElmt[i].observe('mouseout', function() { this.paused = 1;this.pause(); }.bind(this));  //resume on mouseout
				call_func = items[i][1] + '("'+ this.arrSlideElmt[i].id +'");'; // grab the name of the function and append brackets - evaluate to make js turn it into a function call
				eval(call_func);
				
				
			}
		
		}
		$$('.'+id+'_controls .cright').each(function(node) {
			node.observe('click', function(s){
				this.arrSlideElmt[this.curElmtNum].setStyle({ display: 'none' });
				this.checkSlide();
				if(this.curEffect1){
					this.curEffect1.cancel();
				}
				if(this.curEffect2){
					this.curEffect2.cancel();
				}
				this.arrSlideElmt[this.curElmtNum].setStyle({ display: 'block', left: '0px' });
				$$('.'+this.id+'_controls .cpause').each(function(node) {
					node.setStyle({backgroundPosition:'-37px -19px'});
				});
				this.paused = 1;
			}.bind(this));
		}.bind(this));
		$$('.'+id+'_controls .cleft').each(function(node) {
			node.observe('click', function(s){
				this.arrSlideElmt[this.curElmtNum].setStyle({ display: 'none' });
				this.forward = 0;
				this.checkSlide();
				if(this.curEffect1){
					this.curEffect1.cancel();
				}
				if(this.curEffect2){
					this.curEffect2.cancel();
				}
				this.arrSlideElmt[this.curElmtNum].setStyle({ display: 'block', left: '1px' });
				this.forward = 1;
				$$('.'+this.id+'_controls .cpause').each(function(node) {
					node.setStyle({backgroundPosition:'-37px -19px'});
				});
				this.paused = 1;
			}.bind(this));
		}.bind(this));
		$$('.'+id+'_controls .cpause').each(function(node) {
			node.observe('click', function(s){
				this.pause();
			}.bind(this));
		}.bind(this));
	},
	start: function() {
		if(this.totalElmt > 1){
			this.executor = new PeriodicalExecuter(function() {
				this.next(); //start slidehow
			}.bind(this), this.delay);
		}
	},
	
	next: function(){
		if (!this.paused) {
			this.update();
		}
	},
	pause: function(){
		if(this.paused == 1){
			this.paused = 0;
			$$('.'+this.id+'_controls .cpause').each(function(node) {
				node.setStyle({backgroundPosition:'-37px 0px'});
			});
		}
		else {
			this.paused = 1
			$$('.'+this.id+'_controls .cpause').each(function(node) {
				node.setStyle({backgroundPosition:'-37px -19px'});
			});
		}
	},
	update: function() {
		if(this.action == 'slide'){
			current = this.curElmtNum;
			width = this.arrSlideElmt[this.curElmtNum].getWidth();
			this.checkSlide();
			this.arrSlideElmt[this.curElmtNum].setStyle({left:width+'px'});
			this.arrSlideElmt[this.curElmtNum].show();
			
			this.curEffect1 = new Effect.Move(this.arrSlideElmt[current], { x: '-'+width, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, duration: this.speed, fps: 100 });	
			this.curEffect2 = new Effect.Move(this.arrSlideElmt[this.curElmtNum], { x: 0, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, duration: this.speed, fps: 100 });	
		}
		else {
			new Effect.Fade(this.arrSlideElmt[this.curElmtNum], { duration: this.speed });
			this.checkSlide();
			new Effect.Appear(this.arrSlideElmt[this.curElmtNum], { duration: this.speed });
		}

//		new Effect.Fade(this.arrSlideElmt[this.curElmtNum],{afterFinish:function(){
//			this.checkSlide();
//			new Effect.Appear(this.arrSlideElmt[this.curElmtNum]);
//		}.bind(this)});
	},
	checkSlide: function() {
		if(this.forward == 1){
			this.curElmtNum ++;
		}
		else {
			this.curElmtNum --;
		}
		if (this.curElmtNum == (this.totalElmt)) { this.curElmtNum = 0; }
		if (this.curElmtNum == -1) { this.curElmtNum = this.totalElmt -1; }
	}
});

function countryTest() {
	new Ajax.Request('/sitestyle/lib/class.maxmind.php', {method: 'get', onSuccess: countryResults});
}
function countryResults(response) {

	if(response.responseText == "IE"){
		window.location = 'http://www.plantationshutters.co.uk/';
	}
}

function setupColourHover() {
	$('doc').insert({'after': new Element('div', {'id':'hover_outer'})});
	$('hover_outer').hide();
	$(document).observe('mousemove', function(e) {
		_x = Event.pointerX(e)+10;
		_y = Event.pointerY(e)-160;

		$('hover_outer').setStyle({
			'left':_x+'px',
			'top':_y+'px'
		});
	});
}

function captureColourHover(id) {
	$$(id).invoke('observe', 'mouseover', function() {
			$('hover_outer').innerHTML = '<span class="'+this.className+'"></span>';
			$('hover_outer').show();
	}).invoke('observe', 'mouseout', function() {
//		$('hover_outer').innerHTML = '';
		$('hover_outer').hide();
	});
}

function loadPriceComparison(comp_div){ // we take the div object so we can inject html into it.
	/*
		This function is used to load up the price comparison json data and export out a div.
		The div will be used in the slideshow for the home page feature.
	*/

	 var test = new Ajax.Request('store/pricecomparison.json',
	 				{ 
	 				method:'get',
	 				onSuccess:function(oReq,oJson){

	 					var json = oReq.responseText.evalJSON();
	 					infoArray['store'] = json.main_info.replace(/\\\"/g,'"').replace(/\\'/g,"'");
	 					infoArray['company1'] =json.companies[0].info.replace(/\\\"/g,'"').replace(/\\'/g,"'");
	 					infoArray['company2'] =json.companies[1].info.replace(/\\\"/g,'"').replace(/\\'/g,"'");
	 					infoArray['company3'] =json.companies[2].info.replace(/\\\"/g,'"').replace(/\\'/g,"'");
	 					infoArray['company4'] =json.companies[3].info.replace(/\\\"/g,'"').replace(/\\'/g,"'");
	 					html_out =  '<table id="price_compare_table">' +
		 								'<tr class="h53 darkb otext title">' +
		 									'<td colspan="6" class="nopad">' + json.title.replace(/\\&quot;/g,'"').replace(/\\&#39;/g,"'") + '</td>' +
		 								'</tr>' +
		 								'<tr class="h40 lightb wtext">' +
		 									'<td class="other noshadow borderright nopad">info</td>' +
		 									'<td class="other left_al noshadow borderboth">Prices updated '+ json.date +' </td>' +
		 									'<td class="body borderboth">24" x 36"</td>'+
		 									'<td class="body borderboth">48" x 48"</td>' +
		 									'<td class="body borderboth">60" x 80"</td>' +
		 									'<td class="borderleft"></td>' +
		 								'</tr>' +
		 								'<tr class="h40 darkb gtext">' +
		 									'<td class="borderright nopad"><img src="sitestyle/images/info-price-compare.png" id="store" class="info_btn" onmouseover="priceInfoShow(\'store\',this)" onmouseout="priceInfoHide()" width="20" height="20"/></td>' +
		 									'<td class="body left_al borderboth">The Shutter Store</td>' +
		 									'<td class="body save_cut borderboth">$' + json.shutter_prices.price1 + '</td>'+
		 									'<td class="body save_cut borderboth">$' + json.shutter_prices.price2 + '</td>' +
		 									'<td class="body save_cut borderboth">$' + json.shutter_prices.price3 + '</td>' +
		 									'<td class="nopad borderleft"><a href="/Shutters/" class="price_comp_btn"></a></td>' +
		 								'</tr>' +
		 								'<tr class="h40 lightb wtext">' +
		 									'<td class="borderright nopad"><img src="sitestyle/images/info-price-compare.png" id="company1" onmouseover="priceInfoShow(\'company1\',this)" onmouseout="priceInfoHide()" class="info_btn" width="20" height="20"/></td>' +
		 									'<td class="body left_al borderboth">' + json.companies[0].company_name + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[0].price1 + '</td>'+
		 									'<td class="body borderboth">$' + json.companies[0].price2 + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[0].price3 + '</td>' +
		 									'<td class="gtext other left_al ital noshadow borderleft">Save up to $' + json.shutter_savings.saving1 + '</td>' +
		 								'</tr>' +
		 								'<tr class="h40 darkb wtext">' +
		 									'<td class="borderright nopad"><img src="sitestyle/images/info-price-compare.png" id="company2" onmouseover="priceInfoShow(\'company2\',this)" onmouseout="priceInfoHide()" class="info_btn" width="20" height="20"/></td>' +
		 									'<td class="body left_al borderboth">' + json.companies[1].company_name + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[1].price1 + '</td>'+
		 									'<td class="body borderboth">$' + json.companies[1].price2 + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[1].price3 + '</td>' +
		 									'<td class="gtext other left_al ital noshadow borderleft">Save up to $' + json.shutter_savings.saving2 + '</td>' +
		 								'</tr>' +
		 								'<tr class="h40 lightb wtext">' +
		 									'<td class="borderright nopad"><img src="sitestyle/images/info-price-compare.png" id="company3" onmouseover="priceInfoShow(\'company3\',this)" onmouseout="priceInfoHide()" class="info_btn" width="20" height="20"/></td>' +
		 									'<td class="body left_al borderboth">' + json.companies[2].company_name + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[2].price1 + '</td>'+
		 									'<td class="body borderboth">$' + json.companies[2].price2 + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[2].price3 + '</td>' +
		 									'<td class="gtext other left_al ital noshadow borderleft">Save up to $' + json.shutter_savings.saving3 + '</td>' +
		 								'</tr>' +
		 								'<tr class="h40 darkb wtext">' +
		 									'<td class="borderright nopad"><img src="sitestyle/images/info-price-compare.png" id="company4" onmouseover="priceInfoShow(\'company4\',this)" onmouseout="priceInfoHide()" class="info_btn" width="20" height="20"/></td>' +
		 									'<td class="body left_al borderboth">' + json.companies[3].company_name + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[3].price1 + '</td>'+
		 									'<td class="body borderboth">$' + json.companies[3].price2 + '</td>' +
		 									'<td class="body borderboth">$' + json.companies[3].price3 + '</td>' +
		 									'<td class="gtext other left_al ital noshadow borderleft">Save up to $' + json.shutter_savings.saving4 + '</td>' +
		 								'</tr>' +

		 								'<tr class="h40 lightb small btext">' +
		 									'<td colspan="6" class="left_al">' +
		 									'To ensure a like for like comparison, shipping charges are excluded, If shipping charges ARE included in the purchase price, this is indicated. Pricing examples use Z frame and standard front tilt rod option. Prices have been rounded to the nearest $ value for purposes of clarity.' +
											'</td>' +
		 								'</tr>' +
		 								'<tr class="h6 darkb btext">' +
		 									'<td colspan="6"></td>' +
		 								'</tr>' +
	 								'</table>';
	 								
	 								var info_div = '<div id="info_main">' +
													'<div id="info_main_left">' +
													'</div>' +
													'<div id="info_main_main">' +
														'<div id="info_main_main_top">' +
														'</div>' +
														'<div id="info_main_main_center">' +
															'<span id="info_content">' +
															'</span>' +
														'</div>' +
														'<div id="info_main_main_bottom">' +
														'</div>' +
													'</div>' +
													'<div style="clear:both"></div>' +
												'</div>';
												
									html_out = html_out + info_div;
	 										
	 					$(comp_div).insert(html_out);
	 					$('info_main').hide();
	 					
	 				}
	 				});
	

}

function priceInfoShow(info_id,btn){
	var offset = $(btn.id).positionedOffset(); 
	$('info_main').style.top = offset[1] - 20 + 'px';
	$('info_main').style.left = offset[0] + 20 +  'px';
	$('info_content').replace('<span id="info_content">' + infoArray[info_id] + '<span>');
	$('info_main').show();
}


function priceInfoHide(){
	$('info_main').hide();
}

function priceCompareFeature(){
	var test = new Ajax.Request('/store/pricecomparison.json',
	 				{ 
	 				method:'get',
	 				onSuccess:function(oReq,oJson){

	 					var json = oReq.responseText.evalJSON();
	 					$('c_p_f_shutter_price').replace('<span class="c_p_f_main_price" id="c_p_f_shutter_price">$ ' + json.shutter_prices.price1 + '</span>');
	 					
	 					var html_out = '<div id="c_p_f_comp_prices">' +
									'<div id="c_p_f_slide1"><div>' +
										'<span class="c_p_f_main_title">' + json.companies[0].company_name + '</span>'+
										'<span class="c_p_f_main_price">$ ' + json.companies[0].price1 + '</span>'+
									'</div></div>'+
									'<div id="c_p_f_slide2" style="display: none"><div>'+
										'<span class="c_p_f_main_title">' + json.companies[1].company_name + '</span>'+
										'<span class="c_p_f_main_price">$ ' + json.companies[1].price1 + '</span>'+
									'</div></div>'+
									'<div id="c_p_f_slide3" style="display: none"><div>'+
										'<span class="c_p_f_main_title">' + json.companies[2].company_name + '</span>'+
										'<span class="c_p_f_main_price">$ ' + json.companies[2].price1 + '</span>'+
									'</div></div>'+
									'<div id="c_p_f_slide4" style="display: none"><div>'+
										'<span class="c_p_f_main_title">' + json.companies[3].company_name + '</span>'+
										'<span class="c_p_f_main_price">$ ' + json.companies[3].price1 + '</span>'+
									'</div></div>'+
							'</div>';
	 					
	 					$('c_p_f_comp_prices').replace(html_out);
	 					 start_slideshow(1, 4, 4000);
    
					    function start_slideshow(start_frame, end_frame, delay) {
					        setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
					    }
					                            
					    function switch_slides(frame, start_frame, end_frame, delay) {
					        return (function() {
					            Effect.Fade('c_p_f_slide' + frame);
					            if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
					            setTimeout("Effect.Appear('c_p_f_slide" + frame + "');", 850);
					            setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 350);
					        })
					    }
	 				}
	 			});
}
