
/*******
** vp - Local navigation  - Indivirtual (c) - 1.0 **
*******/
	$(document).ready(function() {
		$(".localNav").find('.arrow').click(function (e) {
			if ( $(this).parent().hasClass("down")) {
				$(this).next().next().hide();
				$(this).parent().removeClass("down")
			}
			else if ( $(this).parent().hasClass("actDown") ) {
				$(this).next().next().hide();
				$(this).parent().removeClass("actDown")
			}
			e.preventDefault();
		});
	});



//Son of Suckerfish with sticky focus toplevel
menuHover = function(nav) {
	if (document.getElementById(nav)) {
		var sfEls = document.getElementById(nav).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("\\s?sfhover\\b"), "");
			}
		}
	}
}

function addEvent(obj, type, fn) {
	if (obj.attachEvent) {
		obj['e' + type + fn] = fn;
		obj[type + fn] = function() { obj['e' + type + fn](window.event); }
		obj.attachEvent('on' + type, obj[type + fn]);
	} else
		obj.addEventListener(type, fn, false);
}

function removeEvent(obj, type, fn) {
	if (obj.detachEvent) {
		obj.detachEvent('on' + type, obj[type + fn]);
		obj[type + fn] = null;
	} else
		obj.removeEventListener(type, fn, false);
}

addEvent(window, 'load', function () { menuHover('nav'); });

function Log(msg) {
	if(!document.all) {
		console.log(msg);
	}
}

/* marketprices page */
function openBigGraph(key, hubName) {
	var opt = 'width=488; height=347; location=no; resizable=no; menubar=no; scrollbars=no; status=no; titlebar=no; toolbar=no;';
	var win = window.open('', hubName.replace(' ', ''), opt);
	win.resizeTo(488, 347);
	var img = 'http://www.endex.nl/index.php?view=img&size=big&key=' + key;

	var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
	html += '<html>';
	html += '<head>';
	html += '  <title>' + hubName + ' - Vergroting</title>';
	html += '  <link rel="stylesheet" type="text/css" href="http://www.endex.nl/layout/default/style.css">';
	html += '</head>';
	html += '<body style="margin: 0px; background-color: #FFF; background-image: none;">';
	html += '<img src="' + img + '" style="border: 0px none;" />';
	html += '</body>';
	html += '</html>';

	win.document.write(html);
}

/* jQuery functions ****************************************************/
  $(document).ready(function() {

  	//open these links in a new window:
  	$("a.linkPdf, a.linkDoc, a.linkPp, a.linkExcel").click(function() {
  		window.open(this.href);
  		return false;
  	});

  	//anchors!
  	$("div.content ul>li>a[href*=#]").each(function() {
  		var parent = $(this).parents("ul:eq(0)");

  		if (!parent.hasClass("thisPage")) {
  			parent.addClass("thisPage");
  			return false;
  		}
  	});

  	$("div.content a[href=#]").each(function() {
  		if (!$(this).hasClass("top")) {
  			$(this).addClass("top");
  		}
  	});

  	$("div.content a:not([href])").each(function() {
  		if (!$(this).hasClass("noHyperlink")) {
  			$(this).addClass("noHyperlink");
  		}
  	});
	
	/* button with classNames */
	$("div#main a[class]").each(function() {
	
		if ($(this).children().size() <= 0) {
			$(this).wrapInner(document.createElement("span"));
		}
		else if ( $(this).children().size() >= 0 ) {
			var tagname = $(this).children().get(0).tagName.toLowerCase();
			if (tagname == 'strong' ) {
				if ( $(this).is('.buttonDownloadBlue') || $(this).is('.buttonDownloadRed') ) {
					$(this).wrapInner(document.createElement("span"));
					$(this).wrapInner(document.createElement("span"));
				}
				else {
					$(this).wrapInner(document.createElement("span"));
				}
			}
		}
	});

  });