/**
 * app.generic.js
 *
 * @copyright antwerpes ag 2009
 * @version 0.1 - 27.01.2009 12:02:01
 * @access public
 * @package
 */

function blurLink() { return false; }

var toSleep = true;
function stopTimer(){
	toSleep=false;
}
function clickTracker(LinkName){
	var secureID="BQsmS9";
	var redirectUrl="http://www.etracker.de/skin/de.def/img/1px.gif";
	etrackerSink=new Image(1,1);
	toSleep=true;
	etrackerSink.src="http://www.etracker.de/lnkcnt.php?et="+secureID+"&url="+redirectUrl+"&lnkname="+LinkName;
	etrackerSink.onload=stopTimer;
	if(toSleep==true) {
		maxDelay(500);
	}
	return true;
}
function maxDelay(gap){
	var then,now;then=new
	Date().getTime();
	now=then;
	while( toSleep==true&&(now-then)<gap){
		now=new Date().getTime();
	}
}

$(document).ready(function() {
	$('div#tabContainer ul').css('display', 'block');
	$('div#tabContainer div#tabContent').tabs();

	$('textarea#expertenratQuestion').focus(function() {
		if ($(this).val() == 'Stellen Sie hier Ihre Frage!') {
			$(this).val('');
		}
	});

	$('textarea#expertenratQuestion').blur(function() {
		if ($(this).val() == '') {
			$(this).val('Stellen Sie hier Ihre Frage!');
		}
	});

	var objActiveTopNavigationItem = null;
	var objActiveLayer = null;
	var bolBlockHide = false;
	
	function _parseQuery ( query ) {
	    // return empty object
	    if( !query )
	        return {};
	    var params = {};
	
	    // parse query
	    var pairs = query.split(/[;&]/);
	    for ( var i = 0; i < pairs.length; i++ ) {
	        var pair = pairs[i].split('=');
	        if ( !pair || pair.length != 2 )
	            continue;
	        // unescape both key and value, replace "+" with spaces in value
	        params[unescape(pair[0])] = unescape(pair[1]).replace(/\+/g, ' ');
	   }
	   return params;
	}

    /*
     * TOP NAVIGATION
     */
    $('div#pageHeader').hover( function() {
        if( objActiveTopNavigationItem != null ) {
            objActiveTopNavigationItem.removeClass('active');
        }
        if ( objActiveLayer != null ) {
            objActiveLayer.hide();
        }
    });

    $('ul#first li').hover( function() {

        if( objActiveTopNavigationItem != null ) {
            objActiveTopNavigationItem.removeClass('active');
        }
        if ( objActiveLayer != null ) {
            objActiveLayer.hide();
        }

        objActiveTopNavigationItem = $(this);
        $(this).addClass('active');

        strActiveLayerId = '#divTopNavigationLayered' + $(this).attr('id');
        //alert(strActiveLayerId);

        objActiveLayer = $(strActiveLayerId);
        //alert(objActiveLayer.size());
        objActiveLayer.show();

    }, function () {
    });

    $('.ulTopNavigationLayered').hover( function() {
    }, function() {

        if( objActiveTopNavigationItem ) {
            objActiveTopNavigationItem.removeClass('active');
        }
        if ( objActiveLayer ) {
            objActiveLayer.hide();
        }
    });

    $('div.divTopNavigationLayeredItem').hover( function() {
        $(this).addClass('divTopNavigationLayeredItemActive');
    }, function () {
        $(this).removeClass('divTopNavigationLayeredItemActive');
    });

    $('div#divHeader | div.divTopNavigationItemLast').hover( function() {
        if( objActiveTopNavigationItem ) {
            objActiveTopNavigationItem.removeClass('divTopNavigationItemActive');
        }
        if ( objActiveLayer ) {
            objActiveLayer.hide();
        }
    }, function() {
    });

    $('div#divStartTeaser div.csc-textpic-center').click( function() {
	        if(confirm("Please note: This website is intended to provide information to an international audience outside the USA and UK.")) {
	            return true;
	        } else {
	            return false;
	        }
	    }, function() {
    });

	// lexikon loop up. perform ajax request
	$('a.lexikonLookup').click(function() {
		var entryName = $(this).html();
		$.ajax({
			type: "POST",
			url: "/fileadmin/scripts/lexikonLookup.php",
			data: "link=" + lexikonLink + "&name=" + entryName,
			success: function(entryLink){
				window.open(entryLink, "Lexikon", "width=500,height=300,left=300,top=200");
				return false;
			}
		});

		return false;
	});

	// index search
	$('input#tx-indexedsearch-searchbox-sword-js').focus(function() {
		if ($(this).val() == 'Suchbegriff') {
			$(this).val('');
		}
	});

	$('input#tx-indexedsearch-searchbox-sword-js').blur(function() {
		setDefaultSearchWord();
	});

	function setDefaultSearchWord() {
		if ($('input#tx-indexedsearch-searchbox-sword-js').val() == '') {
			$('input#tx-indexedsearch-searchbox-sword-js').val('Suchbegriff');
		}
	}

	setDefaultSearchWord();

	// privacy policy
	$('a.linkPrivacyPolicy').click(function() {
		window.open( '/' + privacyPolicyPopup, "Datenschutz", "width=500,height=300,left=300,top=200,scrollbars=yes");
		return false;
	});
});

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
} else if (document.all&&!document.getElementById) {
	document.onmousedown=clickIE4;
}
document.oncontextmenu = new Function("return false")

$("a").click(function() {
	$(this).hide("slow");
	return false;
});
