$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.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;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});


// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();
	}
	else var expires = '';
	document.cookie = name+'='+value+expires+'; path=/';
}
function readCookie(name)
{
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,'',-1);
}
// /cookie functions


/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/
jQuery(document).ready(function($){vtip();}) 

this.vtip = function() {    
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 10; // y distance from mouse       
    
    $('.vtip').unbind().hover(    
        function(e) {
            this.t = this.title; 
            this.title = ''; // do not show title tooltip
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            
            $('body').append( '<p id="vtip"><img id="vtipArrow" />' + this.t + '</p>' );
                        
            $('p#vtip #vtipArrow').attr('src', './layout/gmo-free-regions/img/vtip_arrow.gif');
            $('p#vtip').css('top', this.top+'px').css('left', this.left+'px').fadeIn();
            
        },
        function() {
            this.title = this.t;
            $('p#vtip').fadeOut().remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
                         
            $('p#vtip').css('top', this.top+'px').css('left', this.left+'px');
        }
    );            
    
};

  
 function create_icon(icon)
 {
    var newimg=document.createElement('img');
	newimg.setAttribute('src','layout/img/'+icon+'.gif');
	newimg.setAttribute('class','link-icon');
	return newimg;
 }
 

/*    // vtip    ------------------------------------------ */

$(document).ready(function() {
						   
	$('tr:odd').addClass('odd');
	
	$('table tr').each(function() {
    	$(this).find('th:eq(0)').addClass('th-1');
		
    	$(this).find('td:eq(0)').addClass('td-1');
    	$(this).find('td:eq(1)').addClass('td-2');
    	$(this).find('td:eq(2)').addClass('td-3');
 	});	
	
	$("a[href^='http']").attr('target','_blank');
	
    $("a:has(img)").addClass("img");
	$("a[href^='javascript:linkTo_UnCryptMailto']").addClass("email").append(create_icon('linkmail'));
	// link icons: because of the IE multiline problem do not use css classes
	$("a[href$='.pdf']").append(create_icon('pdf_small'));
	$("a[href$='.rtf']").append(create_icon('doc_small'));
	$("a[href$='.doc']").append(create_icon('doc_small'));
	
	$("a[href$='.rtf']").attr('target','_blank');
	$("a[href$='.doc']").attr('target','_blank');
	$("a[href*='.pdf'], a[href*=':PDF']").attr('target','_blank');
	
	$("p a img.link-icon").parents('p').each(function(){
		// alert($(this).html());
        var expr = /link-icon([^>]*)><\/a>([,\.\)]{1})/gi;
		var repl = 'link-icon2$1></a>$2';
		$(this).html($(this).html().replace(expr,repl));	
	});	


	// showHide clickable
	$(".show-hide-text").hide(); 
	
	var showHideLinkStart = '<a class="show-hide-link" title="Show text"><img src="layout/img/plus.gif" />';
	var showHideLinkEnd = '</a>';

	$(".show-hide h2, .show-hide h3, .show-hide h4").each(function(){
			$(this).html(showHideLinkStart + $(this).html() + showHideLinkEnd);			  
	});		
	$(".show-hide h2 a, .show-hide h3 a, .show-hide h4 a").click(function(){
		$(this).parents("h3").next("div").toggle();		
		 if ($(this).attr("title") == 'Show text')
		 {
		   $(this).parents("h2, h3, h4").addClass('show');
		   $(this).attr("title","Hide text");
		   $(this).children("img").attr("src","layout/img/minus.gif");
		 } 
	    else
		 {
		   $(this).attr("title","Show text");
		   $(this).children("img").attr("src","layout/img/plus.gif");
		  // $(this).parents("h3").removeAttr('style');
		   $(this).parents("h3").removeAttr('class');
		 }	    
	});				   


						   
});


// typo3  /


function openPic(url,winName,winParams)	{	//
		var theWindow = window.open(url,winName,winParams);
		if (theWindow)	{theWindow.focus();}
	}
	
function openPopUp(url,winName,winParams)	{	//
		var theWindow = window.open(url,winName,winParams);
		if (theWindow)	{theWindow.focus();}
	}
	
function openMap(url,winWidth,winHeight)	{	//   
		if (newWin) {
			newWin.close();
		}
		// simple string without special characters for IE
		var winName = 'PopUp';
        var winParams = 'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=1,height='+winHeight+',width='+winWidth;
		// do not write var newWin here, but write var newWin outside of the function, then first if(newWin) causes no error
		newWin = window.open(url,winName,winParams);
		if (newWin)	{
			newWin.focus();
		}
	}