//uniformNZ Javascript
if(document.images){var imgHovers=new Array(20);}
function lOn(id){
document.getElementById('lcat'+id+'').style.visibility='visible';
document.getElementById('mtp'+id+'').style.borderTop='1px solid #FF9900';
}
function lOff(id){
document.getElementById('lcat'+id+'').style.visibility='hidden';
document.getElementById('mtp'+id+'').style.borderTop='1px solid #1A1B1F';
}
function sCat(id){document.getElementById(id).style.visibility='visible';}
function hCat(id){document.getElementById(id).style.visibility='hidden';}
function changeHover(bg,hoverid){
if(bg==2){bg=''}
else{bg='#994D00'}
document.getElementById(hoverid).style.backgroundColor=bg;
}
function sUniforms(){
if(document.getElementById('hovermenu_border').style.display=='block'){hUniforms();}
else{
document.getElementById('hovermenu_border').style.display='block';
document.getElementById('uniform_shadow').style.display='block';
document.getElementById('uniform_button_link').style.backgroundPosition='170px 0px';
}
}
function hUniforms(){
document.getElementById('hovermenu_border').style.display='none';
document.getElementById('uniform_shadow').style.display='none';
document.getElementById('uniform_button_link').style.backgroundPosition='0px 0px';
}
var time;
clearInterval(time);
var sheight=0;
oheights="do";
var started="no";
var sbounce="no";
function sideMenus(head){
document.getElementById(head).style.borderLeft='2px solid #FF9900';
}
function delayMenus(id,head){
	if(document.getElementById('matching')!=null){document.getElementById('mu').onclick='';}
	if(document.getElementById('product_cat')!=null){document.getElementById('pc').onclick='';}
	document.getElementById('nh').onclick='';
	document.getElementById('tvh').onclick='';
	document.getElementById('sbh').onclick='';
	document.getElementById('eph').onclick='';
	if(document.getElementById(id).style.visibility=='visible'){return;}
	else{time=setInterval("showSide('"+id+"','"+head+"')",1);}
}
function showSide(id,head){
	started="yes";
	final_height=360;
	if(sheight>=final_height || sbounce=="up" || sbounce=="down" || sbounce=="done"){
		if(sbounce=="no"){sheight=final_height;sbounce="up";}
		if(sbounce=="up"){
			sheight-=10;
			document.getElementById(id).style.height = sheight + 'px';
			if(sheight==(final_height-40)){sbounce="down";}
		}
		else if(sbounce=="down"){
			sheight+=5;
			document.getElementById(id).style.height = sheight + 'px';
			if(sheight>=final_height){sbounce="done";}
		}
		else if(sbounce=="done"){
			sheight=0;
			oheights="do";
			started="no";
			sbounce="no";
			if(document.getElementById('matching')!=null){document.getElementById('mu').onclick=function(){delayMenus('matching','mu');};}
			if(document.getElementById('product_cat')!=null){document.getElementById('pc').onclick=function(){delayMenus('product_cat','pc');};}
			document.getElementById('nh').onclick=function(){delayMenus('navigate','nh');};
			document.getElementById('tvh').onclick=function(){delayMenus('top_view','tvh');};
			document.getElementById('sbh').onclick=function(){delayMenus('side_quote','sbh');};
			document.getElementById('eph').onclick=function(){delayMenus('side_ep','eph');};
			clearInterval(time);
			return;
		}
	}
	else{
		if(oheights=="do"){
		if(document.getElementById('matching')!=null){document.getElementById('matching').style.visibility='hidden';document.getElementById('matching').style.height='0.1em';}
		if(document.getElementById('product_cat')!=null){document.getElementById('product_cat').style.visibility='hidden';document.getElementById('product_cat').style.height='0.1em';}
		document.getElementById('navigate').style.visibility='hidden';document.getElementById('navigate').style.height='0.1em';
		document.getElementById('top_view').style.visibility='hidden';document.getElementById('top_view').style.height='0.1em';
		document.getElementById('side_quote').style.visibility='hidden';document.getElementById('side_quote').style.height='0.1em';
		document.getElementById('side_ep').style.visibility='hidden';document.getElementById('side_ep').style.height='0.1em';
		oheights="done";}
		if(sheight==200){document.getElementById(id).style.visibility='visible';}
		sheight+=50;
		document.getElementById(id).style.height = sheight + 'px';
	}
}
function hsBack(head){
	if(started=="no"){
	if(document.getElementById('matching')!=null){document.getElementById('mu').onclick=function(){delayMenus('matching','mu');};}
	if(document.getElementById('product_cat')!=null){document.getElementById('pc').onclick=function(){delayMenus('product_cat','pc');};}
	document.getElementById('nh').onclick=function(){delayMenus('navigate','nh');};
	document.getElementById('tvh').onclick=function(){delayMenus('top_view','tvh');};
	document.getElementById('sbh').onclick=function(){delayMenus('side_quote','sbh');};
	document.getElementById('eph').onclick=function(){delayMenus('side_ep','eph');};
	}
	document.getElementById(head).style.borderLeft='2px solid #000';
}
var xmlHttp;var nocache=0;var fav_form='';var cart_form='';var scrollLocation=0;var oldScrollLocation=0;var hoveredSuggestion="";var newSuggestion="search-";var elementId="";var box_id="";var innerElementPrefix="search-";
function GetXmlHttpObject(){
var xmlHttp=null;
try{xmlHttp=new XMLHttpRequest();}
catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;
}
function showResult(str,event,search_box,boxId){
elementId=search_box;
box_id=boxId;
if(str.length==0){
if(document.getElementById('livesearch')!=null && document.getElementById('livesearch').style.visibility=='visible'){
document.getElementById('livesearch').style.visibility='hidden';
document.getElementById('livesearch').innerHTML='';
if(typeof document.forms['order_by']!="undefined"){document.getElementById('hide_order_by').style.visibility='visible';}
}
else if(document.getElementById('livesearch_admin')!=null && document.getElementById('livesearch_admin').style.visibility=='visible'){
document.getElementById('livesearch_admin').style.visibility='hidden';
document.getElementById('livesearch_admin').innerHTML='';
}
else if(document.getElementById('livesearch_matching')!=null && document.getElementById('livesearch_matching').style.visibility=='visible'){
document.getElementById('livesearch_matching').style.visibility='hidden';
document.getElementById('livesearch_matching').innerHTML='';
}return}
else if((event.keyCode==40 || event.keyCode==38) && elementId!='livesearch_admin' && elementId!='livesearch_matching'){
checkForScroll(event, elementId, innerElementPrefix);}
else if(event.keyCode!=37 && event.keyCode!=39){
hoveredSuggestion=str;
document.getElementById(box_id).setAttribute("autocomplete","off");
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null){
alert ("Browser does not support HTTP Request");
return}
var url="/"+elementId+".php";
url=url+"?q="+str;
url=url+"&box="+box_id;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
scrollLocation=0;
oldScrollLocation=0;}}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById(elementId).style.visibility='visible';
document.getElementById(elementId).innerHTML=xmlHttp.responseText;
if(typeof document.forms['order_by']!="undefined"){document.getElementById('hide_order_by').style.visibility='hidden';}}}
function checkForScroll(event, elementId, innerElementPrefix){
var el=document.getElementById(elementId);
if(!el){return;}
if(event.keyCode==40){
if(document.getElementById(innerElementPrefix+(scrollLocation+1))!=null){
oldScrollLocation=scrollLocation;
scrollLocation=scrollLocation+1;
if(document.getElementById(innerElementPrefix+(oldScrollLocation))!=null){
document.getElementById(innerElementPrefix+(oldScrollLocation)).className='';}
document.getElementById(innerElementPrefix+(scrollLocation)).className='hovered';
document.getElementById(box_id).value=document.getElementById(innerElementPrefix+(scrollLocation)).innerHTML;}}
else if(event.keyCode==38 && (scrollLocation-1)==0){
document.getElementById(box_id).value=hoveredSuggestion;
document.getElementById(innerElementPrefix+(scrollLocation)).className='';} 
else if(event.keyCode==38){
if(document.getElementById(innerElementPrefix+(scrollLocation-1))!=null){
oldScrollLocation=scrollLocation;
scrollLocation=scrollLocation-1;
if(document.getElementById(innerElementPrefix+(oldScrollLocation))!=null){
document.getElementById(innerElementPrefix+(oldScrollLocation)).className='';}
document.getElementById(innerElementPrefix+(scrollLocation)).className='hovered';
document.getElementById(box_id).value=document.getElementById(innerElementPrefix+(scrollLocation)).innerHTML;}}}
function insert(prod_no,form_number){
fav_form=form_number;
xmlHttp=GetXmlHttpObject()
nocache=Math.random();
xmlHttp.open('get', '/products/insert_fav.php?prod_no='+prod_no+'&nocache='+nocache);
xmlHttp.onreadystatechange=insertReply;
xmlHttp.send(null);}
function insertReply(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
document.getElementById(fav_form).innerHTML=xmlHttp.responseText;}}
function insertCart(id,form_number){
cart_form=form_number;
xmlHttp=GetXmlHttpObject()
nocache=Math.random();
xmlHttp.open('get', '/products/insert_cart.php?id='+id+'&nocache='+nocache);
xmlHttp.onreadystatechange=insertCartReply;
xmlHttp.send(null);}
function insertCartReply(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
document.getElementById(cart_form).innerHTML=xmlHttp.responseText;
getCartInfo('single');}}
u_qtyoq=0;
u_qtylogo=0;
new_height=0;
function setCartInfo(oq,logo){
u_qtyoq=oq;
u_qtylogo=logo;}
function getCartInfo(type){
if(type='single'){u_qtyoq++;}
document.getElementById('qtyoq').innerHTML=u_qtyoq;
document.getElementById('qtylogo').innerHTML=u_qtylogo;
if(document.getElementById('cart_info').style.display=='none'){document.getElementById('cart_info').style.display='block';}}
//remove from favourites
function removeFav(id){
xmlHttp=GetXmlHttpObject()
// Set the random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
xmlHttp.open('get', '/products/remove_fav.php?id='+id+'&nocache='+nocache);
xmlHttp.send(null);}

//Product Finder
var nocache=0;
var forms;
var style;
style="all";
var fabric;
fabric="all";
function u_update(element,cat,page,form){
	document.getElementById('u_colour').disabled=true;
	document.getElementById('u_style').disabled=true;
	document.getElementById('filter_fabric').disabled=true;
	document.getElementById('submit_button').disabled=true;
	forms=form;
	if(page=="update_finder_2"){
		style = element.value;
	}//if
	if(page=="update_finder_3"){
		fabric = element.value;
	}//if
	xmlHttp=GetXmlHttpObject();
	nocache=Math.random();
	xmlHttp.open('get', '/products/update_finder.php?element='+element.value+'&cat='+cat+'&style='+style+'&page='+page+'&fabric='+fabric+'&nocache='+nocache);
	xmlHttp.onreadystatechange=insertReplys;
	xmlHttp.send(null);
}//function

function insertReplys(){
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById(forms).innerHTML=xmlHttp.responseText;
	}//if
	window.setTimeout("en()",1000);
}//function

function en(){
	document.getElementById('u_colour').disabled=false;
	document.getElementById('u_style').disabled=false;
	document.getElementById('filter_fabric').disabled=false;
	document.getElementById('submit_button').disabled=false;
}//function

//reflection.js v2.0 Freely distributable under MIT-style license.
if(!document.myGetElementsByClassName){
document.myGetElementsByClassName=function(className){
var children=document.getElementsByTagName('*') || document.all;
var elements=new Array();
for(var i=0; i<children.length; i++){
var child=children[i];
var classNames=child.className.split(' ');
for(var j=0; j<classNames.length; j++){
if(classNames[j]==className){
elements.push(child);
break;
}}}
return elements;
}}
var Reflection={
defaultHeight:0.15,
defaultOpacity:0.35,
add: function(image,options){
Reflection.remove(image);
doptions={"height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity}
if(options){
for(var i in doptions){
if(!options[i]){
options[i]=doptions[i];
}}}
else{
options=doptions;
}
try{
var d=document.createElement('div');
var p=image;
var classes=p.className.split(' ');
var newClasses='';
for(j=0;j<classes.length;j++){
if(classes[j]!="reflect"){
if(newClasses){
newClasses+=' '
}
newClasses+=classes[j];
}}
var reflectionHeight=Math.floor(p.height*options['height']);
var divHeight=Math.floor(p.height*(1+options['height']));
var reflectionWidth=p.width;
if((navigator.appVersion.indexOf("MSIE 7.")!=-1) ||(navigator.appVersion.indexOf("MSIE 8.")!=-1)){
if(p.parentElement.tagName=='A'){
var d=document.createElement('a');
d.href=p.parentElement.href;}
d.className=newClasses;
p.className='reflected';
d.style.cssText=p.style.cssText;
p.style.cssText='vertical-align: bottom';
var rfl=document.createElement('img');
rfl.src=p.src;
rfl.style.display='block';
rfl.style.width=reflectionWidth+'px';
rfl.style.margin='0px auto';
rfl.style.height=p.height+"px";
rfl.style.marginBottom='-'+(p.height-reflectionHeight+20)+'px';
rfl.style.filter='flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
d.style.width=reflectionWidth+'px';
d.style.height=divHeight+'px';
d.style.margin='0px auto';
p.parentNode.replaceChild(d,p);
d.appendChild(p);
d.appendChild(rfl);
}
else{
var canvas=document.createElement('canvas');
if(canvas.getContext){
d.className=newClasses;
p.className='reflected';
d.style.cssText=p.style.cssText;
p.style.cssText='vertical-align: bottom';
var context=canvas.getContext("2d");
canvas.style.height=reflectionHeight+'px';
canvas.style.width=reflectionWidth+'px';
canvas.height=reflectionHeight;
canvas.width=reflectionWidth;
d.style.width=reflectionWidth+'px';
d.style.height=divHeight+'px';
d.style.margin='0px auto';
d.style.marginBottom='-'+reflectionHeight+'px';
p.parentNode.replaceChild(d,p);
d.appendChild(p);
d.appendChild(canvas);
context.save();
context.translate(0,image.height-1);
context.scale(1,-1);
context.drawImage(image,0,0,reflectionWidth,image.height);
context.restore();
context.globalCompositeOperation="destination-out";
var gradient=context.createLinearGradient(0,0,0,reflectionHeight);
gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
context.fillStyle=gradient;
context.rect(0,0,reflectionWidth,reflectionHeight*2);
context.fill();
}}} 
catch(e){}},
remove : function(image){
if(image.className=="reflected"){
image.className=image.parentNode.className;
image.parentNode.parentNode.replaceChild(image,image.parentNode);
}}}
function addReflections(){
var rimages=document.myGetElementsByClassName('reflect');
for(i=0;i<rimages.length;i++){
var rheight=null;
var ropacity=null;
var classes=rimages[i].className.split(' ');
for(j=0;j<classes.length;j++){
if(classes[j].indexOf("rheight")==0){
var rheight=classes[j].substring(7)/100;
}
else if(classes[j].indexOf("ropacity")==0){
var ropacity=classes[j].substring(8)/100;
}}
Reflection.add(rimages[i],{ height: rheight, opacity : ropacity});
}}
var previousOnload=window.onload;
window.onload=function(){ if(previousOnload) previousOnload(); addReflections(); }