// include.js file for library of javascript functions

//////////////////////////////////////////////////////////////////////////////////
// popup function
	function popup( url, name, w, h, x, y, scroll, status )
	{	if( (name == "") || (name == null) )	    {	var Winname = "ClickAndScore";	}
		else	{	var Winname = name;     }
		if( (scroll == "") || (scroll == null) )	{	var scrollBar = "auto";	        }
		else	{	var scrollBar = scroll;	}
		if( (status == "") || (status == null) )	{	var statusBar = "no";	        }
		else	{	var statusBar = status;	}
		window.open(url, Winname, 'resizable=yes,menubar=no,toolbar=no,location=no,status='+statusBar+',scrollbars='+scrollBar+',width='+w+',height='+h+',left='+x+',top='+y);
	}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// help window function
	function helpWindow( URL )
	{	popup( URL, "Help", 500, 500, 300, 150, "auto", "yes" );
	}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// copy to clipboard function
	function copyToClipboard( sText )
	{	if( window.clipboardData )
		{	window.clipboardData.setData( "Text", sText );
		}
		else if( window.netscape )
		{	netscape.security.PrivilegeManager.enablePrivilege( 'UniversalXPConnect' );
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance( Components.interfaces.nsIClipboard );
			if( !clip )	return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance( Components.interfaces.nsITransferable );
			if( !trans )	return;
			trans.addDataFlavor( 'text/unicode' );
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance( Components.interfaces.nsISupportsString );
			var copyText = sText;
			str.data = copyText;
			trans.setTransferData( "text/unicode", str, copyText.length * 2 );
			var clipid = Components.interfaces.nsIClipboard;
			if( !clip )	return false;
			clip.setData( trans, null, clipid.kGlobalClipboard );
		}
		return false;
	}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// are you sure function
    function areYouSure( url, type, id )
    {   var answer = confirm( "Are you sure you want to delete " + type + " " + id + "?" );
        if( answer )
        {   document.location = url;
        }
    }
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// compute ezine code function
//////////////////////////////////////////////////////////////////////////////////
function computeCode( type )
{	var elemDate = document.getElementById( type + 'Date' ).value;
	var elemType = document.getElementById( type + 'Type' ).value;
	var elemCode = document.getElementById( type + 'Code' );
	var re = new RegExp( '\/', 'gi' );
	var newstr = elemDate.replace( re, '' );
	if( elemType == 1 )
		elemCode.value = "r" + newstr;
	if( elemType == 2 )
		elemCode.value = "s" + newstr;
}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// divShowAndHide function
//////////////////////////////////////////////////////////////////////////////////
function divShowAndHide( divID )
{	if( document.getElementById )
	{	divID_dom = document.getElementById( divID );
		if( divID_dom.style.display == 'none' )
		{	// show block
			divID_dom.style.display = '';
		}
        else
        {	// hide block
			divID_dom.style.display = 'none';
		}
	}
	else
	{	alert("Sorry, this site's design is only visible in a graphical browser.");
	}
}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// over function
//////////////////////////////////////////////////////////////////////////////////
    function over( TD )
    {	TD.style.backgroundColor = '#DEE3E7';
    	cursor = "pointer";
	}
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// out function
//////////////////////////////////////////////////////////////////////////////////
    function out( TD )
    {	TD.style.backgroundColor = '#EFEFEF';
    	cursor = "default";
    }
//////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////
// submitOnce function
//////////////////////////////////////////////////////////////////////////////////
    function submitOnce( button, newValue )
    {	button.value = newValue;
	}
//////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////
// write flash code or alt gif with specified paramaters.
// asks for width and height of swf
    function writeFlash( WIDTH, HEIGHT, SWF )
    {
        var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
            + ' width="'+WIDTH+'" height="'+HEIGHT+'"'
            + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">'
            + '\n<param name="WMODE" value="opaque" />'
            + '\n<param name="MOVIE" value="'+SWF+'" />'
            + '\n<param name="PLAY" value="false" />'
            + '\n<param name="LOOP" value="false" />'
            + '\n<param name="QUALITY" value="high" />'
            + '\n<param name="MENU" value="false" />'
            + '\n<embed src="'+SWF+'"'
            + ' width="'+WIDTH+'" height="'+HEIGHT+'"'
            + ' play="false"'
            + ' loop="false"'
            + ' quality="high"'
            + ' menu="false"'
            + ' type="application/x-shockwave-flash"'
            + ' pluginspage="http://www.macromedia.com/go/getflashplayer">'
            + '</embed>'
            + '\n</object>';
            document.write( oeTags );   // embed the flash movie
    }
//////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////
    function pollResults( earl )
    {   var url = earl;
        var name = "ALLOY_POLL_RESULTS";
        var widgets = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=430,height=500,top=200,screenX=200,screenY=200";
        popupWin = window.open( url, name, widgets );
        popupWin.focus();
    }
//////////////////////////////////////////////////////////////////////////////////
