var anzeigeelement = null;
//function altnation(){
//
//    $$('.nation').each(function(item){
//        item.ovalue = item.getParent().getElement('.other').getProperty('value');
//        if(item.getProperty('value') == 1){
//            item.set('name')
//            item.set('value',);
//            alert(item.getProperty('value'));
//        }
//    });
//}


window.addEvent('domready', function() {


/*
 * Shop-Detail
 */

$$('.detail_pic').each(function(item,index){
    item.setStyle('z-index',100 - index);
});



/*
 * Shop-Form
 **/

$$('.nation').each(function(item,index){

    item.other = item.getParent().getElement('.other');
    item.fname = item.getProperty('name');

    if(item.getProperty('value') == '1'){
            item.other.setStyle('display','block');
            item.other.set('name',item.getProperty('name'));
            item.set('name','em');
    }


    item.addEvent('change',function(){
        if(this.getProperty('value') == '1'){
            this.other.setStyle('display','block');
            item.other.set('name',item.fname);
            item.set('name','em');
        }else{
            this.other.setStyle('display','none');
            item.set('name',item.fname);
            item.other.set('name','em');

        }
    });
});









    /**
* ### SHOP AGB ###
**/

if( $('IpButton') != null && $('ConfirmButton') != null ) {
	$('IpButton').setProperty('checked',false);
	$('IpButton').addEvents({
    		'change': function(){
			if( this.getProperty('checked') == true && $('payment').getProperty('value') != 0 ){
                       
				$('ConfirmButton').setProperty('href', this.getProperty('value')+'&payment='+ $('payment').getProperty('value'));
			}else{
				$('ConfirmButton').removeProperty('href');

			}
		}
	});
        $('payment').addEvents({
            'change': function(){
                if( $('IpButton').getProperty('checked') == true && $('payment').getProperty('value') != 0 ){
				$('ConfirmButton').setProperty('href', $('IpButton').getProperty('value')+'&payment='+ $('payment').getProperty('value'));
			}else{
				$('ConfirmButton').removeProperty('href');

			}
            }
        });


}


$$('a[rel*=external]').each(function(element){
    
	var link = element;
        //alert(link);
	if( link != null ){
		link.addEvents({
    			'click': function(e){
				e.stop();
				var href = this.getProperty('href');
				//href = href + '?type=5';
				Mediabox.open(href ,"","800 600");
			}
		});
	}
});















	$$('div.mitarbeiter').addEvents({
    		'mouseover': function(){
					this.set('tween', {duration: 200});
					this.tween('background-color', '#ebf0b6');
			},
			'mouseout': function(){
					this.set('tween', {duration: 300});
					this.tween('background-color', '#ffffff');
				},
		'click': function(){
				var textdiv = this.getChildren('div.mitarbeiterhidden');
				if( anzeigeelement != null ){
					$('mitarbeiteranzeige').set('html',textdiv.get('html'));
				}else{
					anzeigeelement = new Element('div', {
						'id' : 'mitarbeiteranzeige',
						'html' : textdiv.get('html')
					});
					$('Content').adopt(anzeigeelement );
				}
			}
	});
	$$('div.ct_linkbox').addEvents({
		'click': function(){
			var link = this.getElements('a');
			for (var i = 0;i<link.length;i++)
			{
 				if( link[i].getProperty('html') == 'findmylink' ){
					if( link[i].getProperty('target') == '_blank' ){
 						var newWindow = window.open(link[i].getProperty('href'), '_blank');
 						newWindow.focus();
						return false;
					}else{
						window.location.href = link[i].getProperty('href');
					}
				}
			}
	 	},
		'mouseover': function(){
			this.set('tween', {duration: 200});
			this.tween('background-color', '#ebf0b6');
			//this.setStyle('background-color','#90C131');
	 	},
		'mouseleave': function(){
			this.set('tween', {duration: 500});
			this.tween('background-color', '#ffffff');
	 		//this.setStyle('background-color','#c9df94');
		}
	});

});
