/*START: Google Analytics*/
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
	var pageTracker = _gat._getTracker("UA-6394846-3");
	pageTracker._trackPageview();
} catch(err) {}
/*END: Google Analytics*/

var PO=[];

var console = (console) ? console : {log:function(a) {;}};
jQuery.fn.truncate_cookietrail = function(options) {
		var max_len = (options.max_length) ? options.max_length : 100;
		var text = $(this).text().replace(/\n/gi,"").replace(/\t/gi," ");
		while (text.indexOf("  ")>-1) { text = text.replace(/  /gi," "); };
		//var text = $(this).text();
		if (text.length>max_len) {
			var html = $(this).html().replace(/\n/gi,"").replace(/\t/gi," ");
			while (html.indexOf("  ")>-1) { html = html.replace(/  /gi," "); };
			//var html = $(this).html();
			html = html.split(" ");
			text = $(this).text().replace(/\t/gi,"").replace(/\n/gi," ");
			while (text.indexOf("  ")>-1) { text = text.replace(/  /gi," "); };
			//text = $(this).text();
			text = text.split(" ");
			while (text.join(" ").length>max_len) {
				text.pop();
				html.pop();
			}
			$(this).html(html.join(" ")+" ...");
		}
	};

jQuery(function() {
	var counter = 0, max = 2000;
	if ($.browser.msie && $.browser.version < 8) {
		$(".Index #IndexTree").children("ul").each(function() {
			$(this).css({"z-index":max-counter});
			counter++;
		});
		$("#Content").css({"z-index":1});
		$("#Footer").css({"z-index":0});
		//$("body").css({"overflow-x":null});
	}
	$("#RightHeader h2").truncate_cookietrail({max_length:120});
});

function open_po_v1() {
//	alert('The Purchase order screen is under development.');
	try {
		var height=768;
		var width=1024;

		try {
			if (screen.availHeight) {
				height=(screen.height) 
					? (screen.availHeight-33) //if IE
					: screen.availHeight; //if not IE
			} else { height=600; }
			if (screen.availWidth) {
				width=(screen.width)
					? (screen.availWidth-33) //if IE
					: screen.availWidth; //if not IE
			} else { width=800; }
		} 
		catch(e) { 
//			alert('1 '+e); 
		}

		var uid='PO_'+Math.random();
		uid=uid.replace('.','');
		var properties=[
			'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,height=' //fullscreen,
			,height
			,',width='
			,width
		].join('');
//		PO.push(window.open('/customer/purchaseorder/default.aspx', uid, properties));
//		window.open('https://www.qualitymarine.com/customer/purchaseorder/default.aspx', uid, properties);
		window.open('http://www.qualitymarine.com/po/index.asp', uid, properties);
	}
	catch(e) {
		alert(e);
	}
}
function open_po() {
//	alert('The Purchase order screen is under maintenance and will be available @ 9 AM PST');
	try {
		var height=768;
		var width=1024;

		try {
			if (screen.availHeight) {
				height=(screen.height) 
					? (screen.availHeight-33) //if IE
					: screen.availHeight; //if not IE
			} else { height=600; }
			if (screen.availWidth) {
				width=(screen.width)
					? (screen.availWidth-33) //if IE
					: screen.availWidth; //if not IE
			} else { width=800; }
		} 
		catch(e) { 
//			alert('1 '+e); 
		}

		var uid='PO_'+Math.random();
		uid=uid.replace('.','');
		var properties=[
			'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,height=' //fullscreen,
			,height
			,',width='
			,width
		].join('');
//		PO.push(window.open('/customer/purchaseorder/default.aspx', uid, properties));
//		window.open('https://staging.qualitymarine.com/customer/purchaseorder', uid, properties);
		window.open('https://www.qualitymarine.com/customer/purchaseorder', uid, properties);
//		window.open('/customer/purchaseorder/default.aspx', uid, properties);
	}
	catch(e) {
		alert(e);
	}
}
function closePOs(obj) {
	if (obj==null) obj=PO;
	for (var i=0; i<obj.length; i++) {
		if (obj[i].length>0) closePOs(obj[i]);
		obj[i]=null;
		delete obj[i];
	}
	delete obj;
	PO=null;
}
function XmlHttpObject() {
	this.xmlHttp;

	this.setXmlHttp=function() {
		/*@cc_on
		@if (@_jscript_version >= 5)
			try { this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
			catch (e) {
				try { this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
				catch (E) { this.xmlHttp = false; }
			}
		@else
		this.xmlHttp = false;
		@end @*/
		if (!this.xmlHttp && typeof XMLHttpRequest != 'undefined') {
			try { this.xmlHttp = new XMLHttpRequest(); } 
			catch (e) { this.xmlHttp = false; }
		}
	};
	
	this.handler=function() {
		try {
			UI.innerHTML=this.xmlHttp.responseText; 
		} 
		catch(e) { 
			alert('error @ XmlHttpObject.Handler\n'+e); 
		};
	};
	
	this.errHandler=function() {
		alert('error @ XmlHttpObject.errHandler()\n'+e);
	};
	
	this.enableUI=function() { ; };
	
	this.disableUI=function() { ; };
	
	this.serverErrorPrompt=function(msg) {
		try {
			var ans=confirm(msg);
			if (ans==true) {
				var newWin=window.open('blank.htm');
				newWin.document.write(this.xmlHttp.responseText);
			}
		}
		catch(e) {
			alert('error @ XmlHttpObject.serverErrorPrompt()\n'+e);
		}
	};
}
function server_error_detail_prompt(msg, detail) {
	try {
		var ans=confirm(msg+'\n\n'+'Click OK for the error detail; otherwise, CANCEL.');
		if (ans==true) {
			var newWin=window.open('blank.htm');
			newWin.document.write(detail);
		}
	}
	catch(e) {
		alert('error @ server_error_detail_prompt()\n'+e);
	}
}
function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch (e) {
			try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
			catch (E) { xmlhttp = false; }
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try { xmlhttp = new XMLHttpRequest(); } 
		catch (e) { xmlhttp = false; }
	}
	return xmlhttp;
}
function get_keycode(e) {
	try {
		if(document.all) e=window.event; // for IE
		var charCode;
		if (charCode=='' || charCode==null) try {charCode=e.which;} catch(e) {;}
		if (charCode=='' || charCode==null) try {charCode=e.keyCode;} catch(e) {;};
		if (charCode=='' || charCode==null) try {charCode=e.charCode;} catch(e) {;};
	}
	catch(e) { ; }
//	var msg=document.getElementById('MSG');
//	msg.innerHTML+=charCode;
//	Barcode.focus();
	return(charCode);
}
function GoTo(url) {
	document.location=url;
	return(false);
}

/* Previous Version of main.js*/
var previous_element_id;
var previous_element_order;
var previous_element_cls;
var previous_element_scls;
var previous_element_cat;

//load_images();

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
function load_images() {
	var cur_image;
	var nav_images=new Array(
		'static/navigation/about.gif',
		'static/navigation/about_ro.gif',
		'static/navigation/contact.gif',
		'static/navigation/contact_ro.gif',
		'static/navigation/faq.gif',
		'static/navigation/faq_ro.gif',
		'static/navigation/home.gif',
		'static/navigation/home_ro.gif',
		'static/navigation/inventory.gif',
		'static/navigation/inventory_ro.gif',
		'static/navigation/links.gif',
		'static/navigation/links_ro.gif',
		'static/navigation/news.gif',
		'static/navigation/news_ro.gif',
		'static/navigation/pending.gif',
		'static/navigation/pending_ro.gif',
		'static/navigation/pinvoice.gif',
		'static/navigation/pinvoice_ro.gif',
		'static/navigation/products.gif',
		'static/navigation/products_ro.gif',
		'static/navigation/stock.gif',
		'static/navigation/stock_ro.gif',
		'static/navigation/uinvoice.gif',
		'static/navigation/uinvoice_ro.gif',
		'static/navigation/memberNavCreateOrder.gif',
		'static/navigation/memberNavCreateOrderOn.gif',
		'static/navigation/memberNavResumeOrder.gif',
		'static/navigation/memberNavResumeOrderOn.gif',
		'static/po/buttonAdd.gif',
		'static/po/buttonDelete.gif'
	);
	for (var i in nav_images) {
		cur_image=new Image;
		cur_image.src=nav_images[i];
	}
}
function open_order_form() {
//    alert('The Purchase order screen is currently undergoing maintenance.\nThis service will be available at noon PST');
	var height;
	var width;
	if (screen.availHeight) {
		if (screen.height) { //if IE
			height=(screen.availHeight-33);
		}
		else { //if not IE
			height=screen.availHeight;
		}
	}
	else {
		height=600;
	}
	if (screen.availWidth) {
		if (screen.width) { //if IE
			width=(screen.availWidth-33);
		}
		else { //if not IE
			width=screen.availWidth;
		}
	}
	else {
		width=800;
	}
	var uid='QM';//envURL.replace(/\./g,'_');
	//var uid='_'+Math.random();
	//uid=uid.replace('.','');
	//alert(uid);
	//window.open('po/index.asp','order','toolbar=1,scrollbars=1,location=1,menubar=1,resizable=1');
	var properties='toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,height='+height+',width='+width; //fullscreen,
	window.open('/po/index.asp', 'order_'+uid, properties);
	//window.open('po/order.asp', 'order', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,'+height);
}
function open_popup(page, name, width, height) {
	window.open(page, name, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
}
function open_window(page, name, width, height) {
	window.open(page, name, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width='+width+',height='+height);
}
function open_popup_return(page, name, width, height) {
	window.open(page, name, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
	return(false);
}
function set_prev_ids(cls, scls, cat) {
	if (document.getElementById(cls)!=null)
		previous_element_cls=cls;
	if (document.getElementById(scls)!=null)
		previous_element_scls=scls;
	if (document.getElementById(cat)!=null)
		previous_element_cat=cat;
}
function show_hide(element_id) {
	var cur_display=document.getElementById(element_id);
	if(previous_element_id!=null && previous_element_id!=element_id) {
		document.getElementById(previous_element_id).style.display='none';
	}
	if (cur_display.style.display=='block') {
		cur_display.style.display='none';
	}
	else {
		cur_display.style.display='block';
	}
	previous_element_id=element_id;
}
function show_hide_cls(element_id) {
	var cur_display=document.getElementById(element_id);
	if(previous_element_cls!=null && previous_element_cls!=element_id) {
		document.getElementById(previous_element_cls).style.display='none';
	}
	if (cur_display.style.display=='block' || cur_display.style.display=='') {
		cur_display.style.display='none';
	}
	else {
		cur_display.style.display='block';
	}
	//these lines are to work w/ the products navigator to reset the category prev id
	//since previous_element_cat is unused by all other insertions of main.js, this poses no problems on other uses.
	/*if (previous_element_cls!=null) {
		document.getElementById(previous_element_cls).style.display='none';
		previous_element_cls=null; 
	}*/
	previous_element_cls=element_id;
}
function show_hide_scls(element_id) {
	var cur_display=document.getElementById(element_id);
    //alert(cur_display.id);
	if(previous_element_scls!=null && previous_element_scls!=element_id) {
		document.getElementById(previous_element_scls).style.display='none';
	}
	if (cur_display.style.display=='block' || cur_display.style.display=='') {
		cur_display.style.display='none';
	}
	else {
		cur_display.style.display='block';
	}
	previous_element_scls=element_id;
	//these lines are to work w/ the products navigator to reset the category prev id
	//since previous_element_cat is unused by all other insertions of main.js, this poses no problems on other uses.
	/*if (previous_element_scls!=null) {
		document.getElementById(previous_element_scls).style.display='none';
		previous_element_scls=null; 
	}*/
}
function show_hide_cat(element_id) {
	var prev_display=document.getElementById(previous_element_cat);
	prev_display.style.display='none';
	if (previous_element_cat!=element_id) {
		var cur_display=document.getElementById(element_id);
		if (cur_display.style.display=='block' || cur_display.style.display=='') {
			cur_display.style.display='none';
		}
		else {
			var cls=element_id.split('_')[0];
			var cat=element_id.split('_')[1];
			if (cur_display.innerHTML=='') {
				var scat='';
				//alert('//c[@ci='+cat+']/s');
				var nodes=get_nodes('//c[@ci='+cat+']/s');
				for (var i=0; i<nodes.length; i++) {
					scat+=
						'<a href="products.asp?'+
						'cls='+cls+
						'&cat='+cat+
						'&scat='+nodes[i].getAttribute('si')+
						'&pg=1"'+
						'>'+nodes[i].getAttribute('sd')+'</a><br/>';
				}
				cur_display.innerHTML=scat;
			}
			cur_display.style.display='block';
		}
	}
	previous_element_cat=element_id;
}
function initialize_navigator() {

	//mozilla hiccups w/ the length property of List returned from selectNodes method.
	var nav='';
	var cur_cls, cur_cat, cur_scat;
	var cls, cls_id, cls_desc;
	var cat, cat_id, cat_desc;
	var scat, scat_id, scat_desc;
	
	if (location.search.length>0) {
		var qs=location.search;
		var qss=location.search.split('&');
		for (var i=0; i<qss.length; i++) {
			var field=qss[i].split('=');
			if (field[0].replace('?','')=='cls') {
				cur_cls=field[1];
			}
			else if (field[0].replace('?','')=='cat') {
				cur_cat=field[1];
			}
			else if (field[0].replace('?','')=='scat') {
				cur_scat=field[1];
			}
		}
	}

	cls=get_nodes('//p');
	alert(cls.length);
	for (var i=0; i<cls.length; i++) {
		cls_id=cls[i].getAttribute('pi');
		cls_desc=cls[i].getAttribute('pd');
		nav+=
			'<span id='+cls_id+'>'+
			'<b><a class="body" href="javascript:show_hide_cls(\'cls_'+cls_id+'\');">'+
			cls_desc+
			'</a></b></span><br>'+
			'<div class="navClass" id=cls_'+cls_id+' style="display:'+((cur_cls==cls_id)?'block':'none')+';"></div>';
		/*nav+=
			'<span id='+cls_id+'>'+
			'<b><a class="body" href="javascript:show_hide_cls(\'cls_'+cls_id+'\'">'+
			cls_desc+
			'</a></b></span><br>'+
			'<div class="navClass" id=cls_'+cls_id+' style="display:'+(cur_cls==cls_id)?'block':'none'+';"></div>';*/
		/*var cat=cls[i].get_nodes('child::c');
		for (var j=0; i<cat.length; i++) {
			var cat_id=cat[i].getAttribute('ci');
			var cat_desc=cat[i].getAttribute('cd');
			nav+='<a href="products.asp?cls='+cls_id+'&cat='+cat_id+'">'+cat_desc+'</a>'
			var scat=cat[i].get_nodes('child::s');
			for (var k=0; i<scat.length; i++) {
				
			}
		}*/
	}
	/*if (location.search.length>0) {
		cat=get_nodes('//p[@pi='+cur_cls+']/c');
		for (var i=0; i<cat.length; i++) {
			cat_id=cat[i].getAttribute('ci');
			cat_desc=cat[i].getAttribute('cd');
			nav+='<a href="products.asp?cls='+cls_id+'&cat='+cat_id+'">'+cat_desc+'</a><br>'

			var cat=cls[i].get_nodes('child::c');
			for (var j=0; i<cat.length; i++) {
				var cat_id=cat[i].getAttribute('ci');
				var cat_desc=cat[i].getAttribute('cd');
				nav+='<a href="products.asp?cls='+cls_id+'&cat='+cat_id+'">'+cat_desc+'</a>'
				var scat=cat[i].get_nodes('child::s');
				for (var k=0; i<scat.length; i++) {
					
				}
			}
		}
	}*/
	document.getElementById('prod_nav').innerHTML=nav;
}
function show_cat() {
	var cls, cat, scat, pg;
	if (location.search.length>0) {
		var qs=location.search;
		var qss=location.search.split('&');
		for (var i=0; i<qss.length; i++) {
			var field=qss[i].split('=');
			if (field[0].replace('?','')=='cls') {
				cls=field[1];
			}
			else if (field[0].replace('?','')=='cat') {
				cat=field[1];
			}
			/*if (field[0]=='cls') {
				cls=field[1];
			}
			else if (field[0]=='cat') {
				cat=field[1];
			}
			else if (field[0]=='scat') {
				scat=field[1];
			}
			else if (field[0]=='pg') {
				pg=field[1];
			}*/
		}
		show_hide_cat(cls+'_'+cat);
	}
}
function show_hide_alternate(element_id) {
	var cur_display=document.getElementById(element_id);
	if (cur_display.style.display=='none') {
		cur_display.style.display='block';
	}
	else {
		cur_display.style.display='none';
	}
	previous_element_id=element_id;
}
function show_hide_stocklist() {
	var listarea=document.getElementById('stocklist');
	var stocklist=document.getElementById('stocklist');
	var specials=document.getElementById('specials');
	if (listarea.style.display=='none') {
		listarea.style.display='block';
		if (!stocklist_loaded) {
			specials.innerHTML='<div class="loadMsg">Please wait while the specials & stocklist load...</div>';
			load_xml('get_specials.asp', 'specials');
			stocklist_loaded=true;
		}
	}
	else {
		listarea.style.display='none';
	}
}
function show_hide_by_prefix(form, prefix) {
	var cur_display;
	for(var i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].id.substr(0,2)==prefix) {
			cur_display=form.elements[i].parentNode;
			if (cur_display.style.display=='block') {
				cur_display.style.display='none';
			}
			else {
				cur_display.style.display='block';
			}
		}
	}
}
function resize_overflow(previous_page) {
	/*if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}*/

	//var toolkit=java.awt.Toolkit.getDefaultToolkit(); //performance takes a hit when loading a java class.
	//var screensize=toolkit.getScreenSize();
	//alert(screensize.height);
	var previous_area;
	var auxIE=0;
	var auxMZ=0;
	//alert(previous_page);
	if (previous_page=='add_frequent' || previous_page=='add_promo') {
		previous_area=document.getElementById(previous_page+'_area');
	}
	else if (previous_page=='shipping') {
		previous_area=document.getElementById('shipping_materials');
	}
	else {
		previous_area=document.getElementById('order_'+previous_page+'_area');
	}
	
	var purOrder=document.getElementById('purOrder');
	
	if (purOrder) {
		//var shellTable=document.getElementById('shellTable');
		//shellTable.style.height="100%";
		
		//var winH = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
		//var winH = (window.innerHeight) ? window.innerHeight : screen.availHeight;
		//alert(screen.availHeight);
		//alert(winH);
		//alert(shellTable.height);
		
		if (window.innerHeight) {
			//works for mozilla; note that mozilla sizes new window in terms of innerwidth and height, whereas IE frame size.
			var winH = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
			//if (previous_area!=null) previous_area.style.height=winH-135-13;
			if (previous_area!=null) previous_area.style.height=winH-135-17-auxMZ;
			//purOrder.style.height=winH-138-17;
			//purOrder.style.height=winH-138-14-auxMZ;
			purOrder.style.height=winH-152-auxMZ;
		}
		else {
			//IE code;
			var winH = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
			if (previous_area!=null) previous_area.style.height=winH-143-auxIE;
			purOrder.style.height=winH-143-auxIE;
			//purOrder.style.height=winH-100-auxIE;
		}
	}
}
function nav_rollover(obj, norm, rover) {
	var objSrc=''+obj.src;
	//alert(objSrc);
	if (objSrc.indexOf(norm)>0) {
		obj.src='static/navigation/'+rover;
	}
	else {
		obj.src='static/navigation/'+norm;
	}
}
function returnValue(value) {
    return(value);
}

var QM={
	NewElement:{
		Div:function(Class, Text) { return(QM.NewElement.Object('div', Class, Text)); }
		,Span:function(Class, Text) { return(QM.NewElement.Object('span', Class, Text)); }
		,Center:function(Class, Text) { return(QM.NewElement.Object('center', Class, Text)); }
		,BR:function(Class, Text) { return(QM.NewElement.Object('br', Class, Text)); }
		,Textarea:function(Class, Text) { return(QM.NewElement.Object('textarea', Class, Text)); }
		,Input:function(Class, Text) { return(QM.NewElement.Object('input', Class, Text)); }
		,UL:function(Class, Text) { return(QM.NewElement.Object('ul', Class, Text)); }
		,LI:function(Class, Text) { return(QM.NewElement.Object('li', Class, Text)); }
		,A:function(Class, Text) { return(QM.NewElement.Object('a', Class, Text)); }
		,Img:function(Class, Text, Src) { return(QM.NewElement.Object('img', Class, Text, Src)); }
		,Object:function(Type, Class, Text, Src) {
		    var Element=document.createElement(Type);
		    if (Class) Element.className=Class;
		    try {
	            if (Src) Element.src=Src;
		        if (Text) 
		            if (Element.value) Element.value=Text;
		            else Element.innerHTML=Text;
		    } catch(e) { ; }
		    return(Element);
		}
	}
	,Pages:{
        Load:function() {
            if (!window.addEventListener) {
                window.attachEvent('onload',QM.Pages.Home.Load);
            }
            else {
                window.addEventListener('load',QM.Pages.Home.Load,false);
            }
        }
        ,Home:{
            Load:function() {
                QM.Pages.Home.FeaturedProducts.Animation.Initialize();
            }
            ,FeaturedProducts:{
                Products:[]
                ,Animation:{
                    Initialize:function() {
                        var load=setInterval(
                            function() {
                                try {
									if (fisheyemenu) {
										if ($$('Feature_1')) {
											for (var i=1; i<100; i++) {
												if ($$('Feature_'+i)) {
													QM.Pages.Home.FeaturedProducts.Products.push($$('Feature_'+i));
													$$('Feature_'+i).onmouseover=fisheyemenu.resetPosition;
													$$('Feature_'+i).onmouseout=fisheyemenu.resetPosition;
												}
												else
													break;
											}
											$$('Content').onmouseover=fisheyemenu.resetPosition;
											$$('Content').onmouseout=fisheyemenu.resetPosition;
											var Animation=QM.Pages.Home.FeaturedProducts.Animation;
											Animation.Navigation.Load();
											Animation.Navigation.Buttons.Play.Element.className='Pressed';
											Animation.Iterate(true);
										}
										fisheyemenu.init();
										clearInterval(load);
									}
                                }
                                catch(e) { ; }
                            }
                            ,200
                        );
                        //fisheyemenu.init();
                        /*var script=document.createElement('script');
                        //script.src="/library/fisheye-menu/fisheye-rev.js";
                        script.src="/library/fisheye-menu/fisheye.js";
                        script.type="text/javascript";
                        document.body.appendChild(script);*/
                    }
                    ,MoveIndexNext:function() {
                        var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                        var Index=Animation.Index;
                        var Products=QM.Pages.Home.FeaturedProducts.Products;
                        Index.Current=(Index.Current==null) ? Products.length-1 : (Index.Current==Products.length-1) ? 0 : Index.Current-1+2;
                        Index.Next=(Index.Next==null) ? 0 : (Index.Current==Products.length-1) ? 0 : Index.Current-1+2;
                    }
                    ,MoveIndexPrevious:function() {
                        var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                        var Index=Animation.Index;
                        var Products=QM.Pages.Home.FeaturedProducts.Products;
                        Index.Current=(Index.Current==null) ? 0 : (Index.Current==0) ? Products.length-1 : Index.Current-1;
                        Index.Next=(Index.Next==null) ? 1 : (Index.Current==Products.length-1) ? 0 : Index.Current-1+2;
                    }
                    ,Navigation:{
                        Buttons:{
                            Previous:{Element:null,Text:'Previous'}
                            ,Pause:{Element:null,Text:'Pause'}
                            ,Play:{Element:null,Text:'Play'}
                            ,Next:{Element:null,Text:'Next'}
                        }
                        ,Move:{Active:false,Interval:null}
                        ,Load:function() {
                            var Products=QM.Pages.Home.FeaturedProducts;
                            var Navigation=QM.Pages.Home.FeaturedProducts.Animation.Navigation;
                            var Container=QM.NewElement.Div('Navigation',null);
                            var Features=$$('Features');
							Container.id='fisheye_menu';
                            for (var i in Navigation.Buttons) {
                                Navigation.Buttons[i].Element=QM.NewElement.A(null, Navigation.Buttons[i].Text);
								Navigation.Buttons[i].Element.id=i;
                                Navigation.Buttons[i].Element.onclick=function () { QM.Pages.Home.FeaturedProducts.Animation.Navigation[this.id](); };
                                Container.appendChild(Navigation.Buttons[i].Element);
                            }
                            for (var i=0; i<Products.Products.length; i++) {
                                Navigation.Buttons[i]={Element:null};
                                //Navigation.Buttons[i].Element=QM.NewElement.A(null, i+1);
								var img=Products.Products[i].getElementsByTagName('img')[0];
								Navigation.Buttons[i].Element=QM.NewElement.Img(null, i+1, img.src);
								//Navigation.Buttons[i].Element.style.width='52px';
                                Navigation.Buttons[i].Element.id=i;
                                Navigation.Buttons[i].Element.onclick=function () { QM.Pages.Home.FeaturedProducts.Animation.Navigation.Navigate(this); };
                                Container.appendChild(Navigation.Buttons[i].Element);
                            }
							var ShiftLeft=QM.NewElement.Div('ShiftLeft',null);
							var ShiftRight=QM.NewElement.Div('ShiftRight',null);
							ShiftLeft.onmousedown=MoveLeft;
							ShiftRight.onmousedown=MoveRight;
							ShiftLeft.onmouseup=StopMove;
							ShiftRight.onmouseup=StopMove;
                            function MoveLeft() {
                                var Navigation=QM.Pages.Home.FeaturedProducts.Animation.Navigation;
                                Navigation.Move.Active=true;
                                Navigation.Move.Interval=setInterval(
                                    function() {
                                        var Left=Container.style.left.replace('px','')-1+1;
                                        if (Navigation.Move.Active && Left<0) {
                                            Container.style.left=(Left+3)+'px';
                                        }
                                        else {
                                            clearInterval(Navigation.Move.Interval);
                                        }
                                    }
                                    ,30
                                );
                            }
                            function StopMove() {
                                var Navigation=QM.Pages.Home.FeaturedProducts.Animation.Navigation;
                                Navigation.Move.Active=false;
                            }
                            function MoveRight() {
                                var Navigation=QM.Pages.Home.FeaturedProducts.Animation.Navigation;
                                Navigation.Move.Active=true;
                                Navigation.Move.Interval=setInterval(
                                    function() {
                                        var Left=Container.style.left.replace('px','')-1+1;
                                        var Products=QM.Pages.Home.FeaturedProducts.Products;
                                        var Width=Products.length*(fisheyemenu.startSize.w+1)+1;
                                        var ContainerWidth=$$('Features').offsetWidth;
                                        if (Navigation.Move.Active && Width>ContainerWidth) {
                                            Container.style.left=(Left-3)+'px';
                                        }
                                        else {
                                            clearInterval(Navigation.Move.Interval);
                                        }
                                    }
                                    ,30
                                );
                            }
							var NavContainer=QM.NewElement.Div('NavContainer',null);
							NavContainer.appendChild(Container);
							Features.insertBefore(ShiftLeft,Features.firstChild);
                            Features.insertBefore(NavContainer,Features.firstChild);
							Features.insertBefore(ShiftRight,Features.firstChild);
                        }
                        ,Navigate:function(Element) {
                            var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                            var Products=QM.Pages.Home.FeaturedProducts.Products;
                            for (var i=0; i<Products.length; i++) {
                                $$(i).className='Unpressed';
                                QM.Document.Animation.Fade.ChangeOpacity(0,Products[i]);
                            }
                            clearTimeout(Animation.Thread);
                            Animation.Index.Current=Element.id;
                            Animation.MoveIndexPrevious();
                            Animation.MoveIndexPrevious();
                            Animation.IsPaused=false;
                            Products[Animation.Index.Current].style.zIndex=-10; 
                            Products[Animation.Index.Current].getElementsByTagName('img')[0].style.zIndex=-10;
                            Products[Animation.Index.Current].getElementsByTagName('a')[0].style.zIndex=-10;
                            Products[Animation.Index.Current].getElementsByTagName('a')[1].style.zIndex=-10;
                            Products[Animation.Index.Next].style.zIndex=1000; 
                            Products[Animation.Index.Next].getElementsByTagName('img')[0].style.zIndex=1000;
                            Products[Animation.Index.Next].getElementsByTagName('a')[0].style.zIndex=1000;
                            Products[Animation.Index.Next].getElementsByTagName('a')[1].style.zIndex=1000;
                            //Products[Animation.Index.Next].getElementsByTagName('div')[0].style.display='inline';
                            Animation.Iterate(true);
                            //Animation.IsPaused=true;
                            //Element.className='Pressed';
                            //Animation.Navigation.Buttons.Play.Element.className='Unpressed';
                            //Animation.Navigation.Buttons.Pause.Element.className='Pressed';
                            Animation.Navigation.Buttons.Play.Element.className='Pressed';
                        }
                        ,Next:function(Element) {
                            var Products=QM.Pages.Home.FeaturedProducts;
                            var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                            Animation.MoveIndexNext();
                            Animation.MoveIndexNext();
                            Animation.Navigation.Navigate($$(Animation.Index.Current));
                        }
                        ,Previous:function() {
                            var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                            Animation.MoveIndexPrevious();
                            Animation.MoveIndexPrevious();
                            Animation.MoveIndexPrevious();
                            Animation.MoveIndexPrevious();
                            Animation.Navigation.Navigate($$(Animation.Index.Current));
                        }
                        ,Pause:function() {
                            var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                            Animation.IsPaused=true;
                            Animation.Navigation.Buttons.Play.Element.className='Unpressed';
                            Animation.Navigation.Buttons.Pause.Element.className='Pressed';
                            clearTimeout(Animation.Thread);
                        }
                        ,Play:function() {
                            var Products=QM.Pages.Home.FeaturedProducts.Products;
                            var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                            for (var i=0; i<Products.length; i++) {
                                $$(i).className='Unpressed';
                                QM.Document.Animation.Fade.ChangeOpacity(0,Products[i]);
                            }
                            clearTimeout(Animation.Thread);
                            Animation.IsPaused=false;
                            //Animation.MoveIndexNext();
                            Animation.MoveIndexPrevious();
                            QM.Document.Animation.Fade.ChangeOpacity(0,Products[Animation.Index.Current]);
                            QM.Document.Animation.Fade.ChangeOpacity(0,Products[Animation.Index.Next]);
                            Animation.Navigation.Buttons.Pause.Element.className='Unpressed';
                            Animation.Navigation.Buttons.Play.Element.className='Pressed';
                            Animation.Iterate(true);
                        }
                    }
                    ,Thread:null
                    ,IsPaused:false
                    ,Iterate:function(isInitial, skipLoop) {
                        var Animation=QM.Pages.Home.FeaturedProducts.Animation;
                        var Index=Animation.Index;
                        var Products=QM.Pages.Home.FeaturedProducts.Products;
                        if (!Animation.IsPaused) {
                            Animation.MoveIndexNext();
                            Animation.Thread=setTimeout(
                                function() {
                                    if ($$(Index.Current)!=null) $$(Index.Current).className='Unpressed';
                                    if ($$(Index.Next)!=null) $$(Index.Next).className='Pressed';
                                    Products[Index.Current].style.display='inline';
                                    Products[Index.Next].style.display='inline';
                                    QM.Document.Animation.Fade.Blend(
                                        {Element:Products[Index.Current],FadeIndex:(isInitial) ? 0 : 100}
                                        ,{Element:Products[Index.Next],FadeIndex:0}
                                        ,Animation.Interval
                                        ,function() { 
                                            if (!skipLoop) {
                                                Products[Index.Current].style.zIndex=-10; 
                                                Products[Index.Current].getElementsByTagName('img')[0].style.zIndex=-10;
                                                Products[Index.Current].getElementsByTagName('a')[0].style.zIndex=-10;
                                                Products[Index.Current].getElementsByTagName('a')[1].style.zIndex=-10;
                                                Products[Index.Next].style.zIndex=1000; 
                                                Products[Index.Next].getElementsByTagName('img')[0].style.zIndex=1000;
                                                Products[Index.Next].getElementsByTagName('a')[0].style.zIndex=1000;
                                                Products[Index.Next].getElementsByTagName('a')[1].style.zIndex=1000;
                                                //Products[Index.Next].getElementsByTagName('div')[0].style.display='inline';
                                                Animation.Iterate(false); 
                                            }
                                        }
                                    );
                                }
                                ,(isInitial) ? 0 : Animation.Wait
                            );
                        }
                    }
                    ,Index:{Current:null,Next:null}
                    ,Wait:7000
                    ,Interval:25
                }
            }
        }
    }
    ,Document:{
        Animation:{
            Fade:{
                MaxOpacity:100
                ,CurrentThread:null
                ,ChangeOpacity:function(Opacity, Element) { 
                    var object = Element.style; 
                    if (Opacity==100 && document.all) {
                        object.opacity = '';
                        object.MozOpacity = '';
                        object.KhtmlOpacity = '';
                        object.filter = '';
                    }
                    else if (Opacity<=100) {
                        object.opacity = (Opacity / QM.Document.Animation.Fade.MaxOpacity); 
                        object.MozOpacity = (Opacity / QM.Document.Animation.Fade.MaxOpacity); 
                        object.KhtmlOpacity = (Opacity / QM.Document.Animation.Fade.MaxOpacity); 
                        object.filter = "alpha(opacity=" + Opacity + ")"; 
                    }
                }
                ,Blend:function(bottom, top, interval, onComplete) { 
                    if (top.FadeIndex<=QM.Document.Animation.Fade.MaxOpacity) {
                        QM.Document.Animation.Fade.ChangeOpacity(top.FadeIndex,top.Element)
                        QM.Document.Animation.Fade.ChangeOpacity(bottom.FadeIndex,bottom.Element)
                        top.FadeIndex=top.FadeIndex+10;
                        bottom.FadeIndex=bottom.FadeIndex-10;
                        if (QM.Document.Animation.Fade.CurrentThread) {
							clearTimeout(QM.Document.Animation.Fade.CurrentThread);
                        }
                        QM.Document.Animation.Fade.CurrentThread=setTimeout(
                            function() { QM.Document.Animation.Fade.Blend(bottom, top, interval, onComplete); }
                            ,interval
                        );
                    }
                    else {
                        onComplete();
                    }
                }
            }
        }
    }
};

QM.Pages.Load();

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var DetectFlash=function () {
	var requiredMajorVersion = 10;
	var requiredMinorVersion = 0;
	var requiredRevision = 2;

	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);	
	if(!hasRightVersion) {
		// flash is too old or we can't detect the plugin
		var alternateContent = '<div class="FlashMsg">This content requires the Adobe Flash Player 10.<br/>'
			+ '<a href="http://www.adobe.com/go/getflashplayer/">Get Flash</a></div>';
		var movies = $("object");
		for (var i=0; i<movies.length; i++) {
			var parent = movies[i].parentNode;
			var alternate = document.createElement("div");
			parent.removeChild(movies[i]);
			parent.insertBefore(alternate,parent.firstChild);
			alternate.innerHTML = alternateContent;
		}
	}

	function ControlVersion()
	{
		var version;
		var axo;
		var e;
		// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
		try {
			// version will be set for 7.X or greater players
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
		if (!version)
		{
			try {
				// version will be set for 6.X players only
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				
				// installed player is some revision of 6.0
				// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
				// so we have to be careful. 
				
				// default to the first public version
				version = "WIN 6,0,21,0";
				// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
				axo.AllowScriptAccess = "always";
				// safe to call for 6.0r47 or greater
				version = axo.GetVariable("$version");
			} catch (e) {
			}
		}
		if (!version)
		{
			try {
				// version will be set for 4.X or 5.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
				version = axo.GetVariable("$version");
			} catch (e) {
			}
		}
		if (!version)
		{
			try {
				// version will be set for 3.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
				version = "WIN 3,0,18,0";
			} catch (e) {
			}
		}
		if (!version)
		{
			try {
				// version will be set for 2.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				version = "WIN 2,0,0,11";
			} catch (e) {
				version = -1;
			}
		}
		
		return version;
	}
	// JavaScript helper required to detect Flash Player PlugIn version information
	function GetSwfVer(){
		// NS/Opera version >= 3 check for Flash plugin in plugin array
		var flashVer = -1;
		
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
				var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
				var descArray = flashDescription.split(" ");
				var tempArrayMajor = descArray[2].split(".");			
				var versionMajor = tempArrayMajor[0];
				var versionMinor = tempArrayMajor[1];
				var versionRevision = descArray[3];
				if (versionRevision == "") {
					versionRevision = descArray[4];
				}
				if (versionRevision[0] == "d") {
					versionRevision = versionRevision.substring(1);
				} else if (versionRevision[0] == "r") {
					versionRevision = versionRevision.substring(1);
					if (versionRevision.indexOf("d") > 0) {
						versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
					}
				}
				var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			}
		}
		// MSN/WebTV 2.6 supports Flash 4
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		// WebTV 2.5 supports Flash 3
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		// older WebTV supports Flash 2
		else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		else if ( isIE && isWin && !isOpera ) {
			flashVer = ControlVersion();
		}	
		return flashVer;
	}
	// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
	function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
	{
		versionStr = GetSwfVer();
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				// Given "WIN 2,0,0,11"
				tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
				tempString        = tempArray[1];			// "2,0,0,11"
				versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
			} else {
				versionArray      = versionStr.split(".");
			}
			var versionMajor      = versionArray[0];
			var versionMinor      = versionArray[1];
			var versionRevision   = versionArray[2];
        		// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if (versionMajor > parseFloat(reqMajorVer)) {
				return true;
			} else if (versionMajor == parseFloat(reqMajorVer)) {
				if (versionMinor > parseFloat(reqMinorVer))
					return true;
				else if (versionMinor == parseFloat(reqMinorVer)) {
					if (versionRevision >= parseFloat(reqRevision))
						return true;
				}
			}
			return false;
		}
	}
	function AC_AddExtension(src, ext)
	{
	  if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext+'?'); 
	  else
		return src + ext;
	}
	function AC_Generateobj(objAttrs, params, embedAttrs) 
	{ 
	  var str = '';
	  if (isIE && isWin && !isOpera)
	  {
		str += '<object ';
		for (var i in objAttrs)
		{
		  str += i + '="' + objAttrs[i] + '" ';
		}
		str += '>';
		for (var i in params)
		{
		  str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		}
		str += '</object>';
	  }
	  else
	  {
		str += '<embed ';
		for (var i in embedAttrs)
		{
		  str += i + '="' + embedAttrs[i] + '" ';
		}
		str += '> </embed>';
	  }
	  document.write(str);
	}
	function AC_FL_RunContent(){
	  var ret = 
		AC_GetArgs
		(  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
		 , "application/x-shockwave-flash"
		);
	  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
	function AC_SW_RunContent(){
	  var ret = 
		AC_GetArgs
		(  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
		 , null
		);
	  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
	function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
	  var ret = new Object();
	  ret.embedAttrs = new Object();
	  ret.params = new Object();
	  ret.objAttrs = new Object();
	  for (var i=0; i < args.length; i=i+2){
		var currArg = args[i].toLowerCase();    
		switch (currArg){	
		  case "classid":
			break;
		  case "pluginspage":
			ret.embedAttrs[args[i]] = args[i+1];
			break;
		  case "src":
		  case "movie":	
			args[i+1] = AC_AddExtension(args[i+1], ext);
			ret.embedAttrs["src"] = args[i+1];
			ret.params[srcParamName] = args[i+1];
			break;
		  case "onafterupdate":
		  case "onbeforeupdate":
		  case "onblur":
		  case "oncellchange":
		  case "onclick":
		  case "ondblclick":
		  case "ondrag":
		  case "ondragend":
		  case "ondragenter":
		  case "ondragleave":
		  case "ondragover":
		  case "ondrop":
		  case "onfinish":
		  case "onfocus":
		  case "onhelp":
		  case "onmousedown":
		  case "onmouseup":
		  case "onmouseover":
		  case "onmousemove":
		  case "onmouseout":
		  case "onkeypress":
		  case "onkeydown":
		  case "onkeyup":
		  case "onload":
		  case "onlosecapture":
		  case "onpropertychange":
		  case "onreadystatechange":
		  case "onrowsdelete":
		  case "onrowenter":
		  case "onrowexit":
		  case "onrowsinserted":
		  case "onstart":
		  case "onscroll":
		  case "onbeforeeditfocus":
		  case "onactivate":
		  case "onbeforedeactivate":
		  case "ondeactivate":
		  case "type":
		  case "codebase":
		  case "id":
			ret.objAttrs[args[i]] = args[i+1];
			break;
		  case "width":
		  case "height":
		  case "align":
		  case "vspace": 
		  case "hspace":
		  case "class":
		  case "title":
		  case "accesskey":
		  case "name":
		  case "tabindex":
			ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
			break;
		  default:
			ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
		}
	  }
	  ret.objAttrs["classid"] = classid;
	  if (mimeType) ret.embedAttrs["type"] = mimeType;
	  return ret;
	}
}
$(document).ready(function() {
	DetectFlash();
});