 
function redrawFooterContainer() {
	$("#footerContainer").css("position", "relative");
}


$(document).ready(function() {
	NX.osec.forms.setLabelAsFirstItem('formtopic');
	NX.osec.forms.setLabelAsFirstItem('formcountry');

	if( jQuery.isFunction($(".popupwindow").popupwindow) ) {
		$(".popupwindow").popupwindow();
	}
	
 	// Styles when JavaScript is enabled
 	$("#quickSearchContainer, #langListWrapper").css("left","-900%");
 	
	$("a[@href^=http]").addClass('ext');
	
	$("a").not("[@href^=http]").addClass('int'); 	
 	
	// LangSelector
	$("#currentLang, #bttLangSelector").hover(
      function () {
      	$("#currentLang").css("background","#a4011c");
      	$("#bttLangSelector").css("background-position","-18px 0");
      	$(".langSelector").css("background","#a4011c");   	
        $("#langListWrapper").css("left","0");
      }, 
      function () {
      	$("#bttLangSelector").css("background-position","0 0");
      }
    );

    $(".pseudoRef").hover(
      function () {
        //$("#langListWrapper").css("left","-800%");
        //$("#bttLangSelector").css("background-position","0 0");
      	//$(".langSelector").css("background","");
      	//$("#currentLang").css("background","");
       }, 
      function () {
      	//
      }
    );
        
    $("#langListWrapper").hover(
      function () {
      	$("#currentLang").css("background", "#a4011c");
      	$("#bttLangSelector").css("background-position","-18px 0");
				$(".langSelector").css("background","#a4011c");
      }, 
      function () {
				$("#langListWrapper").css("left","-800%");
    		$("#currentLang").css("background", "transparent");
      	$("#bttLangSelector").css("background-position","0 0");

      }
    );
      
    $("#currentLang li ").hover(
      function () {
        $("#langListWrapper").css("left","0");
      }, 
      function () {
      	//
      }
    );
    
    $("#currentLang li a ").hover(
      function () {
        $("#langListWrapper").css("left","0");
      }, 
      function () {
      	//
      }
    );
   
	 
	 	// Top-Link
		$("div.component.top div.top a.top").hover(
			function () {
				$(this).css("backgroundImage","url(/images/arrowTopHover.gif)");
			}, 
			function(){
				$(this).css("backgroundImage","url(/images/arrowTop.gif)");
			}
		);
	  
	  	 	// Top-Link
		$("div.component.glossary a.top span").hide();
		$("div.component.glossary a.top").hover(
      function () {
      	$(".text", $(this)).show();
      	$(this).css("width","10em");
				$("img", $(this)).attr({
					src: "/images/arrowTopHover.gif" 
				});
      }, 
      function(){
      	$(".text", $(this)).hide();
      	$(this).css("width","2em");
				$("img", $(this)).attr({
					src: "/images/arrowTop.gif" 
				});
	  	}
    );
   
    // Get ShortCut height
    if ((jQuery.browser.msie) && jQuery.browser.version < 7) {
  		shortCutHeight = (document.getElementById("shortCut"))? document.getElementById("shortCut").offsetHeight - 16: null;
     $("#shortCut_shadow").css("height",shortCutHeight);
		}


	// Search Show/Hide Search 
	$("#searchTitle , #searchTitle *").mouseover(
      function () {
        $("#quickSearchContainer").css("left","0");
       }
    ); 
    
  $("#moodImg, #header").mouseover(
  function(){
    $("#quickSearchContainer").css("left","-900%");
  	}
  );
  
  
  /*Segment Intranets Start*/
	document.onmouseover = hideSearchDiv;
	function hideSearchDiv()
	{ 
		$("#quickSearchContainer").css("left","-900%");
	}
	
	function showSearchDiv() 
	{ 
		$("#quickSearchContainer").css("left","0");
	}
	
	$("#searchDiv").mouseover( function(e) { e.stopPropagation() } );
	
	$("#searchDiv").mouseover(showSearchDiv);
	
  /*
  $("#searchDiv").hover(
    function () {      
     }, 
    function () {
      $("#quickSearchContainer").css("left","-900%");
    }
  );
    */

    // Show/Hide Exhibitorlist
	$(".toggleExhibitors .titleWrapper").click(function () {
      $(this).parent().toggleClass("off");
				if ( $(this).parent().hasClass("off")){
					if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
        	$(".toggle", $(this)).css("background", "url(/images/showTableHover.gif)");
      		}
			  }
      	else {
      		if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
	        	$(".toggle", $(this)).css("background", "url(/images/hideTableHover.gif)");
        	}
      	}
      
      $("*", $(this)).blur();
		redrawFooterContainer();
      return false;
    });

     // Show/Hide Content
     $(".toggleTeaser .titleWrapper").click(function () {
      $(this).parent().toggleClass("off");   
      if ( $(this).parent().hasClass("off")){
        	$(".toggle", $(this)).css("background", "url(/images/icon_showContent.gif)");
			    }
      	else {
        	$(".toggle", $(this)).css("background", "url(/images/icon_hideContent.gif)");
      	}
      
      $("*", $(this)).blur();
		redrawFooterContainer();
      return false;
    });

    
    // Show/Hide Table
     $(".toggleTable .titleWrapper").click(function () {
      $(this).parent().toggleClass("off");
				if ( $(this).parent().hasClass("off")){
					if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
        	$(".toggle", $(this)).css("background", "url(/images/showTableHover.gif)");
      		}
			  }
      	else {
      		if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
	        	$(".toggle", $(this)).css("background", "url(/images/hideTableHover.gif)");
        	}
      	}
      
      $("*", $(this)).blur();
		redrawFooterContainer();
      return false;
    });
    
    
    // Special for IE 6
    $(".toggleTable .titleWrapper").mouseover(function () {
      if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
      	if ( $(this).parent().hasClass("off")){
        	$(".toggle", $(this)).css("background", "url(/images/showTableHover.gif)");
			    }
      	else {
        	$(".toggle", $(this)).css("background", "url(/images/hideTableHover.gif)");
      	}   	
      }
     });
     
     $(".toggleTable .titleWrapper").mouseout(function () {
      if ( $.browser.msie && (jQuery.browser.version <= 6)){ 
      	if ( $(this).parent().hasClass("off")){
        	$(".toggle", $(this)).css("background", "url(/images/showTable.gif)");
			    }
      	else {
        	$(".toggle", $(this)).css("background", "url(/images/hideTable.gif)");
      	}   	
      }
     });
     
     
     
     $("#formsicDivision").change( function() {
    	 updateMemberSicMajorList( $(this).val() );
     });
     
     $('#change-country').hover(
			function(){
				$('.flag-list').css('display','block');
				$('#col3').addClass('col3investhome');
			},
			function() {
				$('.flag-list').css('display','none');
				$('#col3').removeClass('col3investhome');
			}
		);	
    // Show/Hide Content
	/*
    $(".ext").hover(
      function () {
      	if( $(this).attr("title") ) {
       		$(this).append("<div class=\"extLayer\">"+ $(this).attr("title") +"</div>");
       	}
       }, 
      function () {
      	if( $(this).attr("title") ) {
       		$(".extLayer").remove();
       	}
      }
    );
	*/
     
     if( jQuery.innerfade ) {
	     $('#picture-fade').innerfade({
	    	 speed: 1000,
	    	 timeout: 4000,
	    	 type: 'random',
	    	 containerheight: '1em'
	     }); 
     }
     
     
     
     $("div.paypalbuynow form").each(function(index) {
    	 var rand = new Date().getTime();
    	 
    	 var returnElem = $("input[@name=return]", $(this));
    	 var invoiceElem = $("input[@name=invoice]", $(this));

    	 returnElem.val(returnElem.val().replace("paypalNanotime", rand ));
    	 invoiceElem.val(invoiceElem.val().replace("paypalNanotime", rand ));
     });     
    	 
     
     
 });
 
 
 
 // update periodicaly a clock

function showClock( divID, h, m, s, z ) {

	var tDate = new Date( 1970, 1, 1, h, m, s );
	
	h = tDate.getHours()  	< 10 ? "0" + tDate.getHours() : tDate.getHours()
	m = tDate.getMinutes()  < 10 ? "0" + tDate.getMinutes() : tDate.getMinutes();
	s = tDate.getSeconds()  < 10 ? "0" + tDate.getSeconds() : tDate.getSeconds()

	$("#" + divID ).text( h + ":" + m + " (" + z + ")" );
	setTimeout("showClock('" + divID + "'," + h + "," + (m+1) + "," + s + ",'" + z + "')",60000);
}


function checkFormRequired( setting, context, value, element, param ) {
	redrawFooterContainer();
	if( setting == 'true' ) {
		// check if dependency is met
		if ( !context.depend(param, element) )
			return "dependency-mismatch";
		switch( element.nodeName.toLowerCase() ) {
		case 'select':
			var options = jQuery("option:selected", element);
			return options.length > 0 && ( element.type == "select-multiple" || (jQuery.browser.msie && !(options[0].attributes['value'].specified) ? options[0].text : options[0].value).length > 0);
		case 'input':
			if ( context.checkable(element) )
				return context.getLength(value, element) > 0;
		default:
			return value.length > 0;
		}
	}
	else {
		return true;
	}
}


function checkFormConstraint( setting, context, value, element, param ) {
	redrawFooterContainer();
	switch( setting ) {
	
		case "none":
			return true;
			break;
			
		case "email":
			return context.optional(element) || /^([0-9a-zA-Z]+[-._+])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/i.test(value);
			break;
			
		case "text":
			return context.optional(element) || /^([a-zäöüA-ZÇüéâäàåçêëèïîìÁÀÄÅÉæÆôöòûùÿÖÜáíóúñÑß°\s])*$/i.test(value);
			break;
			
		case "numeric":
			return context.optional(element) || /^[\+\-]?[0-9]+([\,\.][0-9]+)?$/.test(value);
			break;
			
		case "date":
			return context.optional(element) || /^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{2,4}$/.test(value);
			break;
			
		default:
			return true;			
	}
}

function browseLinkDefaulted(fieldName,defaultHandle,closecall,internal,external,searchBox,start) {
    closecall   = typeof(closecall)     != 'undefined' ? closecall  : '';
    internal    = typeof(internal)      != 'undefined' ? internal   : '';
    external    = typeof(external)      != 'undefined' ? external   : '1';
    searchBox   = typeof(searchBox)     != 'undefined' ? searchBox  : '1';
    start       = typeof(start)         != 'undefined' ? start      : '/content';
    
    var value = $("input[name='" + fieldName + "']").attr('value');
    if( !value || value == '') value = defaultHandle;
    CFC_browseLink(fieldName,closecall,internal,external,searchBox,start,'','TitleText','','',value);
}

function CFC_popup(url, name, features) {
    var defaultWidth = 500;
    var defaultHeight = 400;
   
    if (url.indexOf("/") == 0) url = "" + url;
    if (features.indexOf("width") == -1) features += ",width=" + defaultWidth;
    if (features.indexOf("height") == -1) features += ",height=" + defaultHeight;
    var w = window.open(url, name, features);
    w.focus();
}

// used by memberlist
function openThickbox(obj) {
	var t = obj.title || obj.name || null;
	var a = obj.href || this.alt;
	var g = obj.rel || false;
	tb_show(t,a,g);
	this.blur();
	return false;
}

function updateMemberSicMajorList( divisionCode ) {
	var url = document.location.href;
	var index = url.lastIndexOf(".html")
	url = url.substr(0, index);
	url = url + ".selectSicMajorGroups." + divisionCode + ".json";
	
     // remove current options
	 $("#formsicMajor").removeOption(/./);
	 
	 // add new options
	 $("#formsicMajor").ajaxAddOption(url,{}, false, function() {
		 $("#formsicMajor").selectOptions("", true);
	 });
}

/**
 * @author Thomas Junghans, Namics AG, www.namics.com
 */
// create global object NX as our namespace
var NX = NX || {};

NX.osec = NX.osec || {};

NX.osec.forms = function() {
	
	/**
	 * Checks if a select fields has a label and creates an option item with the value of the label
	 * @param {String} selectId
	 */
	var setLabelAsFirstItem = function(selectId) {
		
		// find <select> with id = selectId
		if (!selectId) { return false; }
		
		if (jQuery('body.landingpage #' + selectId).length < 1) { return false; }
		
		var $select = null,
			$fieldset = null,
			$for = null,
			labelValue = '';
		
		$select = jQuery('#' + selectId);
		$fieldset = $select.parents('fieldset');
		
		if ($fieldset.length < 1) {
			return false;
		}
		
		// check if there is a <label> with for = selectId
		if (($for = $fieldset.find('label[for=' + selectId + ']')) && !$for) {
			return false;
		}
		
		// get label value, hide label
		labelValue = $for.html();
		$for.addClass('hide');
				
		// append label value to select first <option>
		$select.prepend('<option class="labelValue" value="">' + labelValue + '</option>');
		$select.children('option:first').get(0).selected = 'selected';
		
	};
		
	// public properties and methods or in fact only public if they are returned
	return {
		setLabelAsFirstItem : setLabelAsFirstItem
	}

}();
  
function PopupCenter(pageURL, title, w, h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}         
