/*
*********************************************************************
Language:       Javascript 1.5
Web Site:       http://www.mainememory.net/
Copyright:      &copy;2008 Jmaie Peloquin <http://www.jamiepeloquin.com>
Created by:     Jamie Peloquin
*********************************************************************
*******************************************************************
Javascript worksheet
*******************************************************************
*/
var MHS;
if (typeof MHS == "undefined") { MHS = {}; }

// << Pop Windows using REL
//    Use rel="popup" in anchor links to open link in a new window
//    Use rel="popup_mov" to get a movie-sized popup instead.
function externalLinks() { 
    if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) { 
	var anchor = anchors[i]; 
	if ( anchor.getAttribute("href") ) {
	    if ( anchor.getAttribute("rel") == "popup" ) {
		anchor.target = "_blank"; 
	    }
	    else if ( anchor.getAttribute("rel") == "popup_mov" ) {
		anchor.onclick = openMovieWindow;
	    }
	} 
    }
}

function openMovieWindow( event ) {
    // Open the target in a small and limited-UI window.
    pop_generic(
		'fwee',
		event.target.getAttribute('href'),
		400,
		400,
		'no',
		'no',
		'no',
		'no',
		'no',
		'no'
		);
    return false;
}

window.onload = externalLinks;
// >>

/* Pop Window Generic - Centered --------------------------------- */
/* EXAMPLE
<a onclick="pop_generic('NewWin','http://www.axondm.com','800','600','no','no','no','yes','yes','yes');return false;" href="http://www.axondm.com" title="Open in a new window (Javascript)">http://www.axondm.com</a>
*/
function pop_generic(NAME,URL,WD,HT,TOOL,LOCATION,MENU,SCROLL,STATUS,RESIZE){
	if(!NAME){NAME = "genWin"}
	if(!WD){WD = "780"}
	if(!HT){HT = "500"}
	if(!TOOL){TOOL = "yes"}
	if(!LOCATION){LOCATION = "yes"}
	if(!MENU){MENU = "yes"}
	if(!SCROLL){SCROLL = "yes"}
	if(!STATUS){STATUS = "yes"}
	if(!RESIZE){RESIZE = "yes"}
	var halfW = (WD/2)
 	var halfH = (HT/2)
   	var screenW = screen.availWidth
    var screenH = screen.availHeight
    
    var screenX = ((screenW / 2) - halfW) // is half the width of the window
    var screenY = ((screenH / 2) - halfH) // is half the height of the window
	
	var WINNAME = NAME+'_win'
	if(document.layers){ //Fixes Netscape 4 bug
    	var NAME = window.open(URL, WINNAME);
	}
	else{
		var NAME = window.open(URL, WINNAME, 'width='+WD+', height='+HT+', top='+screenY+', left='+screenX+', toolbar='+TOOL+', location='+LOCATION+', menubar='+MENU+', scrollbars='+SCROLL+', status='+STATUS+', resizable='+RESIZE);
    }
    NAME.focus();
}//END

/* Reset Form Input Field */
function form_input_reset($ID) {
    $ID.value = '';
}

/* Submit Form --------------------------------------------------- */
function form_submit($FORM) {
	document.getElementById($FORM).submit();
}

/* Confirm Delete ------------------------------------------------- */
/* Added by ADH - 7/14/05 ---------------------------------------- */
function confirm_delete(item_name) {
    var agree=confirm("Are you sure you want to delete this " + item_name + "?");
    if (agree) return true;
    else return false;
}

/* CSS CONTROL --------------------------------------------------- */
// << BEGIN: Toggle Display
function cssToggleDisplay(OID,DISP) {
	// OID = Object's ID
	// DISP = block, inline, list-item
	var thisOID = document.getElementById(OID);
	if(thisOID.style.display == "none"){
		thisOID.style.display=DISP;
	}
	else{
		thisOID.style.display="none";
	}
}
// >> END: Toggle Display

// << BEGIN: Toggle Visibility ON
function cssToggleVisibilityOn(OID) {
	// OID = Object's ID
	var thisOID = document.getElementById(OID);
	thisOID.style.visibility="visible";
}
// >> END: Toggle Visibility ON

// << BEGIN: Toggle Visibility OFF
function cssToggleVisibilityOff(OID) {
	// OID = Object's ID
	var thisOID = document.getElementById(OID);
	thisOID.style.visibility="hidden";
}
// >> END: Toggle Visibility OFF

MHS.AlbumToolbar = function() {
    var D = YAHOO.util.Dom;
    var E = YAHOO.util.Event;

    var elTab;
    var elDrawer;

    var animOpen;
    var animClose;

    function toggleDrawer(e) {
        E.stopEvent(e);

        if (D.getStyle(elDrawer, 'width') == '401px') {
            animClose.animate();
        }
        else {
            animOpen.animate();
        }
    }

    return {
        toggleDrawer : toggleDrawer,
        init : function() {
            elTab    = D.get('album_drawer_tab');
            elDrawer = D.get('mycollection_drawer');

            E.addListener(elTab, 'click', MHS.AlbumToolbar.toggleDrawer);

            animOpen = new YAHOO.util.Anim( elDrawer, { width: { to: 401}, left : { to : -402 } }, 0.5 );
            animClose = new YAHOO.util.Anim( elDrawer, { width: { to: 31}, left : { to : -32 } }, 0.5 );
        }
    };
}();
YAHOO.util.Event.onDOMReady( MHS.AlbumToolbar.init );
