$(document).ready(function(){	
	
	var strThemeUrl = Drupal.settings.themeUrl;
	var strImageUrl = strThemeUrl + "/images/pixel.gif";
	$.ifixpng(strImageUrl);
	$('img').ifixpng();
	$('#header-logo').ifixpng();
	
	if ($("#disclaimer")) {
		$("#disclaimer").click(function() {
			var baseUrl = Drupal.settings.baseUrl;
			var strDisclaimer = baseUrl + "/sites/tereo.nl/files/disclaimer.html"
			window.open(strDisclaimer, "disclaimerpopup", "top=180, left=200, addressbar = 0, height=400, width=500");
			return false;
		});
	}
	
	if($("#hdnSubMenu") && $("#hdnPrimaryLink")) {
	    var strPrimaryLink = $("#hdnPrimaryLink").val();
	    var strSubMenu = $("#hdnSubMenu").val();
	   
	    if(strSubMenu != '' && strPrimaryLink != '') {
           $("#block-menu-primary-links ul li a").each(function(){
                 var strHref = this.href;
                 if(strHref == strPrimaryLink) {
                     $(this).after(strSubMenu);
                 }
           });
	    }
	}
	
	if($("#block-menu-primary-links ul li ul li")) {
		$("#block-menu-primary-links ul li ul li").each(function(){
			var strHtml = $(this).html();
			strHtml = strHtml + "<span></span>";  
			$(this).html(strHtml);
		});
	}
	
	if($("#block-menu-primary-links ul li ul li span")) {
		var strThemeUrl = Drupal.settings.themeUrl;
		var strImageUrl = strThemeUrl + "/images/bullet.jpg";
		$("#block-menu-primary-links ul li ul li span").each(function(){
			w = window;
			if (w.innerHeight){ 
				$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:3px;");
			} else if (w.document.documentElement && w.document.documentElement.clientHeight) {
				// IE Strict mode
				var ver = getInternetExplorerVersion();
				if(ver >= 8) {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:3px;");
				}
				else if(ver == 6) {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:3px;");
				}
				else {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:45px;");
				}
				
				
			} else if (w.document.body) {
				// IE Normal mode
				var ver = getInternetExplorerVersion();
				if(ver >= 8) {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:3px;");
				}
				else if(ver == 6) {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:3px;");
				}
				else {
					$(this).attr("style", "background-image: url(" + strImageUrl + ");background-repeat: no-repeat;width: 3px;height: 4px; display:block; float:right;margin-left:0px;margin-top:11px;padding-right:45px;");
				}
			}
			
		});
	}
	
	if($("#right-content .intrapage-link p")) {
		$("#right-content .intrapage-link p").each(function(){
			var strHtml = $(this).html();
			var objSpan = $(this).next();
			var strSpan = $(objSpan).html();
			
			strHtml = strHtml + "<span class='more'>" + strSpan + "</span>";  
			$(this).html(strHtml);
			$(objSpan).html('');
		});
	}
	
	$("#Toevoegenaanfavorieten").click(function(){
		var title = window.title; 
		var url = Drupal.settings.baseUrl;
		
		if (window.sidebar) { 
			// Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url, "");
		} 
		else if( window.external ) { 
			// IE Favorite
			window.external.AddFavorite( url, title); 
		}
		else if(window.opera && window.print) { 
			// Opera Hotlist
		}
		return false;
	});
	
	if($(".submitted")) {
		$(".submitted").html("");
	}
	
	$("#country-flag-link").click(function(){
		var strUrl = this.href;
		window.open(strUrl, 'Tereo', 'status=yes,scrollbars=yes,resizable=yes,width=900,height=900');
		return false;
	});
	
	$("#silver-arrow-logo-link").click(function(){
		var strUrl = this.href;
		window.open(strUrl, 'SilverArrows', 'status=yes,scrollbars=yes,resizable=yes,width=1000,height=900');
		return false;
	});
}); 

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


