// JavaScript Document
window.addEvent('domready', function() {
									 
$("wrapper").setOpacity(0);
$("body_wrapper").setOpacity(0);
$("navigation").setOpacity(0);

var fx1 =$("wrapper").effects({duration:3000, transition: Fx.Transitions.Quart.easeOut});	
var fx2 =$("body_wrapper").effects({duration:3000, transition: Fx.Transitions.Quart.easeOut});	
var fx3 =$("navigation").effects({duration:3000, transition: Fx.Transitions.Quart.easeOut});	

fx1.start.delay(1000,fx1,{
		'opacity':1
		});
fx2.start.delay(4000,fx2,{
		'opacity':1
		});
fx3.start.delay(4000,fx3,{
		'opacity':1
		});
									 
var tg1=1;
var tg2=0;
var tg3=0;
var tg4=0;
var tg5=0;
var tg6=0;
var tg7=0;
var tg8=0;

									 
Shadowbox.init({
        animate: false,
        overlayOpacity: 0.5 ,
        skipSetup: true // skip the automatic setup
    });

var pageContent = new Spry.Widget.HTMLPanel("mainPart",{evalScripts:true});
var newsContent = new Spry.Widget.HTMLPanel("rp_content",{evalScripts:true});
var recentTopicsContent = new Spry.Widget.HTMLPanel("recent_topics",{evalScripts:true});

pageContent.loadContent('frags/gallery.php');
newsContent.loadContent('frags/newsList.php');
recentTopicsContent.loadContent('frags/recentTopics.php');

$('logo').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/gallery.php');
	tg1=1;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_on.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";

});



$('btn_info').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/gallery.php');
	tg1=1;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_on.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";

});

$('btn_info').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('homePic').src="images/home_on.jpg";
});

$('btn_info').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg1!=1){
	$('homePic').src="images/home_off.jpg";
	}
});

$('btn_kurse').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/kurse.html');
	tg1=0;
    tg2=1;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_on.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('btn_kurse').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('kursePic').src="images/kurse_on.jpg";
});

$('btn_kurse').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg2!=1){
	$('kursePic').src="images/kurse_off.jpg";
	}
});

$('btn_preise').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/preise.html');
	tg1=0;
    tg2=0;
    tg3=1;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_on.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('btn_preise').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('preisePic').src="images/preise_on.jpg";
});

$('btn_preise').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg3!=1){
	$('preisePic').src="images/preise_off.jpg";
	}
});


$('btn_klettern').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/klettern.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=1;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('kletternPic').src="images/klettern_on.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('btn_klettern').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('kletternPic').src="images/klettern_on.jpg";
});

$('btn_klettern').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg4!=1){
	$('kletternPic').src="images/klettern_off.jpg";
	}
});
/*
$('btn_forum').addEvent('click', function(event) {
	event = new Event(event).stop();
	Shadowbox.open({
		title: "",		   
        player:     'iframe',
        content:    "http://forum.the-rock.de/",
        width:      982,
		height: 867
    });
});
*/
$('btn_cms').addEvent('click', function(event) {
	event = new Event(event).stop();
	Shadowbox.open({
		title: "",		   
        player:     'iframe',
        content:    "http://kletterhalle-karlsruhe.de/z-o.cms/rock_db/",
        width:      1000,
		height: 780
    });
});


$('btn_anfahrt').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/map.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=1;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_on.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('btn_anfahrt').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('anfahrtPic').src="images/anfahrt_on.jpg";
});

$('btn_anfahrt').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg5!=1){
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	}
});

$('btn_downloads').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/downloads.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=1;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_on.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});


$('kontakt_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/kontakt.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('partner_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/partner.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('datens_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
	pageContent.loadContent('frags/datenschutz.html');
	tg1=0;
    tg2=0;
    tg3=0;
    tg4=0;
    tg5=0;
    tg6=0;
    tg7=0;
    tg8=0;
	$('homePic').src="images/home_off.jpg";
	$('kursePic').src="images/kurse_off.jpg";
	$('preisePic').src="images/preise_off.jpg";
	$('anfahrtPic').src="images/anfahrt_off.jpg";
	$('kletternPic').src="images/klettern_off.jpg";
	$('downPic').src="images/down_off.jpg";
	$("mainPart").style.backgroundImage="url(images/content_back.jpg)";
});

$('btn_downloads').addEvent('mouseenter', function(event) {
	event = new Event(event).stop();
	$('downPic').src="images/down_on.jpg";
});

$('btn_downloads').addEvent('mouseleave', function(event) {
	event = new Event(event).stop();
	if(tg6!=1){
	$('downPic').src="images/down_off.jpg";
	}
});

tg_nl=0;
$('n_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
	if(tg_nl==0){
	$('nl_btn').style.backgroundImage="url(images/nl_btn_ak.gif)";
	$('nl_btn').style.height="63px";
	tg_nl=1;
	}else{
	$('nl_btn').style.backgroundImage="url(images/nl_btn.png)";
	$('nl_btn').style.height="23px";
	tg_nl=0;
	}
});

$('nletter').addEvent('click', function(event) {
	event = new Event(event).stop();
	$('nletter').value="";
     document.getElementById("gh").style.display="none";
});	


tgTab=0;

$('tabPic').addEvent('click', function(event) {
	event = new Event(event).stop();
	if(tgTab==0){
	$('tabPic').src="images/termine_tab.jpg";
	tgTab=1;
	var termineContent = new Spry.Widget.HTMLPanel("rp_content",{evalScripts:true});
    termineContent.loadContent('frags/termineList.php');
	}else{
	$('tabPic').src="images/news_tab.jpg";
	tgTab=0;
	var news2Content = new Spry.Widget.HTMLPanel("rp_content",{evalScripts:true});
    news2Content.loadContent('frags/newsList.php');
	}
});	


$('an_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
var str=$("nletter").value;	
if(str.indexOf("@")!=-1){
nlRequest();
}
});

$('ab_btn').addEvent('click', function(event) {
	event = new Event(event).stop();
var str=$("nletter").value;	
if(str.indexOf("@")!=-1){
nlDeactive();
}
});

function nlRequest(){
	XMLrequest=null;
	CreateRequest();
	var url="engine/newsletter_an.php?mail=" + $("nletter").value;
	XMLrequest.onreadystatechange=function(){
		if(XMLrequest.readyState==4 && XMLrequest.status==200){
			response=XMLrequest.responseText
			document.getElementById("nletter").value = response;
			document.getElementById("gh").style.display="block";
			$('nl_btn').style.backgroundImage="url(images/nl_btn.png)";
	        $('nl_btn').style.height="23px";
		}
			
	}
	XMLrequest.open("GET",url,true);
	XMLrequest.send(null);
	
}

function nlDeactive(){
	XMLrequest=null;
	CreateRequest();
	var url="engine/newsletter_ab.php?mail=" + $("nletter").value;
	XMLrequest.onreadystatechange=function(){
		if(XMLrequest.readyState==4 && XMLrequest.status==200){
			response=XMLrequest.responseText
			document.getElementById("nletter").value = response;
			document.getElementById("gh").style.display="block";
			$('nl_btn').style.backgroundImage="url(images/nl_btn.png)";
	        $('nl_btn').style.height="23px";
		}
			
	}
	XMLrequest.open("GET",url,true);
	XMLrequest.send(null);
	

}


XMLrequest=null;
function CreateRequest(){
	if (window.XMLHttpRequest && !(window.ActiveXObject)){
		XMLrequest=new XMLHttpRequest();
	}else if (window.ActiveXObject){
		XMLrequest=new ActiveXObject("MSXML2.XMLHTTP");
		if (XMLrequest==null){
			XMLrequest=new ActiveXobject("Microsoft.XMLHTTP");
		}
	}
}


});	


function goLink(catId){
var pageContentLink = new Spry.Widget.HTMLPanel("mainPart",{evalScripts:true});
pageContentLink.loadContent('frags/news.php?nid='+catId);
}

function goLinkAll(){
var pageContentLink = new Spry.Widget.HTMLPanel("mainPart",{evalScripts:true});
pageContentLink.loadContent('frags/archiveNews.php');
}

function goLinkAll2(){
var pageContentLink = new Spry.Widget.HTMLPanel("mainPart",{evalScripts:true});
pageContentLink.loadContent('frags/archiveTermine.php');
}

function openTopic(topic){
	Shadowbox.open({
		title: "",		   
        player:     'iframe',
        content:    topic,
        width:      982,
		height: 867
    });
}

