/* Change date: July 18,2003
   Changed by: Michael Sullivan
   Description: 
   	1. Removed unused legacy code
   	2. BuildItem: Added if statements to correctly format the jpg name to correspond to 3 digit format i.e. 001.jpg - 999.jpg
	3. Note that pictureLimit is the first invalid picture number
*/

	var pictureLimit = 21;

  function displayItem (Count) {
      var i = 0; 
      document.write("<center><table>"); 
      if ( Count == "") {
	  	i=1; //go to the first page
      }
      else {
         var tempValue = Count - 0;  // awkward way to do a cast 
         if (tempValue == 0) {
            i = 1;
         }
         else {
            if (tempValue >= pictureLimit) {
               i = pictureLimit - 1;
            }
            else {
               i = tempValue;	
            }
         }
      }		 
	 buildItem(i);
	 document.write("</center>");  			
   } // end of displayItem

function buildItem(i) {	

	var previousOne = i - 1;
	var nextOne = i + 1; 

	document.write("<table width='600' border='0' align='center'><tr><td valign='top'><a href='page.htm?Count=", previousOne , "'>");
	document.write("<img src='images/previous.gif' name='previous' alt='Previous Button' border='0' align='top'></a></td>");
	
	document.write("<td><p align='center'><b><font face='Verdana' size='2'><a href='Real_Estate_Guide_FreeMagReq.htm'>Request a FREE copy of the<br>Home Guide of Prescott, AZ</a></font></b></p></td>");
	
	document.write("<td valign='top'><p align='right'><a href='page.htm?Count=", nextOne, "'>");
	document.write("<img src='images/next.gif' name='next' alt='Next Button' border='0' align='top'></a></td></tr></table>");

	document.write("<table border='0'><tr><td>");
	
    if (i < 10)
	   document.write("<img src='image/00", i, ".jpg' border='0' width='600' height='775' alt='Prescott Arizona Real Estate'></a></td></tr></table>");
	else if (i < 100)
	   document.write("<img src='image/0", i, ".jpg' border='0' width='600' height='775' alt='Prescott Arizona Real Estate'></a></td></tr></table>");
	else   
	   document.write("<img src='image/", i, ".jpg' border='0' width='600' height='775' alt='Prescott Arizona Real Estate'></a></td></tr></table>");

	document.write("<table width='600' border='0' align='center'><tr><td valign='top'><a href='page.htm?Count=", previousOne , "'>");
	document.write("<img src='images/previous.gif' name='previous' alt='Previous Button' border='0' align='top'></a></td>");
	
	document.write("<td><p align='center'><b><font face='Verdana' size='2'><a href='Real_Estate_Guide_FreeMagReq.htm'>Request a FREE copy of the<br>Home Guide of Prescott, AZ</a></font></b></p></td>");
	
	document.write("<td valign='top'><p align='right'><a href='page.htm?Count=", nextOne, "'>");
	document.write("<img src='images/next.gif' name='next' alt='Next Button' border='0' align='top'></a></td></tr></table>");	

  }  // end of buildItem 



/* Extract a variable value from the html code ie.
   page.htm?variable=value
	 strFieldName("variable") will return "value" */

  function getFieldValue (strFieldName) {
    var strFieldValue;
    var objRegExp = new RegExp(strFieldName + "=([^&]+)","gi");

    if (objRegExp.test(location.search)) {
      strFieldValue = unescape(RegExp.$1);
		}		
    else {
		  strFieldValue="";
		}	
    return strFieldValue;
  } // end of getFieldValue
  

