// JavaScript Document

if (top.location != self.location) {
top.location = self.location.href
}

$(document).ready(function() {
$('#head_menue > li').bind('mouseover', jsddm_open);
$('#head_menue > li').bind('mouseout', jsddm_timer);
});

document.onclick = jsddm_close;

// Menue
var men_closetimer = 0;
var men_ddmenuitem = 0;

function jsddm_open() { 
jsddm_canceltimer();
jsddm_close();
men_ddmenuitem = $(this).find('ul').css('visibility', 'visible');
};

function jsddm_close() { 
if (men_ddmenuitem) { men_ddmenuitem.css('visibility', 'hidden'); }
};

function jsddm_timer() {
men_closetimer = window.setTimeout(jsddm_close, 500);
};

function jsddm_canceltimer() {
if(men_closetimer) {
	window.clearTimeout(men_closetimer);
    men_closetimer = null;
}
};

function reloaden() {
eval (ReloadFunktion);
}

function load_section(Section, Category, Sort, Page, Genre, Lang) {
$.ajaxSetup( { timeout: 50000, error: function(xhr) { $('#cdata').html('<center style="font-size:11px;"><br><img src="image/reload.png" style="cursor:pointer;" onClick="reloaden();"><br><br>Die Anfrage brauchte zu lange, um zu antworten.<br>Bitte wiederhole den Vorgang.<br><br></center>'); } } );
/* window.location.href='#'; */
ReloadFunktion = "load_section('"+Section+"','"+Category+"','"+Sort+"','"+Page+"');";
$('#cdata').html('<div class="content_box_head">&nbsp;&nbsp;&nbsp;Loading...</div><center style="font-size:11px;"><br><img src="image/loader.gif"><br><br>Daten werden geladen...<br><br></center>');
$.ajax( { 
url: "ajax/section.php",	
type: "GET",
data: 'Section='+Section+'&Category='+Category+'&Sort='+Sort+'&Page='+Page+'&Genre='+Genre+'&Lang='+Lang,		
success: function(phpData) { 
$('#cdata').html(phpData);
}
}
);
}

function load_news(Datum) {
$.ajaxSetup( { timeout: 50000, error: function(xhr) { $('#cdata').html('<center style="font-size:11px;"><br><img src="image/reload.png" style="cursor:pointer;" onClick="reloaden();"><br><br>Die Anfrage brauchte zu lange, um zu antworten.<br>Bitte wiederhole den Vorgang.<br><br></center>'); } } );
/* window.location.href='#'; */
ReloadFunktion = "load_news('"+Datum+"');";
$('#cdata').html('<div class="content_box_head">&nbsp;&nbsp;Loading...</div><center style="font-size:11px;"><br><img src="image/loader.gif"><br><br>Updates werden geladen !<br><br></center>');
$.ajax( { 
url: "ajax/updates.php",	
type: "GET",
data: 'Day='+Datum,		
success: function(phpData) { 
$('#cdata').html(phpData);
}
}
);
}

function save_dltyp() {
var sTime = new Date();
sTime = new Date(sTime.getTime() +1000*60*60*24*365);
var cDDL = $('#sDDL:checked').val();
var cED2K = $('#sED2K:checked').val();
if (cDDL==undefined || cED2K==undefined) {
if (cDDL==undefined) { document.cookie = 'cDDL=0; expires='+sTime.toGMTString()+';'; }
else { document.cookie = 'cDDL='+cDDL+'; expires='+sTime.toGMTString()+';'; }
if (cED2K==undefined) { document.cookie = 'cED2K=0; expires='+sTime.toGMTString()+';'; }
else { document.cookie = 'cED2K='+cED2K+'; expires='+sTime.toGMTString()+';'; }
}
else { document.cookie = 'cDDL=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; document.cookie = 'cED2K=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; }
if (cDDL==undefined && cED2K==undefined) { document.cookie = 'cDDL=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; document.cookie = 'cED2K=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; }
location.reload();
}
 
// Einloggen
function m_login() {		
var user = $('input[name=uname]');
var pass = $('input[name=upass]');
var doing = $('input[name=doing]');
var data = 'doing='+doing.val()+'&user='+user.val()+'&pass='+pass.val(); 
$.ajax({
	url: "ajax/login.php",	
	type: "POST",
	data: data,		
    success: function (reqCode) {
	if (reqCode=="true") {
	window.location.href='?';
	}
	else {
	alert(''+reqCode+'');
	}
	}		
});
return false;
};

function load_Cats() {
$('#CatLoad').html('Loading...');
var sSection = $('select[name=Section]').val();
$.ajax( { 
url: "ajax/categories.php",	
type: "GET",
data: 'Section='+sSection,		
success: function(phpData) { 
$('#CatLoad').html(phpData);
}
}
);
}

function load_Search() {
$.ajaxSetup( { timeout: 50000, error: function(xhr) { $('#cdata').html('<center style="font-size:11px;"><br><img src="image/reload.png" style="cursor:pointer;" onClick="reloaden();"><br><br>Die Anfrage brauchte zu lange, um zu antworten.<br>Bitte wiederhole den Vorgang.<br><br></center>'); } } );
ReloadFunktion = "load_Search();";
$('#cdata').html('<div class="content_box_head">&nbsp;&nbsp;Loading...</div><center style="font-size:11px;"><br><img src="image/loader.gif"><br><br>Suche läuft ...<br><br></center>');
var sSuchbegriff = $('input[name=Suchbegriff]').val();
var sSection = $('select[name=Section]').val();
var sCategory = $('select[name=Category]').val();
var sGenau = $("input:radio:checked[name='oGenau']").val()
var sDDL = $('#oDDL:checked').val();
var sED2K = $('#oED2K:checked').val();
$.ajax( { 
url: "ajax/search.php",	
type: "POST",
data: 'Suchbegriff='+sSuchbegriff+'&Section='+sSection+'&Category='+sCategory+'&Genau='+sGenau+'&DDL='+sDDL+'&ED2K='+sED2K,		
success: function(phpData) { 
$('#cdata').html(phpData);
$('input[name=Suchbegriff]').focus();
}
}
);
return false;
}

function load_archiv_calender(sMonat, sJahr) {
$('#calender_loading').html('<img src="image/loader.gif">');
var ajxFile = "ajax/newscalender.php";
$.ajax( { 
	   type: "GET", 
	   url: ajxFile, 
	   data: "Monat="+sMonat+"&Jahr="+sJahr, 
	   success: function(phpData) {
	   $('#archiv_calender').html(phpData);
	   $('#archiv_calender').show('fast');
	   }
	   }
	   );   
}

function load_archiv_entries(Datum) {
$.ajaxSetup( { timeout: 50000, error: function(xhr) { $('#cdata').html('<center style="font-size:11px;"><br><img src="image/reload.png" style="cursor:pointer;" onClick="reloaden();"><br><br>Die Anfrage brauchte zu lange, um zu antworten.<br>Bitte wiederhole den Vorgang.<br><br></center>'); } } );
/* window.location.href='#'; */
ReloadFunktion = "load_archiv_entries('"+Datum+"');";
$('#cdata').html('<div class="content_box_head">&nbsp;&nbsp;Loading...</div><center style="font-size:11px;"><br><img src="image/loader.gif"><br><br>Updates werden geladen !<br><br></center>');
$.ajax( { 
url: "ajax/newsarchiv.php",	
type: "GET",
data: 'Day='+Datum,		
success: function(phpData) { 
$('#cdata').html(phpData);
}
}
);
}

function load_Stream(Stream) {
$('#streamdata').html('<center><br><br><img src="image/streamloader.gif"><br><br></center>');
$('#streamdata').show();
$.post("ajax/streams.php", { Stream: Stream }, function(phpData) { $("#streamdata").html(phpData); });
}

function ldD(ID) { $.post("ajax/lddl.php", { ID: ID }, function(Link) { window.open(Link, ID, ''); }); }

