/*

This template builds an automated image
of the day gallery and archive

*/



/* POD: (PARSEFORM) */


var formdata=new Array();


function parse_form(){

    if (document.location.search.indexOf('=')>-1) {
 
        keyvalues=unescape(document.location.search.substring('1').replace(/\+/g,' ')).split("&");

         for(p=0;p<keyvalues.length;p++) {

            pairs=keyvalues[p].split("=");

            formdata[pairs[0]]=pairs[1];

            }

        }

    }



parse_form();



/* POD: (begin user editable) */


	
	/* POD: (set thumbs path) */

	var thumbpath="images/potd/thumbs/"



	/* POD: (set big path) */

	var bigpath="images/potd/big/"


	
	/* POD: (uselabel (true | false)) */
	
	var uselabel=false;



/* POD: (end user editable) */



/* POD: (begin main) */
	
	/* POD: (init date object) */

	var now = new Date();



	/* POD: (init days array) */

	var days=new Array();


	/* POD: (init counter) */

	var start=((formdata['start'])?parseInt(formdata['start']):0);;


	/* POD: (init thumbs hash) */

	var hash = "";



	/*POD: (start thumbnail hash) */
	for(i=0;i<=6;i++) {

	   days[i]=new Date(now.getTime()-((parseInt(start)+i)*86400000));

	   hash+="<p>";

	   hash+="<a href=\"";

	   hash+="javascript:SwapImage('big','"+bigpath+ReturnDateImg(days[i],'png')+"')";

	   hash+="\"  title=\""+ReturnUSDate(days[i])+"\">";

	   hash+="<img src=\""+thumbpath+ReturnDateImg(days[i],'png')+"\" border=0 \/>";

	   hash+="<\/a>"

	   hash+=((uselabel)?"<div class=plabel>"+ReturnUSDate(days[i])+"<\/div>":"");

	   }


	/* POD: (end thumbnail hash) */
	
		

/* POD: (BUILD BASEIMAGE) */

	var baseImage="<img src="+bigpath+ReturnDateImg(days[0],'png')+" name='big' \/>";


/*POD: (end main) */

/* POD: (begin subroutines) */


/* POD: (IMAGE SWAP) */

function SwapImage(theName,theSource) {

	document.images[theName].src=theSource;

	document.images[theName].alt=theSource;

   }


/* POD: (RETURN IMAGE) */

function ReturnDateImg(then,postfix) {

   var when=new Date(then);

   var t=when.getFullYear()+"-";

   t+=Return2Digits((when.getMonth()+1))+"-";

   t+=Return2Digits(when.getDate());

   t+="."+postfix;

   return t;

   }



/* POD: (RETURN US STANDARD DATE) */

function ReturnUSDate(date) {

   var us=Return2Digits(date.getMonth()+1);

   us+="/"; 
      us+=Return2Digits(date.getDate());

   us+="/";

   us+=date.getFullYear();

   return us;

   }



/* POD: (APPEND LEADING ZERO) */

function Return2Digits(numin) {

	return ((numin<10)?("0"+numin):numin);

	}





/* POD: (end subroutines) */
