﻿/*
var newsTexts;
var news;
var moreLink1 = '</a><a href="javascript:showMore(';
var moreLink2 = '';
var lessLink1 = '</a><a href="javascript:showLess(';
var lessLink2 = '';

function initialize(){
	$$('div#footer_1 div.footer_col_2 div.csc-textpic-imagecolumn').setStyle('width', 130);
	$$('div#footer_1 div.footer_col_2 div.csc-textpic-imagecolumn:nth-child(3)').setStyle('width', 121);
}

function truncateNews() {
	news = $$('div#content_wrap_1 div#contents2 .news-list-item .news_list_text');
	if (news.length)
		newsTexts = new Array();
		
		if (document.location.href.indexOf('/it/') != -1) {
			moreLink2 += ');"><br /><span class="tt_news_list_more">+informazioni</span></a>';
			lessLink2 += ');"><br /><span class="tt_news_list_more">>chiudere</span></a>';
		}
		else {
			moreLink2 += ');"><br /><span class="tt_news_list_more">+information</span></a>';
			lessLink2 += ');"><br /><span class="tt_news_list_more">>schließen</span></a>';
		}
		
		var i = 0;
		news.each(function(el){
			newsTexts[i] = el.get('html');
			if (newsTexts[i].length > 450)
				el.set('html', newsTexts[i].substring(0,450)+moreLink1+i+moreLink2);
			i++;
		});
}

function showMore(i) {
	news[i].set('html', newsTexts[i]+lessLink1+i+lessLink2);
}

function showLess(i) {
	news[i].set('html', newsTexts[i].substring(0,450)+moreLink1+i+moreLink2);
}

*/


var onlypass = true;


//change the text below to reflect your own,
var before="Christmas!";
var current="Today is Christmas. Merry Christmas!";
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var days;
var hours;
var minutes;
var seconds;

function setNewsMoreLinks(){

	if (document.location.href.indexOf('/it/') != -1) {
		moreLinkTitle = '+informazioni';
		lessLinkTitle = '>chiudere';
	}
	else {
		moreLinkTitle = '+information';
		lessLinkTitle = '>schließen';
	}

	var moreLink = new Element('span', {
		'class': 'tt_news_list_more',
		'html': moreLinkTitle,
		'events': {
				'click': function(){
					if(this.get('html')==moreLinkTitle){
						this.getPrevious().setStyle('height','auto');
						this.set('html',lessLinkTitle);	
					}
					else{
						this.getPrevious().setStyle('height',72);
						this.set('html',moreLinkTitle);	
					}
				}
		}
	});
	
	$$('div#content_wrap_1 div#contents2 .news_list_text').each(function(item){
		moreLink.clone().cloneEvents(moreLink).inject(item, 'after');
	});

} 

function setMeta(){
	
	var metaImg = new Element('meta', {
		'property': 'og:image',
		'content': 'http://www.suedtirol-fenster.com/typo3temp/pics/3c24f5ecd0.jpg'
	});

	$$('head')[0].inject(metaImg, 'after');
}

function countdown(yr,m,d){
	theyear=yr;themonth=m;theday=d;
	var today=new Date();
	var todayy=today.getYear();
	if (todayy < 1000);
	todayy+=1900;
	var todaym=today.getMonth();
	var todayd=today.getDate();
	var todayh=today.getHours();
	var todaymin=today.getMinutes();
	var todaysec=today.getSeconds();
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
	futurestring=montharray[m-1]+" "+d+", "+yr;
	dd=Date.parse(futurestring)-Date.parse(todaystring);
	dday=Math.floor(dd/(60*60*1000*24)*1);
	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
	if (dday  < 10) { dday  = "0"+dday; }
	if (dhour < 10) { dhour = "0"+dhour; }
	if (dmin  < 10) { dmin  = "0"+dmin; }
	if (dsec  < 10) { dsec  = "0"+dsec; }
	
	if(dday==0&&dhour==0&&dmin==0&&dsec==1){
		document.forms.count.count2.value=current;
		return
	}
	else {
		var cd = document.getElementById('countdown');
		var cdh1 = cd.getElementsByTagName('h1');
		var iHTML = "<h1>"+cdh1[0].innerHTML+"</h1>";
		iHTML += "<table><tr class=\"numbers\"><td>"+dday+ "</td><td>:</td><td>"+dhour+"</td><td>:</td><td>"+dmin+"</td><td>:</td><td>"+dsec+"</td></tr>";
		iHTML += "<tr class=\"labels\"><td>"+days+"</td><td></td><td>"+hours+"</td><td></td><td>"+minutes+"</td><td></td><td>"+seconds+"</td></tr></table>";
		
		cd.innerHTML = iHTML;
	}
	setTimeout("countdown(theyear,themonth,theday,days,hours,minutes,seconds)",1000);
}

function setupGewinnSpiel(iscountdown,_days,_hours,_minutes,_seconds) {
	document.getElementById("content").removeChild(document.getElementById("menuLeftWrap"));
	document.getElementById("content_wrap_1").removeChild(document.getElementById("contents2"));
	document.getElementById("footer_1").removeChild(document.getElementById("contact"));
	document.getElementById("content_wrap_1").style.width = "100%";
	document.getElementById("top_picture").className += " gewinnSpiel";
	if (iscountdown) {
		days = _days;
		hours = _hours;
		minutes = _minutes;
		seconds = _seconds;
		countdown(2012,01,26);
	}
}

function addCssClass(id, cssClass) {
	document.getElementById("c"+id).className += " "+cssClass;
}


setMeta();		

window.addEvent('domready', function() {
	
	if($defined($('weiter1'))){
		$('weiter1').addEvent('click', function(event){
			if ($('frage1').get('rel')=='hid' && $('frage2').get('rel')=='hid' && $('frage3').get('rel')=='hid'){
				$('magus_antwort1').setStyle('display', 'none');
				$('magus_antwort4').setStyle('display', 'block');
			}
			else{
				$('magus_antwort1').setStyle('display', 'none');
				$('magus_frage').setStyle('display', 'block');	
				$('fragebg').set('src', 'fileadmin/templates/images/bg1.png');
			}
		});
	}
	
	if($defined($('weiter2'))){
		$('weiter2').addEvent('click', function(event){
			if ($('frage1').get('rel')=='hid' && $('frage2').get('rel')=='hid' && $('frage3').get('rel')=='hid'){
				$('magus_antwort2').setStyle('display', 'none');
				$('magus_antwort4').setStyle('display', 'block');
			}
			else{
				$('magus_antwort2').setStyle('display', 'none');
				$('magus_frage').setStyle('display', 'block');
				$('fragebg').set('src', 'fileadmin/templates/images/bg2.png');	
			}
		});
	}
	
	if($defined($('weiter3'))){
		$('weiter3').addEvent('click', function(event){
			if ($('frage1').get('rel')=='hid' && $('frage2').get('rel')=='hid' && $('frage3').get('rel')=='hid'){
				$('magus_antwort3').setStyle('display', 'none');
				$('magus_antwort4').setStyle('display', 'block');
			}
			else{
				$('magus_antwort3').setStyle('display', 'none');
				$('magus_frage').setStyle('display', 'block');	
				$('fragebg').set('src', 'fileadmin/templates/images/bg1.png');
			}
		});
	}
	

	if($defined($('frage1'))){
		$('frage1').addEvent('click', function(event){
			$('magus_antwort1').setStyle('display', 'block');
			$('magus_frage').setStyle('display', 'none');
			
			$('frage1').setStyle('background', '#61605f');
			$('frage1').set('rel', 'hid');
			$('frage1').setStyle('color', 'gray');
		
		});
	}
	if($defined($('frage2'))){
		$('frage2').addEvent('click', function(event){
			$('magus_antwort2').setStyle('display', 'block');
			$('magus_frage').setStyle('display', 'none');
			
			$('frage2').setStyle('background', '#61605f');
			$('frage2').set('rel', 'hid');
			$('frage2').setStyle('color', 'gray');
		
		});
	}
	
	if($defined($('frage3'))){
		$('frage3').addEvent('click', function(event){
			$('magus_antwort3').setStyle('display', 'block');
			$('magus_frage').setStyle('display', 'none');
			
			$('frage3').setStyle('background', '#61605f');
			$('frage3').set('rel', 'hid');
			$('frage3').setStyle('color', 'gray');
		
		});
	}
	
	
	
	
	
	
	
	
	if($defined($('contents3')) && $('contents3').get('html')==''){
		$('contents3').setStyle('display', 'none');
	}
	
	if($defined($('menu_2_div'))){
		$$('#menu_2_div a').each(function(item){
			if(item.get('html')=='ISO-bloc®'){
				item.set('html','ISO-bloc<sup>®</sup>');
			 };
		});
	}
	
	if($defined($$('div.news-list-item')[0])){
		setNewsMoreLinks();
	}
	
	if($defined($$('input#user')[0]) && onlypass){

		$$('input#pass')[0].addEvent('keyup', function() {
			
			
			
			var str = null;
			str = $$('input#pass')[0].value;
			
			
			
			if(str.indexOf('91B')!=-1){ $$('input#user')[0].set('value', 'user1'); }
			if(str.indexOf('7GS')!=-1){ $$('input#user')[0].set('value', 'user2'); }
			if(str.indexOf('R85')!=-1){ $$('input#user')[0].set('value', 'user3'); }
			if(str.indexOf('5QW')!=-1){ $$('input#user')[0].set('value', 'user4'); }
			if(str.indexOf('V2E')!=-1){ $$('input#user')[0].set('value', 'user5'); }
			if(str.indexOf('23Z')!=-1){ $$('input#user')[0].set('value', 'user6'); }
			if(str.indexOf('M8D')!=-1){ $$('input#user')[0].set('value', 'user7'); }
			if(str.indexOf('6L2')!=-1){ $$('input#user')[0].set('value', 'user8'); }
			if(str.indexOf('14N')!=-1){ $$('input#user')[0].set('value', 'user9'); }
			if(str.indexOf('ET2')!=-1){ $$('input#user')[0].set('value', 'user10'); }
			
			if(str.indexOf('48K')!=-1){ $$('input#user')[0].set('value', 'handler1'); }
			if(str.indexOf('72C')!=-1){ $$('input#user')[0].set('value', 'handler2'); }
			
			if(str.indexOf('56G')!=-1){ $$('input#user')[0].set('value', 'vertreter1'); }
			if(str.indexOf('41L')!=-1){ $$('input#user')[0].set('value', 'vertreter2'); }
		
	
		});
		if(Browser.Engine.trident){
			$$('input#user')[0].setStyle('visibility', 'hidden');
		}
		else{
			$$('input#user')[0].set('type', 'hidden');
		}
		
		$$('label[for=user]')[0].setStyle('display', 'none');
   }
});
	



	

