/*----------------------------*/
// Create the tooltips only on document load
$(document).ready(function() 
{
   // By suppling no content attribute, the library uses each elements title attribute by default
   $('.call').qtip({
      content: {
         text: false // Use each elements title attribute
      },
      style: 'dark', // Give it some style
	  position: {
      corner: {
         target: 'rightBottom',
         tooltip: 'rightTop'
      }
   }

	

   });
   
   $('.guarantee').each(function(){
   		$(this).qtip({
         content: '<img src="/_images/generic/guarantee-ticks.jpg">', // Use the tooltip attribute of the element for the content
         style: 'dark', // Give it some style
		 position: {
			corner: {
				target: 'lefttop',
				tooltip: 'leftbottom'
			}
   		},
		style: { 
		  padding: 5,
		  background: '#ffffff',
		  color: 'black',
		  textAlign: 'center',
		  border: {
			 width: 1,
			 color: '#cccccc'
		  },
		  name: 'light' // Inherit the rest of the attributes from the preset dark style
	   }

      });
   })
   
   $('#accessories tr[previewimage]').each(function()
   {
      $(this).qtip({
         content: '<img src="/_images/products/' + $(this).attr('previewimage') + '.jpg">', // Use the tooltip attribute of the element for the content
         style: 'dark', // Give it some style
		 position: {
			corner: {
				target: 'lefttBottom',
				tooltip: 'lefttop'
			}
   		}
      });
	  
	  	$(this).click(function (e) { 
		  //alert(e.pageX - $(this).offset().left)
		  if ((e.pageX - $(this).offset().left) < 671) {
		  	window.location.href = '/default.asp?t=' + ($(this).attr('producttype')) + '&s=' + ($(this).attr('productsubtype')) + '&pid=' + ($(this).attr('previewimage')); 
		  }
		});
		
		$(this).hover(function () { 
		  $('body').css('cursor', 'pointer'); 
		},function () { 
		  $('body').css('cursor', 'default'); 
		});
   });

   $('.slideshow').cycle({
		fx: 'zoom', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		sync:  false,
		timeout:   10000,
		random:    1,
		startingSlide:   Math.floor(Math.random()*4)
	});

   // NOTE: You can even omit all options and simply replace the regular title tooltips like so:
   // $('#content a[href]').qtip();
});

function closeAddItemWin(){
	addItemWin.hide()
}
var addItemWin
function newWin2(url){
	addItemWin=dhtmlwindow.open("addItemBox", "iframe", url, "Add Item to Trolley", "width=590px,height=350px,left=100px;,top=200px;resize=0,scrolling=0,center=0")

	addItemWin.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
	return true
	//window.confirm("Close window 1?")
	}
}

function newWin(url)
	{
		window.open(url,"addtobasket","menubar=no,location=no,status=no,scrollbars=no,resizable=no,toolbar=no,width=500,height=210");
	}
	function zoomWin(type, id)
	{
		window.open('/zoom.asp?type=' + type +'&id=' + id + '',"blank","menubar=no,location=no,status=no,scrollbars=yes,resizable=auto,toolbar=no,width=550,height=500");
	}



var rightclickmessage="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(rightclickmessage);return false")




function addToBookmarks(url,who){
	var ver = navigator.appName
	var num = parseInt(navigator.appVersion)
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
	   window.external.AddFavorite(url,who);
	}else{
	   alert('Press Ctrl+D to add this page as a Bookmark');
	} 

}

/*----------------------------*/

document.write('<div id="wait" style="position:absolute;top:0;left:0;width:100%;z-index:50;display:none;"><div id="wait-mask" class="wait-mask"></div><div style="background:transparent;position:absolute;z-index:6;" id="wait-message"><div style="position:absolute;z-index:55;top:27px;left:27px;"><a href="javascript:hidePopup();"><img src="/_images/displayviewer/close.gif" border="0"></a></div><div class="popup-shadow"><div><div class="popup"><div class="popup-message"><iframe id="popupframe" name="popupframe" width="900" height="600px" frameborder="0" src="/blank.asp" scrolling="no"></iframe></div></div></div></div></div></div>')

if (document.getElementById && document.createTextNode) {
   var forms=document.getElementsByTagName('form');
   for (var i=0;i<forms.length;i++)
   {
   	forms[i].onsubmit = function(){pleaseWait();return true;}
   }
}

function getWindowWidth() {
	// Default to screen dimensions.
	var winW = window.screen.width;
	// Attempt to retrieve browser window dimensions.
	if (window.innerWidth)
	winW = window.innerWidth;
	else {
		if(document.documentElement.offsetWidth)
		winW = document.documentElement.offsetWidth;
		else if (document.body.offsetWidth)
		winW = document.body.offsetWidth;
	}
	return winW;
}

function showPopup(query) {

	
	// scroll position
	
	var  scrollY;
	if (document.all) {
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop; 
	}
	else {
		scrollY = window.pageYOffset; 
	}
	
	// Default to screen dimensions.
	var winH = window.screen.height;
	// Attempt to retrieve browser window dimensions.
	
	if (window.innerHeight)
		winH = window.innerHeight;
	else {
		if(document.documentElement.offsetHeight)
			winH = document.documentElement.offsetHeight;
		else if (document.body.offsetHeight)
			winH = document.body.offsetHeight }
	
	var wait = document.getElementById('wait');
	var message = document.getElementById('wait-message');
	message.style.left = ((getWindowWidth()-995)/2)+'px';
	message.style.top = (scrollY+(winH/2)-340)+'px';
	
	// hide all selects for IE
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'hidden';
	}
	
	// add flash animation - this is now done in page loading. See pleaseWait.jsp
	
//	var so = new SWFObject("flash/loader.swf", "waitflash", "340", "36", "6", "#FFF");
//	so.write("wait-flash");
	
		//set bg to height of document
	document.getElementById('wait-mask').style.height = document.body.offsetHeight + 'px';

	// make visible
	wait.style.display = '';
	
	document.getElementById('popupframe').src = '/displayviewer.asp?' + query
	
	
}

function hidePopup() {
	var wait = document.getElementById('wait');
	var message = document.getElementById('wait-message');
	
	// show all selects for IE
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'visible';
	}
	
	//if (Cart == 'True'){
	//	OnGetCart();
	//}
	//OnGetContent('smallcart','smallcart')
	// make visible
	wait.style.display = 'none';
}

function tableruler()
{
 if (document.getElementById && document.createTextNode)
  {
   var tables=document.getElementsByTagName('table');
   for (var i=0;i<tables.length;i++)
   {
    if(tables[i].className=='producttable')
    {
     var trs=tables[i].getElementsByTagName('tr');
     for(var j=0;j<trs.length;j++)
     {
      if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT')
       {
       trs[j].onmouseover=function(){this.className='ruled';return false}
	   if (j%2==0){ 
			trs[j].className = 'ruleda'; 
			trs[j].onmouseout=function(){this.className='ruleda';return false}
		} else { 
			trs[j].className = 'ruledb';
			trs[j].onmouseout=function(){this.className='ruledb';return false}
		}
     }
    }
   }
  }
 }
}

	//var flashvars = {};
	 //flashvars.headertext = "WELCOME...";
	
	//var params = {};
	//params.play = "true";
	//params.menu = "false";
	//params.quality = "high";
	//params.scale = "noscale";
	//params.wmode = "transparent";
	//params.bgcolor = "#ffffff";
	//params.swliveconnect = "true";
	//var attributes = {};
	//attributes.id = "browser";
	//swfobject.embedSWF("/browser.swf", "browser", "940", "142", "7.0.0", "expressInstall.swf", flashvars, params, attributes);
	
	function showPortfolio() {

	
	// scroll position
	
	var  scrollY;
	if (document.all) {
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop; 
	}
	else {
		scrollY = window.pageYOffset; 
	}
	
	// Default to screen dimensions.
	var winH = window.screen.height;
	// Attempt to retrieve browser window dimensions.
	
	if (window.innerHeight)
		winH = window.innerHeight;
	else {
		if(document.documentElement.offsetHeight)
			winH = document.documentElement.offsetHeight;
		else if (document.body.offsetHeight)
			winH = document.body.offsetHeight }
	
	var wait = document.getElementById('wait');
	var message = document.getElementById('wait-message');
	message.style.left = ((getWindowWidth()-995)/2)+'px';
	message.style.top = (scrollY+(winH/2)-340)+'px';
	
	// hide all selects for IE
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'hidden';
	}
	
	// add flash animation - this is now done in page loading. See pleaseWait.jsp
	
//	var so = new SWFObject("flash/loader.swf", "waitflash", "340", "36", "6", "#FFF");
//	so.write("wait-flash");
	
		//set bg to height of document
	document.getElementById('wait-mask').style.height = document.body.offsetHeight + 'px';

	// make visible
	wait.style.display = '';
	
	document.getElementById('popupframe').src = '/portfolio.asp'
	//test3
	 
	
}