document.createElement("article");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("nav");


var timeout;
function ToggleCartBox(show) {
    clearTimeout(timeout);
    if (show) {
        Effect.Appear("cartBox", { duration: 0.5 });
        timeout = setTimeout("ToggleCartBox(false)", 3000);
    }
    else
        Effect.Fade("cartBox", { duration: 0.5 });
}

function SlideInDisplay(divID, cbID) {
    if (jQuery(cbID).attr("checked")) {
        jQuery(divID).show('slow');
    } else {
        jQuery(divID).hide('slow');
    }              
}

function recordOutboundLink(link, category, action) {
  try {
    var pageTracker=_gat._getTracker("UA-1833658-5");
    pageTracker._trackEvent(category, action);
    setTimeout('document.location = "' + link.href + '"', 100)
  }catch(err){}
}    

function expandAllQuestions()
    {
        var all = document.getElementsByTagName("DIV");
        for (var i=0; i<all.length; i++)
        {
            if (all[i].className == "faq-item")
            {
                all[i].className += " faq-expanded-item";
            }
        }            
    }
    
    function collapseAllQuestions()
    {
        var all = document.getElementsByTagName("DIV");
        for (var i=0; i<all.length; i++)
        {
            if (all[i].className == "faq-item faq-expanded-item")
            {
                all[i].className = "faq-item";
            }
        }
    }
 
  function questionExpandCollapse(question) {        
        if ((typeof(question) != "undefined") && (question != null) &&
           (typeof(question.parentNode) != "undefined") && (question.parentNode != null))
           {
             var item = question.parentNode;
              if (item.className.indexOf("faq-expanded-item") > -1)
               {
                   item.className = "faq-item";
		question.style.background = 'url(/media/35559/plus-symbol.jpg) no-repeat top left';
           	//item.className = "faq-question";
             }
                else
               {
                   item.className += " faq-expanded-item";
		question.style.background = 'url(/media/35564/minus-symbol.jpg)  no-repeat top left';
 		//item.className += " faq-answer";
                }
          }
       }
 
function checkEmail(inputvalue){ var pattern=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; return pattern.test(inputvalue);}

function checkPass(inputvalue) { var pattern = /^(?=.*(\d|[^a-zA-Z]))(?=.*[a-z])(?!.*\s).{6,20}$/; return pattern.test(inputvalue); }

function toggle_faq(toggleBtn) {
    var dl = toggleBtn.parentNode;
    dl.className = (dl.className != "expanded") ? "expanded" : "collapsed";
}

function update_textfield(id, str) {
    document.getElementById(id).innerHTML = str;
}

function selectBio(bioId, labelId) {    
    var bio = document.getElementById(bioId);
    var label = document.getElementById(labelId)
    if (bio == null || labelId == null)
        return;

    closeAllBios();
    bio.style.display = 'block'; 
    label.style.color = '#006699'
}

function closeBio(bioId, labelId) {
    var bio = document.getElementById(bioId);
    var label = document.getElementById(labelId)
    if (bio == null || labelId == null)
        return;

    bio.style.display = 'none';
    label.style.color = '';
}

function closeAllBios() {
    for (var i = 0; i <= 15; i++) {
        closeBio("a" + i, "lbl" + i);
    }
}

function advance_slides(incr, slideCount, el, slideWidth) {
    var wrapper = el;
    while (wrapper != null && wrapper.className != "bluebg slider" && wrapper.parentNode != null)
        wrapper = wrapper.parentNode;

    var ctrls = wrapper.getElementsByClassName("wrapper");
    if (ctrls != null && ctrls.length > 0)
        wrapper = ctrls[0];   

    var slideDiff = -1 * slideWidth * incr;
    var wrapperLeft = parseInt(wrapper.style.left) | 0;
    var wrapperWidth = parseInt(wrapper.clientWidth) | 0;

    if (wrapperLeft + slideDiff > 0)
        var effect = new Effect.Move(wrapper, { x: (-1 * wrapperWidth + slideWidth), y: 0, mode: "absolute", duration: 1.0 });
    else if (wrapperLeft + slideDiff <= (-1 * slideWidth * slideCount))
        var effect = new Effect.Move(wrapper, { x: 0, y: 0, mode: "absolute", duration: 1.0 });
    else
        var effect = new Effect.Move(wrapper, { x: slideDiff, y: 0, duration: 0.5 });
}

function InputBoxClear(id, defaultText) {
    var input = document.getElementById(id);
    if (input.value == defaultText)
        input.value = "";
    else if (input.value == "")
        input.value = defaultText;
}

function addItemToCart() {
    Effect.Appear("cartBox", { duration: 0.5 });
    timeout = setTimeout("Effect.Fade('cartBox', { duration: 0.5 })", 3000);

}

jQuery.fn.center = function () {
    this.css("position", "absolute");
//    this.css("top", ((jQuery(window).height() - jQuery('#dvProgressOverlay').height() - 300) / 2) + jQuery(window).scrollTop() + "px");
//    this.css("left", ((jQuery('#Content').width() - jQuery('#dvProgressOverlay').width()) / 2) + jQuery(window).scrollLeft() + "px");

    this.css("top", ((jQuery(window).height() - 350) / 2) + jQuery(window).scrollTop() + "px");
    this.css("left", 350 + jQuery(window).scrollLeft() + "px");

//    this.css("position", "fixed");
//    this.css("top", "50%");
//    this.css("left", "50%");
    return this;
}
