
    //window.onbeforeunload = function() {return true;};

	function update_layout_selection(id) {
        var oSelector = document.getElementById('page_layouts_select_list');
        for (a=0;a<oSelector.options.length;a++) {
            if(oSelector.options[a].value==id) {
                oSelector.selectedIndex = a;
                break;
            }
        }
        oSelector.onchange(); //for some reason changing the value using selectedIndex doesn't fire onchange...
    }


	function tog(element) {
        element.toggle = (element.toggle)?(false):(true);
        return element.toggle;
    }
    
	function snap(elementID) {
		oElement = document.getElementById(elementID);
		offsetHeight = oElement.offsetHeight; 
		iheight = oElement.style.height; 
		iheight = (!offsetHeight)?(iheight):(offsetHeight);
		iheight += 'px';
		//animation
		$('#scroll').animate({ height: iheight}, 'fast');				
		//no animation
		//oScroll = document.getElementById('scroll');
		//oScroll.style.height = iheight;
		oTrack = document.getElementById('lastclicked');
		oTrack.value = elementID;
	} // * * *

	function toggle_menu(direction) {
		var result = false;
		if(direction) {
			$('#admin_menu_container').addClass('menu').animate({ marginLeft:0}, 'fast');
			$('.cs_content').animate({ width:680}, 'fast');
			$('.row').animate({ width:670}, 'fast');
			$('#primary_navigation').animate({ width:195}, 'fast');
			document.getElementById('cs_menu_title').innerHTML= "&laquo;Menu";
			
		} else {
			$('#admin_menu_container').addClass('menu').animate({ marginLeft:-220}, 'fast');
			$('.cs_content').animate({ width:850}, 'fast');
			$('.row').animate({ width:840}, 'fast');
			$('#primary_navigation').animate({ width:10}, 'fast');
			document.getElementById('cs_menu_title').innerHTML= "&raquo;";
			result = true;
		}
		return result;		
	} // * * *



	//REQUIRES global instantiation after body tag. Interstitial dependency... 
	function getDimensions() { //set up "cross browser" document dimensions
		this.IE=document.all && !window.opera;
		this.CommonBody = (document.compatMode=='CSS1Compat')?(document.documentElement):(document.body);
		this.CommonBody = (this.IE) ? (document.body) : (document.documentElement) //create reference to common body across doctypes
		this.scrollbarwidth=window.innerWidth-(this.CommonBody.offsetLeft+this.CommonBody.offsetWidth); //http://www.howtocreate.co.uk/emails/BrynDyment.html
		this.scrollbarwidth=(Number(this.scrollbarwidth))?(this.scrollbarwidth):(0);
		this.iScrollTop = (this.IE) ? (this.CommonBody.scrollTop) : (window.pageYOffset);
		this.iScrollLeft = (this.IE) ? (this.CommonBody.scrollLeft) : (window.pageXOffset);
		this.iDocWidth = (this.IE) ? (this.CommonBody.clientWidth) : (window.innerWidth-this.scrollbarwidth);
		this.iDocHeight = (this.IE) ? (this.CommonBody.clientHeight) : (window.innerHeight);
		this.iDocHeightComplete = (this.CommonBody.offsetHeight>this.CommonBody.scrollHeight) ? (this.CommonBody.offsetHeight) : (this.CommonBody.scrollHeight);
		this.posX=0;
		this.posY=0;
		this.lastX=this.posX;
		this.lastY=this.posY;
	} getDimensions.prototype = {
		refresh:function() {
			this.IE = document.all && !window.opera;
			this.CommonBody = (document.compatMode=='CSS1Compat') ? (document.documentElement) : (document.body) //create reference to common "body" across doctypes
			this.CommonBody = (this.IE) ? (document.body) : (document.documentElement) //create reference to common body across doctypes
			this.scrollbarwidth=window.innerWidth-(this.CommonBody.offsetLeft+this.CommonBody.offsetWidth); //http://www.howtocreate.co.uk/emails/BrynDyment.html
			this.scrollbarwidth=(Number(this.scrollbarwidth))?(this.scrollbarwidth):(0);
			this.iScrollTop = (this.IE) ? (this.CommonBody.scrollTop) : (window.pageYOffset);
			this.iScrollLeft = (this.IE) ? (this.CommonBody.scrollLeft) : (window.pageXOffset);
			this.iDocWidth = (this.IE) ? (this.CommonBody.clientWidth) : (window.innerWidth-this.scrollbarwidth);
			this.iDocHeight = (this.IE) ? (this.CommonBody.clientHeight) : (window.innerHeight);
			this.iDocHeightComplete = (this.CommonBody.offsetHeight>this.CommonBody.scrollHeight) ? (this.CommonBody.offsetHeight) : (this.CommonBody.scrollHeight);
		},
		coordinates:function(e,llTrackLast) {
			if (e.pageX || e.pageY) {
				this.posX = e.pageX;
				this.posY = e.pageY;
			} else if (e.clientX || e.clientY) {
				this.posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				this.posY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			} else {
				this.posX=0;
				this.posY=0;
			}
			if(llTrackLast) {
				this.lastX=this.posX;
				this.lastY=this.posY;
			}
		}
	} // * * *



	function tagAndClassPassThrough (oElement) { //simple 'get children by tag + class'
		//getElementsByTagAndClass 2/10/2009 2:53:00 PM +mlp. 
		//oTest = splints.$('element');
		//tagAndClassPassThrough(oTest); //have to manually add the function where needed.
		//oCollection = oTest.getElementsByTagAndClass('div','half');
		if (typeof(oElement.getElementsByTagAndClass)!=='function') {
		
			oElement.getElementsByTagAndClass = function (sTag,sClass) {
				//still working on this one...
				var oElements = oElement.getElementsByTagName(sTag);
				iElements = oElements.length;
				oCollection = [];
				for (var a=0; a<iElements; a++) {
					if(ClassFX.hasClass(oElements[a],sClass)) {
						oCollection.push(oElements[a]);
					}
				}
				return oCollection;
			}; 
			var getElementsByTagAndClass = function (sTag,sClass) {
				oElement.getElementsByTagAndClass(sTag,sClass);
			};
		}	
	} // * * *

    function mmmcookies() {
    } mmmcookies.prototype = {
        set:function ( id, value, expires ) {
            if ( !expires ) {
                expires = 7;
            }
    		var date = new Date();
    		date.setTime( date.getTime( ) + ( expires * 24 * 60 * 60 * 1000 ) );
    		expires = "expires=" + date.toGMTString();
        	document.cookie = id + "=" + value + ";" + expires + "; path=/;";
        },
        get:function ( id ) {
            var result = false;
        	var items = document.cookie.split(';');
            var limit = items.length;
            var item, id_value, item_id;
            for(var i=0; i<limit; i++) {
        		item = items[i];
                id_value = item.split('=');
                item_id = id_value[0].replace( /\s/g, "" );
                if(item_id==id) {
                    result = id_value[1];
                }
        	}
        	return result;
        },
        eat:function ( id ) {
        	this.set( id, "", -1 );
        }
	} // * * *

