/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
(function($){$.dimensions={version:'1.2'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;};})(jQuery);

function showCountry(id)
{
	
	c = "countryUrl"+ id;
	document.getElementById(c).style.display = "block";
	
}

function addAnd(){
	var addAnd = "&";
	return addAnd;
}
function addGt(){
	var addGt = ">";
	return addGt;
}
function addLt(){
	var addLt = "<";
	return addLt;
}
function hideCountry(id)
{
	c = "countryUrl"+ id;
	document.getElementById(c).style.display = "none";
}

function PopupFenster_small(url) {
	var isSafari3 = false; 
	
	if( window.devicePixelRatio &&  window.getMatchedCSSRules && !window.Opera){
	    isSafari3  =  !!window.getMatchedCSSRules(document.documentElement,'');
		msgWindow=window.open(url,"popup","toolbar=no,width=645,height=445,status=no,scrollbars=no,resizable=no,menubar=no,dependent=no");
	}else{
		msgWindow=window.open(url,"popup","toolbar=no,width=630,height=445,status=no,scrollbars=no,resizable=no,menubar=no,dependent=no");
	}
}

function mailto(url){
        var myUrl = escape(url);
        parent.location.href="mailto:Your%20Contact%20Address?subject=Link-Tip&body=This%20link%20was%20recommended%20to%20you:%20%20" + myUrl +"%20";
}

//Globale Variable welche f�r "printpage" ben�tigt wird
var activeTab;

//Funktion welche tab active inactive setzt udn inhalt anzeigt by juwimm
function showtab1(id) 
{   
	
	activeTab = id;	
    //tab aktiv setzen und andere Tabs inaktiv setzen, tabcontainer anzeigen
    for (i = 0; i < tabLables.length; i++) 
    {           
        if ((i+1) == id)//tab activ setzen 
        {
            if (document.getElementById("tab"+(i+1)).className == "tabinactive") 
            {
                document.getElementById("tab"+(i+1)).className = "tabactive";
            }
            document.getElementById("tabcontent"+(i+1)).style.display = "block";
              
        }
        else //Tab inactiv setzen 
        {
            
            document.getElementById("tab"+(i+1)).className = "tabinactive";
            //Tabcontainer inaktiv setzen
            document.getElementById("tabcontent"+(i+1)).style.display = "none";
        }
    }
}

function openWindow(url,width,height,scroll,name)
{
	//default scrollbars=no;
	if(scroll=='')
	{
		scroll = 'no';
	}
	if(activeTab == null)
	{
		activeTab=1;
	}
	url = url+"&actTab="+activeTab;
	popWindow = window.open(url,name,"toolbar=no,width="+width+",height="+height+",status=yes,scrollbars="+scroll+",resizable=no,menubar=no,dependent=no");
	popWindow.blur;
}


// will be called by flash layer
function closeFlashBannerDiv() 
{
	document.getElementById("flashLayer").style.display = "none";
	isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	if(isIE6){
		;(function($){
				
			$('img').each(function(){
				var $this = $(this);
				if($this.attr('src').match(/\.gif/i) != null) {
					$this.attr('src', $this.attr('src'));
				}
			}); 
				
		})(jQuery);
	}
}


var activeSubcontactDiv = undefined;
var activeSubcontactSelect = undefined;

function updateSubcontactField(div, select) {

    var subcontactDiv 		= document.getElementById(div);
    var subcontactSelect 	= document.getElementById(select);
    
    if (activeSubcontactSelect != null) {
    	activeSubcontactSelect.selectedIndex = 0;
    	activeSubcontactDiv.style.display = 'none';
    	
    }
    
    if (subcontactDiv != null &&  subcontactDiv != undefined) {
         subcontactDiv.style.display = 'block';
         activeSubcontactDiv = subcontactDiv;
         activeSubcontactSelect = subcontactSelect;
    }
}



function createXMLHttpRequest() {

	var ua;

	if(window.XMLHttpRequest) {
    	try {
      		ua = new XMLHttpRequest();
    	} catch(e) {
      		ua = false;
    	}
  	} else if(window.ActiveXObject) {
    	try {
      		ua = new ActiveXObject("Microsoft.XMLHTTP");
    	} catch(e) {
      		ua = false;
    	}
  	}
  return ua;
}

function sendRequest(url) {
  var req = createXMLHttpRequest();
  id = document.getElementById("dropdown").value;
  req.open("POST",url,true);
  req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  req.onreadystatechange = tryit;
  req.send(id);
}

function tryit(){
    document.frm.i_gruppe.value = req.responseText;
}


/* print functions using jQuery and Boxy */
var _currentModalBoxy = {};

if(typeof jQuery != "undefined") {

	jQuery.extend({
		  getUrlVars: function(urlurl){
		    var vars = [], hash;
		    var hashes = urlurl.slice(window.location.href.indexOf('?') + 1).split('&');
		    for(var i = 0; i < hashes.length; i++)
		    {
		
		      hash = hashes[i].split('=');
			  	
		      vars.push(hash[0]);
		      vars[hash[0]] = hash[1];
		    }
		    return vars;
		  }
	});

	
	var closeColorBox = function() {
		var $ = $j || $;
		$("#modalClose").click(); 	
	};
	

	
(function ($){
	$(document).ready(function() {
		$("a.print-link, a.print-all-link").click(function(e) {
			$("#homeWorldwideflash").hide();
			$("select").css({visibility:"hidden"});
			var link = $(this);
			_currentModalBoxy = new Boxy("<iframe src='' frameborder='0' id='modalPrintView'></iframe>", {
				title: link.html(),
				afterHide: function() { this.unload(); $("#homeWorldwideflash").show(); $("select").css({visibility:"visible"}); },
				modal: true,
				closeText: "<img border=\"0\" src=\"/httpd/img/general/icon_close.gif\" width=\"13\" height=\"13\">"
			});
			
			$("#modalPrintView").parent().css("overflow", "hidden");
			$("#modalPrintView").load(function() { $(this).contents().find("html").css("overflow", "hidden"); });
			$("#modalPrintView").attr("src", link.attr("href"));
			
			return false;
		});
		
		$("a.boxy-link").click(function(e) {
			var maxHeight = $(window).height() - 40;
			var maxWidth = $(window).width() - 10;
			var link = $(this);
			var widthOfIframe = $.getUrlVars(link.attr("href"))['width'];
			var heightOfIframe = $.getUrlVars(link.attr("href"))['height'];
			
			widthOfIframe = maxWidth > widthOfIframe ? widthOfIframe : maxWidth;
			heightOfIframe = maxHeight > heightOfIframe ? heightOfIframe : maxHeight;
			
			_currentModalBoxy = new Boxy("<iframe src='' frameborder='0' id='modalFrameView' style='width:" + widthOfIframe + "px;height:" + heightOfIframe + "px;'></iframe>", {
				title: "&#160;",
				afterHide: function() { this.unload(); },
				modal: true,
				closeText: "<img border=\"0\" src=\"/httpd/img/general/icon_close.gif\" width=\"13\" height=\"13\">"
			});
			
			$("#modalFrameView").attr("src", link.attr("href"));
//			$("#modalFrameView").attr("style", "width:" + widthOfIframe + "px;height:" + heightOfIframe + "px;");
			
			return false;
		});		
	});
})(jQuery);
	
}

function requestHomePageHttpLink(httpLink, title, type) {
	if(type == 'http') {
		window.location.href = httpLink;
	} else if ( type == 'thickbox' ) {
		tb_open_new(httpLink,title);
	}else {

	}
}

function clear_form_elements(ele) {
	
	jQuery(':input',ele)
	 .not(':button, :submit, :reset, :hidden')
	 .val('')
	 .removeAttr('checked')
	 .removeAttr('selected');

}
