/* For contact us form */
function antiSpam(form) {
        if (document.form.page_comments.value=='') {
                                        alert('Form cannot be blank.');
        return (false);
        }
}

/*
Function that lets us hide or show a div/element. 
*/
function toggleLayer( whichLayer ) {
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}




// POPUP WINDOW

function addEvent(elm, evType, fn, useCapture) {if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}

var newWindow = null;

function closeWin() {
        if (newWindow != null){
                if(!newWindow.closed)
                        newWindow.close();
        }
}

function popUpWin(url, type, strWidth, strHeight) {
        closeWin();
                
        type = type.toLowerCase();
        
        if (type == "fullscreen"){
                strWidth = screen.availWidth;
                strHeight = screen.availHeight;
        }
        var tools="";
        if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
        if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
        newWindow = window.open(url, 'newWin', tools);
        newWindow.focus();
}

function doPopUp(e) {
//set defaults - if nothing in rel attrib, these will be used
var t = "standard";
var w = "780";
var h = "580";
//look for parameters
attribs = this.rel.split(" ");
if (attribs[1]!=null) {t = attribs[1];}
if (attribs[2]!=null) {w = attribs[2];}
if (attribs[3]!=null) {h = attribs[3];}
//call the popup script
popUpWin(this.href,t,w,h);
//cancel the default link action if pop-up activated
if (window.event) 
        {
        window.event.returnValue = false;
        window.event.cancelBubble = true;
        } 
else if (e) 
        {
        e.stopPropagation();
        e.preventDefault();
        }
}

function findPopUps() {
var popups = document.getElementsByTagName("a");
for (i=0;i<popups.length;i++)
        {
        if (popups[i].rel.indexOf("popup")!=-1)
                {
                // attach popup behaviour
                popups[i].onclick = doPopUp;
                // add popup indicator
                if (popups[i].rel.indexOf("noicon")==-1)
                        {
                        popups[i].style.backgroundImage = "url(pop-up.gif)";
                        popups[i].style.backgroundPosition = "0 center";
                        popups[i].style.backgroundRepeat = "no-repeat";
                        popups[i].style.paddingLeft = "15px";
                        }
                // add info to title attribute to alert fact that it's a pop-up window
                popups[i].title = popups[i].title + " [Opens in pop-up window]";
                }
        }
}

addEvent(window, 'load', findPopUps, false);

function swapImage(myImage, state) {
    if (state == "minus") {
            myImage.src = "/js/hide-show-img/minus.gif";
    }else{
            myImage.src = "/js/hide-show-img/plus.gif";
    }
}

/* B: Hide/show with triangle arrows */
function expandDiv(myItem, myButton) {
    var myItem = document.getElementById(myItem);
    var myButton = document.getElementById(myButton);
    
    if (myItem.style.display != "none") {
       myItem.style.display = "none";
       expandDivSwap(myButton,"plus");
    }else {
            myItem.style.display = "block";
            expandDivSwap(myButton,"minus");
        
    }
}    
    
function expandDivSwap(myImage, state) {
    if (state == "minus") {
            myImage.src = "/files/icons/showdown.png";
    }else{
            myImage.src = "/files/icons/showright.png";
    }
}



onload=function() {
if (document.getElementsByClassName == undefined) {
        document.getElementsByClassName = function(className)
        {
                var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
                var allElements = document.getElementsByTagName("*");
                var results = [];

                var element;
                for (var i = 0; (element = allElements[i]) != null; i++) {
                        var elementClass = element.className;
                        if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
                                results.push(element);
                }
                return results;
        }
}
}





$(document).ready(function() {
var divs = document.getElementsByClassName('hiddentoggle');
for(var i=0; i < divs.length; i++)
{
  var div = divs[i];
  div.style.display = "none";
}
}
);




/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

$(document).ready(function() {

function addMega(){
$(this).addClass("hovering");
}

function removeMega(){
$(this).removeClass("hovering");
}

var megaConfig = {
interval: 300,
sensitivity: 8,
over: addMega,
timeout: 500,
out: removeMega
};

$("li.dropitem").hoverIntent(megaConfig)

});















