// JavaScript Document
rage = {
    
    openRegion: function(region) {
        $('#region_toolbar_'+region).slideToggle('fast',function() {
                 if ($('#region_toolbar_'+region).is(":visible")) {
                    $('#region_toolbar_expander_'+region).addClass('expanded');
                 } else {
                    $('#region_toolbar_expander_'+region).removeClass('expanded');
                 }
            });
        if ($('#region_configuration_'+region).is(":visible")) {
            $('#region_configuration_'+region).slideToggle('fast');
         }
         if ($('#region_menu_'+region).is(":visible")) {
            $('#region_menu_'+region).slideToggle('fast');
        }
    },

    openToolbar: function(region) {        
         if ($('#region_configuration_'+region).is(":visible")) {
            $('#region_configuration_'+region).slideToggle('fast');
         }
         $('#region_menu_'+region).slideToggle('fast');
         
    },

    openConfiguration: function(region) {
        if ($('#region_menu_'+region).is(":visible")) {
            $('#region_menu_'+region).slideToggle('fast');
        }
                
        $('#region_configuration_'+region).slideToggle('fast');
      
    }

}
function getIframeID(el)
{
	var myTop;
	if (window.frameElement) { myTop = window.frameElement; } 
	else if (window.top) {
		myTop = window.top;
		var myURL = location.href;
		var iFs = myTop.document.getElementsByTagName('iframe');
		var x, i = iFs.length;
		while ( i-- ){
			x = iFs[i];
			if (x.src && x.src == myURL){
				myTop = x;
				break;
			}
		}
	}
	if (myTop){
		return(myTop.id);
	} else {
		return '';
	}
}

function checkInRageAdmin() {

	var frameID = getIframeID(this);
	
	if (frameID=='managepagecontent') {
		var currentRef = location.href;
		if (currentRef.indexOf('rage=true')<1) {
			currentRef = currentRef.indexOf('?')<1 ? currentRef+'?' : currentRef+'&';
			currentRef+='rage=true&';
			location.href =	currentRef;
		}		
	}
	
}

if ( window.addEventListener ) {
	window.addEventListener('load', checkInRageAdmin, false);
} else if ( target.attachEvent ) { 
	window.attachEvent("onload", checkInRageAdmin);
} else { 
	window["onload"] = checkInRageAdmin;
} 
