sfHover = function() {
var sfEls = document.getElementById("navitems").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

var htimer; var viewable = 1;
$(document).ready(function () {
    var imgwidth = parseInt($("#ainner .thumb img").width());
    var itemmargin = parseInt($("#ainner .thumb").css("marginRight"));
    var itemwidth = imgwidth + itemmargin;
    viewable = parseInt($("#aitems").width()) / itemwidth;
    viewable = Math.round(viewable);
    var itemcount = $("#ainner .thumb").length;
    var sliderwidth = -itemcount * itemwidth;
    $("#viewer .bigimage:first").addClass("shown").show();
    $("#ainner .thumb:first").addClass("nowshown");
    if (itemcount >= viewable) {
        for (var i = 0; i <= viewable; i++) {
            $("#ainner .thumb:eq(" + i + ")").clone().appendTo("#ainner");
            itemcount++;
        }
    }
    htimer = setTimeout("rollOn(" + itemwidth + "," + sliderwidth + ")", 5000);
    $("#viewer").mouseover(function () { clearTimeout(htimer); });
    $("#viewer").mouseout(function () { htimer = setTimeout("rollOn(" + itemwidth + "," + sliderwidth + ")", 1000); });
    $('.showPop').fancybox({
      autoScale: true,
      imageScale: false,
      hideOnContentClick: true,
      centerOnScroll: true,
      showCloseButton: true
    });

   

});

function rollOn(itemwidth, sliderwidth) {
    var act = $("#viewer .shown").prevAll().length - 1;
    var lastitem = $("#viewer .bigimage").length;
    if (act == lastitem) { act = 0; }
    var stripwidth = parseInt($("#ainner").width());
    if (lastitem >= viewable) {
        if ($("#ainner").css("left") != sliderwidth + "px") {
            $("#ainner").animate({ "left": "-=" + itemwidth + "px" }, "slow", function () { $(this).stop(true); });
        } else {
            $("#ainner").css("left", "0px");
            $("#ainner").animate({ "left": "-=" + itemwidth + "px" }, "slow", function () { $(this).stop(true); });
            act = 1;
        }
    }
    $("#viewer .shown").removeClass("shown").css("display", "none");
    $("#viewer .bigimage:eq(" + act + ")").addClass("shown").css("display", "block");
    $("#ainner .nowshown").removeClass("nowshown");
    if (act == 0) { act = lastitem; }
    $("#ainner .thumb:eq(" + act + ")").addClass("nowshown");
    htimer = setTimeout("rollOn(" + itemwidth + "," + sliderwidth + ")", 5000);
}


function showNextContent() {
  
   current = (current < stopit2) ? current+1 : 0;
   showContent(current);
}

// Image viewer code
function showImgs(str) {
	//var str=id.src;
	if (str.match("78x64")) { str=str.replace(/78x64/,"294x257"); }
	if (str.match("40x64")) { str=str.replace(/40x64/,"161x257"); }
	document.getElementById('big').src=str;
}

// Faq box code
var oid='a0';
function openbox(id) {
	if (document.getElementById(id).lastChild.style.display != "block") {
		//document.getElementById(id).firstChild.style.backgroundImage="url(images/spacer.gif)";
		//document.getElementById(id).firstChild.style.backgroundPosition="top right";
		//document.getElementById(id).firstChild.style.backgroundRepeat="no-repeat";
		document.getElementById(id).lastChild.style.display="block";
	} else {
		//document.getElementById(id).firstChild.style.backgroundImage="url(images/arrow_right.gif)";
		//document.getElementById(id).firstChild.style.backgroundPosition="top right";
		//document.getElementById(id).firstChild.style.backgroundRepeat="no-repeat";
		document.getElementById(id).lastChild.style.display="none";
	}
	// call closeBox(oid) to close open box after opening a new one
	if (id!=oid) { closeBox(oid);oid=id; }
}
// function used to close open box after opening a new one
function closeBox(oid) {
	if (oid=='a0') { return; }
	//document.getElementById(oid).firstChild.style.backgroundImage="url(images/spacer.gif)";
	//document.getElementById(oid).firstChild.style.backgroundPosition="top right";
	//document.getElementById(oid).firstChild.style.backgroundRepeat="no-repeat";
	document.getElementById(oid).lastChild.style.display="none";
}


// new popup

var pid;
function hidePop() { document.getElementById('bopop').style.visibility = 'hidden'; document.getElementById('pop1').style.display = 'none'; ie6Form('visible'); }
var pageWidth, pageHeight;

function showPop(nid) { getPageSize(); document.getElementById('popimg').src = nid; document.getElementById('fade').style.height = pageHeight; document.getElementById('pop1').style.display = 'block'; document.getElementById('bopop').style.visibility = 'visible'; pid = nid; ie6Form('hidden'); }



function getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; }
    else if (document.body.scrollHeight > document.body.offsetHeight) { xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; }
    else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; }
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; }
        else { windowWidth = self.innerWidth; }
        windowHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; }
    else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; }
    if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; }
    if (xScroll < windowWidth) { pageWidth = xScroll; } else { pageWidth = windowWidth; }
    return [pageWidth, pageHeight];
}

function ie6Form(state) {
    if (document.all) {
        var version = /MSIE \d+.\d+/; var brwsr = navigator.appVersion.match(version);
        if (("" + brwsr).indexOf("6") > 0) {
            var frmInput = new Array(); frmInput = document.getElementsByTagName("input"); var stop1 = frmInput.length;
            for (var i = 0; i < stop1; i++) { frmInput[i].style.visibility = state; }
            var frmSelect = new Array(); frmSelect = document.getElementsByTagName("select"); var stop2 = frmSelect.length;
            for (var i = 0; i < stop2; i++) { frmSelect[i].style.visibility = state; }
            var frmTextarea = new Array(); frmTextarea = document.getElementsByTagName("textarea"); var stop3 = frmTextarea.length;
            for (var i = 0; i < stop3; i++) { frmTextarea[i].style.visibility = state; }
        }
    }
}

