// JavaScript for www.littleglassvial.com


// MP3 helper function that adds a SWFObject player to the page
//	duration	= file duration in seconds
//	file		= relative path to media file
//	div_id		= id of DIV that will be replaced by SWFObject
function addSWFObjectMP3( duration, file, div_id )
{
	// REUSE THESE VARS
	var flashvars	= {};
	var params		= {};
	var attributes	= {};

	flashvars.duration		= duration;
	flashvars.file			= file;
	flashvars.backcolor		= "000000";
	flashvars.frontcolor	= "05a9e6";
	flashvars.lightcolor	= "eab227";
	flashvars.screencolor	= "000000";
	flashvars.dock			= "false";

	attributes.id			= div_id;
	attributes.name			= div_id;
	
	return swfobject.embedSWF("../../JWplayer/player.swf", div_id, "300", "20", "9.0.0", "../../JWplayer/expressInstall.swf", flashvars, params, attributes);	
}


// FLV helper function that adds a SWFObject player to the page
//	file		= relative path to media file
//	div_id		= id of DIV that will be replaced by SWFObject
function addSWFObjectFLV( file, div_id )
{
	var flashvars	= {};
	var params		= {};
	var attributes	= {};
	
	flashvars.file			= file;
	flashvars.backcolor		= "000000";
	flashvars.frontcolor	= "05a9e6";
	flashvars.lightcolor	= "eab227";
	flashvars.screencolor	= "000000";

	params.wmode				= "opaque";
	params.allowfullscreen		= "true";
	params.allowscriptaccess	= "always";

	attributes.id			= div_id;
	attributes.name			= div_id;

	return swfobject.embedSWF("../../JWplayer/player.swf", div_id, "470", "320", "9.0.0", "../../JWplayer/expressInstall.swf", flashvars, params, attributes);
}


// Pass in a URL and this will open the
// url in a new popup window
function openFlipper( url )
{
    window.open( url , "flipper", "height=1000, width=1200, status=0,toolbar=0, location=0, menubar=0");
}


// This is the master image pre-loader function
// call this in <body onload="preloadImages()">
// If calling from an update level page, call
// <body onload="preloadImages(true)">
function preloadImages( is_subfolder )
{
    // check to see if the page is an update level page
    if( is_subfolder )
    {
	    MM_preloadImages(	'../../images/go_btn_on.gif',
						    '../../images/nav_home_on.gif',
						    '../../images/nav_home_off.gif',
						    '../../images/nav_updates_on.gif',
						    '../../images/nav_udpates_off.gif',
						    '../../images/nav_archives_off.gif',
						    '../../images/nav_archives_on.gif',
						    '../../images/view_slideshow_on.gif',
						    '../../images/view_slideshow_off.gif',
							'../../images/nav_visit_store_off.gif',
							'../../images/nav_visit_store_on.gif' );
    }
    else
    {
	    MM_preloadImages(	'images/go_btn_on.gif',
						    'images/nav_home_on.gif',
						    'images/nav_home_off.gif',
						    'images/nav_updates_on.gif',
						    'images/nav_udpates_off.gif',
						    'images/nav_archives_off.gif',
						    'images/nav_archives_on.gif',
						    'images/view_slideshow_on.gif',
						    'images/view_slideshow_off.gif',
							'images/nav_visit_store_off.gif',
							'images/nav_visit_store_on.gif' );
    }
}

// Mouseover proxy function for the NAV buttons
// Pass in the id and this will call the MM_swapImage()
// with the appropriate over button name
// NOTE : when using from an update level page, 
// call navbtn( btn_id, true ) 
function navbtn( btn_id, subfolder )
{
    var home_img;
    var updates_img;
    var archives_img;
	var store_img;

    // set image path level appropriately
    if( subfolder )
    {
        home_img        = '../../images/nav_home_on.gif';
        updates_img     = '../../images/nav_updates_on.gif';
        archives_img    = '../../images/nav_archives_on.gif';
		store_img    	= '../../images/nav_visit_store_on.gif';
    }
    else
    {
        home_img        = 'images/nav_home_on.gif';
        updates_img     = 'images/nav_updates_on.gif';
        archives_img    = 'images/nav_archives_on.gif';
		store_img    	= 'images/nav_visit_store_on.gif';
    }


	switch( btn_id )
	{
		case "nav_home":
			MM_swapImage( btn_id ,'', home_img ,1);
		break;
		
		case "nav_updates":
			MM_swapImage( btn_id ,'',updates_img,1);
		break;
		
		case "nav_archives":
			MM_swapImage( btn_id ,'', archives_img,1);
		break;
		
		case "nav_store":
			MM_swapImage( btn_id ,'', store_img,1);
		break;
	}
}



// VIEW REPOZINE : mouseover for RED View RepoZine buttons
function rzbtn( btn_id, subfolder )
{
    var rz_img;

    // set image path level appropriately
    if( subfolder )
    {
        rz_img        = '../../images/view_repozine_on.gif';
    }
    else
    {
        rz_img        = 'images/view_repozine_on.gif';
    }

	// VIEW SLIDESHOW buttons always have the same mouseOver image, so
	// pass in the appropriate button id
	MM_swapImage( btn_id ,'', rz_img,1)
}



// VIEW SLIDESHOW : this is just a proxy function for MM_swapImage() so
// the html isn't so huge for mouseOver
// * subfolder support just in case
function ssbtn( btn_id, subfolder )
{
    var ss_img;

    // set image path level appropriately
    if( subfolder )
    {
        ss_img        = '../../images/view_slideshow_on.gif';
    }
    else
    {
        ss_img        = 'images/view_slideshow_on.gif';
    }

	// VIEW SLIDESHOW buttons always have the same mouseOver image, so
	// pass in the appropriate button id
	MM_swapImage( btn_id ,'', ss_img,1)
}


// GO : this is just a proxy function for MM_swapImage() so
// the html isn't so huge for mouseOver
function gobtn( btn_id )
{
	// GO buttons always have the same mouseOver image, so
	// pass in the appropriate button id
	MM_swapImage( btn_id ,'','images/go_btn_on.gif',1)
}

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->




	/**
	* Pass in an array of field ids, and this
	* will loop through and verify each required field
	* contains a value.
	* If any of your fields do not get checked, verify
	* that field has id="" set to the value in fld_ids
	*/
	function checkRequiredFields( fld_ids, fld_names )
	{
		var msg		= "The following required fields are empty : \n";
		var good	= true; // is form good to submit?
		var first_field = "";   // first empty required field which will get .setFocus

		for( xx = 0; xx <= fld_ids.length-1; xx++ )
		{
			var fld = document.getElementById( fld_ids[xx] );

			//check for bad fields
			if(fld == null)
			{
				alert("The field '" + fld_names[xx] + "' doesn't have it's ID ("+ fld_ids[xx] +") set properly");
				good = false;
				xx = fld_ids.length-1;	//force loop break
				break;
			}

			//remove spaces ( not trim )
			field_value = fld.value.split(" ").join("");

            // type specific field checking
            switch( fld.type )
            {
                // check .checked, not .value
                case "checkbox" :
                    if( fld.checked )
                        field_value = "good";
                    else
                        field_value = "";
                break;
            }
            
// TODO : consider setting bgColor as well since <SELECT>s do not 
// support CSS borders

			// other fields
			if(field_value == "")
			{
				msg		+= " - " + fld_names[xx] + "\n";
				good	= false;
				fld.style.border = "1px solid red";
				
				// track first empty field for setfocus
				if( first_field == "" )
				{
				    first_field = fld;
				}
				
			}
			else
			{
				fld.style.border = "";
			}
		}

		msg += "Please fill out these fields before submitting the form.";

		if(!good)
		{
			// show required field msg
			alert( msg );
			// set focus to first empty field
			if( first_field )   first_field.focus();
		}

		//if the code makes it here, the form is good
		return good;
	}
	
	/**
	* Pass in the id of two fields, and this will tell
	* you if their values match or not
	*/
	function compareTwoFields( fld1, fld2 )
	{
		var f1 = document.getElementById( fld1 );
		var f2 = document.getElementById( fld2 );

		//remove spaces
		pswd1 = f1.value.split(" ").join("");
		pswd2 = f2.value.split(" ").join("");

		if( pswd1 != pswd2 )
		{
		    // focus on first field
		    f1.focus();

			return false;
		}
		else
		{
			return true;
		}
	}
	
	/*
		Convenience function to check required fields AND
		confirm both password fields match.  
		aIds = Array of field ids
		aNames = Array of field names
		pswd1 = id of password field 1
		pswd2 = id of password field 2
	*/
	function verifyRequiredAndPasswords( aIds, aNames, pswd1, pswd2 )		//login.php : signup with promo
	{
		//required fields good?
		if( checkRequiredFields( aIds, aNames ) )
		{
			//do passwords match?
			if( compareTwoFields( pswd1, pswd2 ) )
			{
				return true;
			}
			else
			{
				alert('The password fields do not appear to match. Please try again');
				return false;
			}
		}
		else
		{
			return false;
		}
	}