// SearchBox.js
// JWorks Studios (c) 2009
// This file will format and show the search box


// Which page are we sending all of our variable data to?
//
var SearchResultsPage = 'http://www.JWorksStudios.com/Search/index.php';

// This is the default or random word or phrase that will ALREADY be
// in the search box when the user goes to a page.
//
var DefKeyword = 'Search JWorks';

// The width of the search box (in characters)
//
var BoxWidth = '20';

// This is the list of text strings that will be used to
// default the search box.
var SearchList = new Array();
SearchList[0] = 'Search JWorks';
SearchList[1] = 'JStyle';
SearchList[2] = 'Music Player';
SearchList[3] = 'Logos';
SearchList[4] = 'Prices';
SearchList[5] = 'Flash Animation';
SearchList[6] = 'Samples';
SearchList[7] = 'VIP Badges';
SearchList[8] = 'Backstage Passes';
SearchList[9] = 'Business Cards';
SearchList[10] = 'Letterheads';
SearchList[11] = 'Contracts';
SearchList[12] = 'Get A Quote';
SearchList[13] = 'Specials';
SearchList[14] = 'Packages';
SearchList[15] = 'Create Your Own Pkg.';
SearchList[16] = 'CD Design';
SearchList[17] = 'Album Design';
SearchList[18] = 'Poster Design';
SearchList[19] = 'Promo Flier Design';
SearchList[20] = 'Press Kits';
SearchList[21] = 'Myspace Players';
SearchList[22] = 'Album Material';
SearchList[23] = 'Banners';
SearchList[24] = 'News Tickers/Marquee';


// This style attributes of the text box
//
var BoxStyle = 'color: rgb(125, 125, 125);'

// This is the text that is on the submit button
//
var ButtonText = 'Search';


// Generate A Random Number using the Max number to randomize.
// 
// Returns a zero-based result (i.e. returns 0 instead of 1)
function GenRand(Max){
  if(Max == undefined)
    Max = SearchList.length;
  return (Math.round(Math.random() * (Max - 1)));
}

// Initialize everything with random names and such.
//
function InitSearchBox(){
   // Get a random text string to put in the search box.
   var rnd = GenRand(SearchList.length);
   DefKeyword = SearchList[rnd];
}

// This function will clear out the text box when the user clicks on
// the client area.
function ClearTextBox(){
   document.Search_Form.zoom_query.value = "";
}

// This function will do everything to show the button.
//
function ShowButton(){
   // Initialize with random names and such...
   InitSearchBox();
   // Write out the code for the actual search box and button
   document.write('<form method="get" action="' + SearchResultsPage + '"  name="Search_Form"><input style ="' + BoxStyle + '" value="' + DefKeyword + '" name="zoom_query" size="' + BoxWidth + '" onfocus="ClearTextBox()"' + BoxStyle + ';"> <input value="' + ButtonText + '" type="submit"></form>')
}
