var lastActive;

////var title = document.title;
// Init and change handlers
$.blockUI.defaults.overlayCSS.backgroundColor = '#000000';
$.blockUI.defaults.overlayCSS.opacity = .0;
$.address.init(function(event) {
}).change(function(event) {
    if ( event.value == "/" || event.value == "/home" ) {
        event.value = "/Home";
        $('.content').hide();
        $('.topFlash').hide();
		$('#glow').hide(); 
        $('.bigFlash').show();
		$('#contentInner').html("");
		$('#subnav').html("");
        loading('1');
        $('#topnav').load("/topnav.php?value="+event.value, function() {
            loading('0');
        });        
    }
    else {
        $('.bigFlash').hide();        
		$('#glow').hide(); 
		loading('1');

		$('#contentInner').load("/content.php?value="+event.value, function() {
			$('#topnav').load("/topnav.php?value="+event.value);
            $('#subnav').load("/subnav.php?value="+event.value);
        $('.topFlash').show(); 
		$('.content').fadeIn('slow', function() { 
			$('#glow').show(); 
		});
		loading('0');
		});


}


    if ( lastActive == "/Home" || lastActive == "/" ) {
        restartTop();
    }
    lastActive = event.value;
	if(navigator.platform != 'iPad' && navigator.platform != 'iPhone' && navigator.platform != 'iPod')
	{
		//ander Browser
		$("#bottomDiv").css("position", "fixed");	 
		$("#bottomDiv").css("clear", "both");	
	};
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	{
		//iPad JA
		$("#FlashID4").css("display", "none");
		$("#monstaFlash").css("position", "relative");
		$("#monstaFlash").css("height", "auto");
		$("#monstaFlash").css("top", "0px");
		
		$("#bottomDiv").css("width", "1024px");

	};
});

$(document).ready(function() {
    if(navigator.platform != 'iPad' && navigator.platform != 'iPhone' && navigator.platform != 'iPod') {
		startTop();
	};
});

var topCounter = 0;
function startTop() {
    $('#topflash'+topCounter).animate({
        left: '+='+(screen.width+350)+'px'
      }, 140000, 'linear', function() { //85000
        resetTop();
      });
}
function restartTop() {
    $('#topflash'+topCounter).stop();
    $('#topflash'+topCounter).css("left",'-350px');
    resetTop();
}
function resetTop() {
    $('#topflash'+topCounter).css("left",'-350px');
    topCounter++;
    if ( topCounter >= topFlashNum ) {
        topCounter = 0;
    }
    startTop(topCounter);
}

function loading( _status ) {
    switch ( _status ) {
        case '0':
            $('#topnav').unblock();
            $('#contentInner').unblock();
            $('.subnav').unblock();
            $('#loading').hide();
            break;
        case '1':
            $('#topnav').block({message: null});
            $('#contentInner').block({message: null});
            $('.subnav').block({message: null});
            $('#loading').show();
            break;
    }
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
}
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}



//kundencenter login
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return '';
}
LIVEDAYS=30;
function SetCookie(name, value) {
document.cookie=name+"="+escape(value)+"; expires="+cookie_live();
}
function cookie_live() {
var date=new Date();
date.setDate(date.getDate()+LIVEDAYS);
var gmt=date.toGMTString();
var k1=gmt.indexOf(" ");
var k2=gmt.indexOf(" ", k1+1);
var k3=gmt.indexOf(" ", k2+1);
var str=gmt.substring(0,k2)+"-"+gmt.substring(k2+1,k3)+"-"+gmt.substring(k3+3,gmt.length);
return str;
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
	var myLeft = (screen.width-myWidth)/2;
	var myTop = (screen.height-myHeight)/2;
	features+=(features!='')?',':'';
	features+=',left='+myLeft+',top='+myTop;
	var aw = screen.availWidth;
	var ah = screen.availHeight;
	}

	poplog = window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	poplog.focus();
	}
function mailtocryp(name) {
document.location.href="mailto:" + name + "@logmedia.at";
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function connector(){
SetCookie('portalselect',document.login.portalselect.value);
SetCookie('username',document.login.username.value);
 if(document.login.portalselect.value==''){
 	alert('Bitte geben Sie noch an, bei welchem Service Sie sich einloggen m'+unescape("%F6")+'chten.');
	return false;
 }
 if(document.login.username.value==''){
 	alert('Bitte geben Sie noch Ihren Benutzernamen f'+unescape("%FC")+'r das gew'+unescape("%E4")+'hlte Service an.');
	document.login.username.focus();
	return false;
 }
 if(document.login.password.value==''){
 	alert('Bitte geben Sie noch Ihr Passwort f'+unescape("%FC")+'r das gew'+unescape("%E4")+'hlte Service an.');
	document.login.password.focus();
	return false;
 }
 if(document.login.portalselect.value=='mc'){
 	document.login.action = 'https://sslproxy.hostprofis.com/81.223.40.11/index.php?action=Login';
	document.login.submit();
 }
 else if(document.login.portalselect.value=='eshop'){
	document.login.username.name = 'email';
 	document.login.action = 'https://ssl.log2pay.com/eshop/login/';
	document.login.submit();
 }
 else if(document.login.portalselect.value=='yoogate'){
 	document.login.action = 'http://www.yoogate.com/login.php';
	document.login.submit();
 }
 else if(document.login.portalselect.value=='spamcleaner'){
 	document.login.username.name = 'email';
 	document.login.action = 'http://spamcleaner.antispamservice.at/?p=login';
	document.login.submit();
 }
}
function decryptString(enc,offset)	{
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}
