/**
* Released under the terms or MIT license:
*
* Copyright (c) Bajcic Dragan
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all 
* copies or substantial portions of the Software.
*/

var mt = Class.create();
mt.prototype = {
initialize: function(tabs_container,tabs_class) {
this.bgcolor='#EAEFFA';
this.activeColor='#ffffff';
this.tc=tabs_container;
this.tbClass=tabs_class;
this.elm  = $(tabs_container);
new Insertion.Top(this.elm,'<div id="tab-bar"></div>');
this.tabs = $$(tabs_class);
this.clear(this.tabs);
MT=this;
},
clear: function(tabs){
tabs.each(function(elm){
elm.setStyle({display:'none'});
});
},
makeActive: function(tab_id){
$(tab_id).setStyle({display:'block'});
$('mt-'+tab_id).setStyle({backgroundColor:MT.activeColor});
$$('div.mt-tab').each(function(elm){
if(elm.hasClassName('mt-tab-active')){
elm.removeClassName('mt-tab-active');
elm.setStyle({backgroundColor:MT.bgcolor});
}
});
$('mt-'+tab_id).addClassName('mt-tab-active');
},
addTab: function(tab_id,text){
new Insertion.Bottom($('tab-bar'),'<div id="mt-'+tab_id+'" class="mt-tab">'+text+'</div>');
var elmnt=$('mt-'+tab_id);
elmnt.setStyle({backgroundColor:this.bgcolor});
Event.observe(elmnt, 'click', function() {
window.mt.prototype.clear(MT.tabs);
window.mt.prototype.makeActive(tab_id,MT.tbClass);
});
Event.observe(elmnt, 'mouseover', function(nn) {
if(!elmnt.hasClassName('mt-tab-active')){
elmnt.setStyle({backgroundColor:MT.activeColor});
}
});
Event.observe(elmnt, 'mouseout', function(nn) {
if(!elmnt.hasClassName('mt-tab-active')){
elmnt.setStyle({backgroundColor:MT.bgcolor});
}
});
},
removeTabTitles: function(tabTitlesClass){
this.tabsTitles = $$(tabTitlesClass);
this.tabsTitles.each(function(elm){
elm.setStyle({display:'none'});
});
}
};

var mb = Class.create();
mb.prototype = {
initialize: function(tabs_container,tabs_class) {
this.bgcolor='#EAEFFA';
this.activeColor='#ffffff';
this.tc=tabs_container;
this.tbClass=tabs_class;
this.elm  = $(tabs_container);
new Insertion.Top(this.elm,'<div id="tab-bar2"></div>');
this.tabs = $$(tabs_class);
this.clear(this.tabs);
MB=this;
},
clear: function(tabs){
tabs.each(function(elm){
elm.setStyle({display:'none'});
});
},
makeActive: function(tab_id){
$(tab_id).setStyle({display:'block'});
$('mb-'+tab_id).setStyle({backgroundColor:MB.activeColor});
$$('div.mb-tab').each(function(elm){
if(elm.hasClassName('mb-tab-active')){
elm.removeClassName('mb-tab-active');
elm.setStyle({backgroundColor:MB.bgcolor});
}
});
$('mb-'+tab_id).addClassName('mb-tab-active');
},
addTab: function(tab_id,text){
new Insertion.Bottom($('tab-bar2'),'<div id="mb-'+tab_id+'" class="mb-tab">'+text+'</div>');
var elmnt=$('mb-'+tab_id);
elmnt.setStyle({backgroundColor:this.bgcolor});
Event.observe(elmnt, 'click', function() {
window.mb.prototype.clear(MB.tabs);
window.mb.prototype.makeActive(tab_id,MB.tbClass);
});
Event.observe(elmnt, 'mouseover', function(nn) {
if(!elmnt.hasClassName('mb-tab-active')){
elmnt.setStyle({backgroundColor:MB.activeColor});
}
});
Event.observe(elmnt, 'mouseout', function(nn) {
if(!elmnt.hasClassName('mb-tab-active')){
elmnt.setStyle({backgroundColor:MB.bgcolor});
}
});
},
removeTabTitles: function(tabTitlesClass){
this.tabsTitles = $$(tabTitlesClass);
this.tabsTitles.each(function(elm){
elm.setStyle({display:'none'});
});
}
};


var ft = Class.create();
ft.prototype = {
initialize: function(tabs_container,tabs_class) {
this.bgcolor='#EAEFFA';
this.activeColor='#ffffff';
this.tc=tabs_container;
this.tbClass=tabs_class;
this.elm  = $(tabs_container);
new Insertion.Top(this.elm,'<div id="tab-bar3"></div>');
this.tabs = $$(tabs_class);
this.clear(this.tabs);
FT=this;
},
clear: function(tabs){
tabs.each(function(elm){
elm.setStyle({display:'none'});
});
},
makeActive: function(tab_id){
$(tab_id).setStyle({display:'block'});
$('ft-'+tab_id).setStyle({backgroundColor:FT.activeColor});
$$('div.ft-tab').each(function(elm){
if(elm.hasClassName('ft-tab-active')){
elm.removeClassName('ft-tab-active');
elm.setStyle({backgroundColor:FT.bgcolor});
}
});
$('ft-'+tab_id).addClassName('ft-tab-active');
},
addTab: function(tab_id,text){
new Insertion.Bottom($('tab-bar3'),'<div id="ft-'+tab_id+'" class="ft-tab">'+text+'</div>');
var elmnt=$('ft-'+tab_id);
elmnt.setStyle({backgroundColor:this.bgcolor});
Event.observe(elmnt, 'click', function() {
window.ft.prototype.clear(FT.tabs);
window.ft.prototype.makeActive(tab_id,FT.tbClass);
});
Event.observe(elmnt, 'mouseover', function(nn) {
if(!elmnt.hasClassName('ft-tab-active')){
elmnt.setStyle({backgroundColor:FT.activeColor});
}
});
Event.observe(elmnt, 'mouseout', function(nn) {
if(!elmnt.hasClassName('ft-tab-active')){
elmnt.setStyle({backgroundColor:FT.bgcolor});
}
});
},
removeTabTitles: function(tabTitlesClass){
this.tabsTitles = $$(tabTitlesClass);
this.tabsTitles.each(function(elm){
elm.setStyle({display:'none'});
});
}
};

function forceDigiTVApp() {
    if (document.cookie.indexOf("digiTV_app=false") < 0) {
        if (!navigator.userAgent.match(/Linux/i)) {
            if ( Prototype.Browser.MobileSafari )  {
                setDigiTVCookies();
                if (confirm("Nachrichten auf DIGITALFERNSEHEN.de jetzt noch bequemer lesen - mit unserer Gratis-App DigiTV für iPhone, iPad und iPod touch. Einfach auf OK klicken, um mehr zu erfahren."))
                    window.location = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=491121979&mt=8";
            }   
	
	}
	
	}
}
	
	function setDigiTVCookies() {
    var tage = 30;
	var datum = new Date();
    datum.setTime(datum.getTime()+(tage*24*60*60*1000));
    var exp = "; exp="+ datum.toGMTString();
    document.cookie = "digiTV_app=false" + exp; 
}

forceDigiTVApp();
