﻿function Is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
	this.ns4 = (this.ns && (this.major >= 4));
	this.ie = (agent.indexOf("msie") != -1);
	this.ie4 = (this.ie && (this.major >= 4));
	this.mac = (agent.indexOf("mac") != -1)
	this.aol = (agent.indexOf("aol") != -1);
	this.aol4 = (this.aol && (this.major >= 4));
}

var is = new Is();


function iWindowOpen(iURL, iName, iWidth, iHeight, iLeft, iTop) {

	var nsparam = "left=" + iLeft + ",top=" + iTop + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + iWidth + ",height=" + iHeight;
	var ieparam = "left=" + iLeft + ",top=" + iTop + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + iWidth + ",height=" + iHeight;

	if (is.ns4 || is.ns6up) {
		window.open(iURL, iName, nsparam);
	}
	else if (is.ie4) {
		window.open(iURL, iName, ieparam);
	}
	else {
		location = iURL;
	}
}

function pop_pan(_url) {
	iWindowOpen(_url, 'pan', 440, 350, 10, 10)
}

function pop_sld(_url) {
	iWindowOpen(_url, 'sld', 432, 438, 10, 10)
}

function catHelp(_url) {
	iWindowOpen(_url, 'catHelp', 400, 300, 10, 10)
}

$(document).ready(function () {
    var noHide = false;
    $('#nav-venues, #nav-blog').mouseenter(function() {
      if ($(this).attr('id') === 'nav-venues') {
        $('#nav-blog').mouseleave();
      } else if ($(this).attr('id') === 'nav-blog') {
        noHide = false;
        $('#nav-venues').mouseleave();
      }
      $(this).addClass('hover').siblings().filter('.selected').removeClass('selected').addClass('selected-off'); 
    }).mouseleave(function() {
      if (!noHide) {
        $(this).removeClass('hover').siblings().filter('.selected-off').removeClass('selected-off').addClass('selected');
      }  
    }).find('select').focus(function() {
      noHide = true;
    }).blur(function() {
      noHide = false;
    }).change(function() {
      noHide = false;
    });
    $('#nav-account').mouseenter(function () {
        $(this).addClass('hover');
    }).mouseleave(function () {
        $(this).removeClass('hover');
    });

    $("img").each(function (index) {
        $(this).error(function () {
            $(this).hide();
        });
        $(this).attr("src", $(this).attr("src"));
    });
});

