var animating = false;
function c5a_black(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_hdiw_black').style.display == 'none'){
			Effect.Appear($('content_hdiw_black'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_hdiw').hide();
			$('c5a_black').addClassName('sel');
		} else {
			Effect.Appear($('content_hdiw'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_hdiw_black').hide();
			$('c5a_black').removeClassName('sel');
		}
					
    }
}
function courses(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_pbe_courses').style.display == 'none'){
			Effect.Appear($('content_pbe_courses'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('courses').removeClassName('sel');
			$('s_courses').removeClassName('sel');
			$('content_pbe_main').hide();
			$('content_pbe_scourses').hide();
			$('courses').addClassName('sel');
		} else {
			Effect.Appear($('content_pbe_main'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_pbe_courses').hide();
			$('content_pbe_scourses').hide();
			$('courses').removeClassName('sel');
			$('s_courses').removeClassName('sel');
		}
					
    }
}
function s_courses(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_pbe_scourses').style.display == 'none'){
			Effect.Appear($('content_pbe_scourses'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('courses').removeClassName('sel');
			$('s_courses').removeClassName('sel');
			$('content_pbe_main').hide();
			$('content_pbe_courses').hide();
			$('s_courses').addClassName('sel');
		} else {
			Effect.Appear($('content_pbe_main'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_pbe_courses').hide();
			$('content_pbe_scourses').hide();
			$('courses').removeClassName('sel');
			$('s_courses').removeClassName('sel');
		}
					
    }
}
function pers_mark(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('pm_nav').style.display == 'none'){
			Effect.Appear($('content_iyb_pm'), { duration: 0.85, afterFinish: function() { 
					animating = false;
					Effect.BlindDown($('pm_nav'));
					$('pers_mark').setStyle({backgroundImage: 'url(/_en/_gb/partner/img/personalised_marketing_down.gif)'});
				} });
			removeClassSubNav();
			$('pers_mark').addClassName('sel');
			$('merch').removeClassName('sel');
			$('myst_client').removeClassName('sel');
			$('own_mag').removeClassName('sel');
			hideAllIYB();
		} else {
			Effect.BlindUp($('pm_nav'), { duration: 0.85, afterFinish: function() { 
					animating = false;
					Effect.Appear($('content_iyb_pm'),{duration:0.85});
					$('pers_mark').setStyle({backgroundImage: 'url(/_en/_gb/partner/img/personalised_marketing.gif)'});
				} });
			removeClassSubNav();
			$('pers_mark').addClassName('sel');
			$('merch').removeClassName('sel');
			$('myst_client').removeClassName('sel');
			$('own_mag').removeClassName('sel');
			hideAllIYB();
		}
					
    }
}
function merch(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('merch_nav').style.display == 'none'){
			Effect.Appear($('content_iyb_merch_2'), { duration: 0.85, afterFinish: function() { 
					animating = false;
					Effect.BlindDown($('merch_nav'));
					$('merch_nav2').addClassName('sel');
					$('merch').setStyle({backgroundImage: 'url(/_en/_gb/partner/img/merchandising_down.gif)'});
				} });
			removeClassSubNav();
			//$('merch').addClassName('sel');
			$('pers_mark').removeClassName('sel');
			$('myst_client').removeClassName('sel');
			$('own_mag').removeClassName('sel');
			hideAllIYB();
		} else {
			Effect.BlindUp($('merch_nav'), { duration: 0.85, afterFinish: function() { 
					animating = false;
					Effect.Appear($('content_iyb_merch_2'),{duration:0.85});
					$('merch').setStyle({backgroundImage: 'url(/_en/_gb/partner/img/merchandising.gif)'});
				} });
			removeClassSubNav();
			//$('merch').addClassName('sel');
			$('pers_mark').removeClassName('sel');
			$('myst_client').removeClassName('sel');
			$('own_mag').removeClassName('sel');
			hideAllIYB();
		}
					
    }
}
function myst_client(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_iyb_myst').style.display == 'none'){
			Effect.Appear($('content_iyb_myst'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			removeClassSubNav();
			hideAllIYB();
			$('myst_client').addClassName('sel');
			$('pers_mark').removeClassName('sel');
			$('merch').removeClassName('sel');
			$('own_mag').removeClassName('sel');
		} else {
			animating = false;
		}

    }
}
function own_mag(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_iyb_own').style.display == 'none'){
			Effect.Appear($('content_iyb_own'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			removeClassSubNav();
			hideAllIYB();
			$('own_mag').addClassName('sel');
			$('pers_mark').removeClassName('sel');
			$('merch').removeClassName('sel');
			$('myst_client').removeClassName('sel');
		} else {
			animating = false;
		}

    }
}
function gifts(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_mys_1').style.display == 'none'){
			Effect.Appear($('content_mys_1'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_mys_2').hide();
			$('gifts').addClassName('sel');
			$('incentive').removeClassName('sel');
		} else{
			animating = false;
		}
					
    }
}
function incentive(e) {
    Event.stop(e);
	
    if (!animating) {
        animating = true;
       
		if($('content_mys_2').style.display == 'none'){
			Effect.Appear($('content_mys_2'), { duration: 0.85, afterFinish: function() { 
					animating = false;
				} });
			$('content_mys_1').hide();
			$('incentive').addClassName('sel');
			$('gifts').removeClassName('sel');
		} else{
			animating = false;
		}
					
    }
}
function removeClassSubNav(){
	var g = 1
	for (g=1;g<7;g++){
		$('pm_nav'+g).removeClassName('sel');
	}
	var i = 2
	for (i=2;i<3;i++){
		$('merch_nav'+i).removeClassName('sel');
	}
}
function hideAllIYB(){
	iyp_blocks = $('iyb').select('div.content');

	iyp_blocks.each(function(item) {
			$(item.id).hide();
		});
}
function showContent(type,section){
	hideAllIYB();
	Effect.Appear($('content_iyb_'+type+'_'+section), {duration:0.85});
	if(type=='pm'){
		var g = 1
		for (g=1;g<7;g++){
			$('pm_nav'+g).removeClassName('sel');
		}
		var i = 2
		for (i=2;i<3;i++){
			$('merch_nav'+i).removeClassName('sel');
		}
		$('pm_nav'+section).addClassName('sel');
		$('merch').removeClassName('sel');
		$('myst_client').removeClassName('sel');
		$('pers_mark').addClassName('sel');
		
		if($('pm_nav').style.display == 'none'){
			Effect.BlindDown($('pm_nav'),{duration:0.85})
		}
	} else if(type=='merch'){
		var g = 2
		for (g=2;g<3;g++){
			$('merch_nav'+g).removeClassName('sel');
		}
		var i = 1
		for (i=1;i<7;i++){
			$('pm_nav'+i).removeClassName('sel');
		}
		$('pers_mark').removeClassName('sel');
		$('merch_nav'+section).addClassName('sel');
		$('merch').addClassName('sel');
		$('myst_client').removeClassName('sel');
	}
	return false;
}
function openForm(url, name, popupWidth, popupHeight) {
	var winl = (screen.width - popupWidth) / 2;
	var wint = (screen.height - popupHeight) / 2;
	var name2 = name.replace(' ','');
	name2=name2.replace('-','');
		
	newWindow = window.open(url, name2, ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
	newWindow.focus();
}
function initialize()
{
    if($('c5a_black') != null){Event.observe('c5a_black', 'click', c5a_black, false);}
	if($('courses') != null){Event.observe('courses', 'click', courses, false);}
	if($('s_courses') != null){Event.observe('s_courses', 'click', s_courses, false);}
	if($('pers_mark') != null){Event.observe('pers_mark', 'click', pers_mark, false);}
	if($('merch') != null){Event.observe('merch', 'click', merch, false);}
	if($('myst_client') != null){Event.observe('myst_client', 'click', myst_client, false);}
	if($('own_mag') != null){Event.observe('own_mag', 'click', own_mag, false);}
	if($('gifts') != null){Event.observe('gifts', 'click', gifts, false);}
	if($('incentive') != null){Event.observe('incentive', 'click', incentive, false);}
}
Event.observe(window, 'load', initialize, false);
