// Preload
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Redirect
function redirect(Url){
	
	document.location = Url;
	
}

// Checkout
function deleteItem(id) {
	
	frm = document.getElementById('frmBasket');
	frm.action.value = 'deleteItem';
	frm.itemId.value = id;
	frm.submit();
	
}

// Change colour for thumbnail view
function changeColour(productContainerId, productName, productUrl, productImage){
	
	var imageTemplate = new Template('<a href="#{productUrl}"><img src="#{productImage}" alt=""></a>');	
	
	$(productContainerId).update(imageTemplate.evaluate({ 
		productUrl:productUrl, 
		productImage:productImage 
	}));
	
}

// Change additional image for product details
function changeImage(containerId, imageName, imageLocation, largeLocation){
	
	if(largeLocation.length){
		imageTemplate = new Template('<a href="#{largeLocation}" class="lightwindow" title="#{imageName}"><img src="#{imageLocation}" alt=""></a>');
	
		$(containerId).update(imageTemplate.evaluate({ 
			imageName:imageName, 
			imageLocation:imageLocation,
			largeLocation:largeLocation
		}));
		
		// Have to call lightwindow again to parse the DOM tree finding all the lightwindow references
		lightwindowInit();
		
	}
	else {
		
		imageTemplate = new Template('<img src="#{imageLocation}" alt="">');
		
		$(containerId).update(imageTemplate.evaluate({ 
			imageLocation:imageLocation
		}));
	}

	
}

// Online Help 
function toggleOnlineHelp(elId) {

	aEls = $$('#OnlineHelp a.Link');

	for(i=0; i < aEls.length; i++)
		aEls[i].removeClassName('Selected');
	
	divEls = $$('#OnlineHelp div');
	for(i=0; i < divEls.length; i++)
		divEls[i].hide();
		
	$('Link' + elId).addClassName('Selected');
	$('Item' + elId).show();
	
}

// Gallery - wallpapers
function MM_jumpMenu(targ,selObj,restore){ //v3.0

  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore)
  	selObj.selectedIndex=0;
  
}

function displayPrettySearch(){

	var els = document.getElementsByTagName('input');

	for(var i=0; i<els.length ;i++){

		if(Element.hasClassName(els[i],'PrettySearch'))

			new Control.DecorateSearch(els[i]);

	}

}
