
jQuery.noConflict();


function animated (el_id) {
	var prev_im = null;
	var im1 = null;
	var im2 = null;
	this._init_anim(el_id);
	var last_anim = null;
	var clr = 0;
}




var rollovers = new Hash();
make_active = function (el){
	var all_elms = el.up().childElements();
	all_elms.each( function (s) {
		s.removeClassName('active')}
	);
	el.addClassName('active');
}

highLht = function(el) {
		var toggle = function(tag,attrs){
			var gross = el.up('div').down(tag);
			var kleine = el.down(tag);
			if (!gross || !kleine) return;
			while (attrs.length) {
				var attr = attrs.shift();
				gross.setAttribute(attr, kleine.readAttribute(attr));
			}
		}
		if (!el || el.hasClassName('active')) return false;
		if (el.up().hasClassName('anim') && el.down('.img-cont')) {
			rollovers.get(el.up().id).animate(el.down('.img-cont'));
		} else {
			make_active(el);
			toggle('img',['src','alt']);
			toggle('a',['href']);
		}
}

displayHeadline = function() {
	if ($('headline-link')) { 

		$('headline').style.display='block';

	}
}

switchHeadline = function() {
	$('headline').style.display='none';
}



Event.observe(window, 'load', function() {
	if ($('one') && $('two')) {
		var vis = Math.round(Math.random());
		(vis ? $('one') : $('two')).setStyle({display:'block'});
		(vis ? $('two') : $('one')).remove();
	} 
	displayHeadline();
	var controls = $$('div.control');
	controls.each( function (s) {
		if (!s.up('.image') && !s.up('#video')) {
			s.observe('mouseup', function (event) {
				plus_minus(Event.findElement(event,'div') );
			} );
			var dnd = s.up('.drug-drop');
			if (dnd) {
				var headlines = dnd.down('.content');					
				if((headlines.up().id=='dd-style4') && (headlines.up().id=='dd-style1') )
					{rowcount = 7}
				else if( $( 'auto-page' ) != null ){
					rowcount = 4;
				} else
					{rowcount = 3};
				initList(headlines, getCookie(uniquepageid+"-c-"+headlines.up().id) == ''? rowcount : getCookie(uniquepageid+"-c-"+headlines.up().id));
			}
		} 
		//adjust(s)
	} );
	var rollovrs = $$('div.topic-top');
	rollovrs.each( function (s) {
		if (s.down('ul')) s.down('ul').observe('mouseover', function (event) {
			highLht(Event.findElement(event,'li'));
		} );
	} );
	if ($('hot-news') && !$('description')) $('hot-news').observe('mouseover', function(event) {
			highLht(Event.findElement(event,'H1'));
		}
	);
	$$('ul.anim').each( function (s) {
			if (s.empty()) return;
			var first = s.childElements()[0]; 
			first.addClassName('active');
			first.down('.img-cont').setStyle({height:'auto'});
			if ($('polit-page')) {
				first.removeClassName('active');
				first.down('.img-cont').setStyle({height:'0pt'});
			}
			if (s.hasClassName('dormouse')) return;
			s.setAttribute('id','a_' + s.up('.drug-drop').id);
			rollovers.set (s.id, new animated(s.id));
			s.observe('mouseover', function(event) {
				highLht(Event.findElement(event,'li'));
			} )
			s.up('.content').observe('mouseout', function(event) {
				stopAnim(event,s);
			} )
		}
	);
	var collapses = $$('div.collapse');
	collapses.each( function (s) {
		var slider = s.up('.drug-drop').down('.content');
		slider.setAttribute('id','c_' + s.up('.drug-drop').id);
		slider.setStyle({zoom:1});
		collapse_animation.set (slider.id, new animatedcollapse(slider.id, 400, true));
		s.observe('mouseup', function (event) {
			collapse(Event.findElement(event,'div') );
		} );
		if (collapse_animation.get(slider.id).isExpanded == 'no'){
			s.removeClassName('collapse');
			s.addClassName('collapsed');
		}
	} );


 	if ($('sidebarOne')) $('sidebarOne').setStyle({display:'block'});
 	if ($('sidebarTwo')) $('sidebarTwo').setStyle({display:'block'});
 	if ($('sidebarThree')) $('sidebarThree').setStyle({display:'block'});
	//setTimeout(load_adverts,100);
	var i = 0;
	$$('div.ad-body').each(function(s){
		var a = s.down('iframe');
		if (a) {
			a.setAttribute('id','resz' + i++);
			Event.observe(a, 'load', function() { 
				resize_frame(a.id); 
			});
		}
	});
	jQuery(".video-text").click( function(){
		location.href = jQuery(".video-text").prev().attr("href");
	} );
} );


