﻿    	jQuery().ready(function(){
	        if($(".iframe").length)
	        {    $(".iframe").fancybox( {
	                'width' : 500, 
	                'height': 300, 
	                'type':'iframe',
	                'modal':true
	                });
	        }
            jQuery('#content #homeContent ul').each(function () {
                $(this).wrap('<div class="listWrapper" />');
                $('.listWrapper').prepend('<div class="listWrapperTop" >&nbsp;</div>').append('<div class="listWrapperBottom" >&nbsp;</div>');
            });
            jQuery('.btn').each(function () {
                $(this).wrapInner('<span class="btnText" />');
                $(this).prepend('<span class="btnLeft" >&nbsp;</span>').append('<span class="btnRight" >&nbsp;</span>');
            });

            jQuery('.formPanel').each(function () {
                $(this).wrapInner('<div class="formPanelInner" />');
                $(this).prepend('<div class="formPanelTop" >&nbsp;</div>').append('<div class="formPanelBottom" >&nbsp;</div>');
            });
            
            jQuery('.dfProductInterest .dfControl .dfCheckboxList label').each(function () {
                $(this).append($("<span />").addClass("clear").html("&nbsp;"));
            });

            $(".closeFancyBox").click(function (){
                parent.$.fancybox.close();
            });

		    jQuery('#faq').accordion({
			    event: 'click',
			    selectedClass: 'header_highlight',
			    autoheight: false,
			    active: "#faq1-header",
			    animated: "slide",
			    header: ".accordion_headings"
		    });
    		
		    jQuery('#pnlActions').accordion({
			    event: 'mouseover',
			    selectedClass: 'actionHighlight',
			    autoheight: false,
			    active: "#faq1-header",
			    animated: "slide",
			    header: ".actionHeader"
		    });
//		      if($('#faq').length) {
//		        document.body.onclick = closeFaqCat;
		      //}
    		setupGrid();
        });

function listHover()
{}


/*--Sizing and positioning ----------------- */
function setupGrid()
{	if(document.getElementById('termsContainer')!=null && BrowserDetect.browser=="Opera") { document.getElementById('termsContainer').style.overflow = 'scroll';  }
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	 }
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	 }
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	if (y > 0) {
			if(document.getElementById('header') == null) return
			if(document.getElementById('footer') == null) return
			
			headerEl = document.getElementById('header');
			footerEl = document.getElementById('header');
			
			subHeight = y - headerEl.offsetHeight-65;

			if (BrowserDetect.browser=="Explorer" && BrowserDetect.version<7) //ie6
			{	
			    /*if(document.getElementById('navigation') != null) document.getElementById('navigation').style.height = subHeight+ 'px';*/
			    if(document.getElementById('content') != null) document.getElementById('content').style.height = subHeight + 'px'; 
			    if(document.getElementById('sidebar') != null) document.getElementById('sidebar').style.height = subHeight + 'px'; 
			    if(document.getElementById('mainPnl') != null) document.getElementById('mainPnl').style.height = subHeight - 20 + 'px'; 
                
			}
			else //ie7 & FF etc
			{	
			    /*if(document.getElementById('navigation') != null) document.getElementById('navigation').style.minHeight = subHeight + 'px';*/
			    if(document.getElementById('content') != null) document.getElementById('content').style.minHeight = subHeight + 'px'; 
			    if(document.getElementById('sidebar') != null) document.getElementById('sidebar').style.minHeight = subHeight + 'px'; 
			    if(document.getElementById('mainPnl') != null) document.getElementById('mainPnl').style.minHeight = subHeight - 20 + 'px'; 
			}
		}		
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

    function openFaqCat()
    {   
        el = document.getElementById('faqCategories');
        
	    for (i=0; i<el.childNodes.length; i++) {
		    node = el.childNodes[i];
		    if (node.nodeName=="UL") { 
                theUL = node;	    
		    }
        }
        
        
        
        if(window.opera)
        {   el2 = document.getElementById('faqCategoriesList');
            /* OPERA doesn't support overflow-y, so that leaves 2 choices: both scrollbars or no scrollbars (long list)*/
            // - long list:
                el.style.height = 'auto';
                el2.style.height = 'auto';
            
            // - both scrollbars:
                //el.style.height = '169px';
                //el2.style.overflow = 'scroll';
        }
        else
        {  if(theUL.offsetHeight<171) { el.style.height = 'auto';  el.style.overflow = 'auto';  }
           else             { el.style.height = '171px';  theUL.style.height = '150px';}
        }

    }

    function closeFaqCat(e)
    {   
        e = e || window.event;
        var obj = e.target || e.srcElement;
        theClass = obj.className.toLowerCase();
                
        if(theClass.indexOf("faqcat") < 0)
        {   
            el = document.getElementById('faqCategories');
            el2 = document.getElementById('faqCategoriesList');
            el.style.height = '20px'; 
            el.style.overflow = 'hidden';
            if(el.style.height == 'auto')
            { el2.style.height = '150px'; }

        }

        
        
    }
