//Location map preloads
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		locationmap_01_ImageMap_01_over = newImage("/Images/location/locationmap_01-ImageMap_01_.gif");
		locationmap_01_ImageMap_02_over = newImage("/Images/location/locationmap_01-ImageMap_02_.gif");
		locationmap_01_ImageMap_03_over = newImage("/Images/location/locationmap_01-ImageMap_03_.gif");
		locationmap_01_ImageMap_04_over = newImage("/Images/location/locationmap_01-ImageMap_04_.gif");
		locationmap_01_ImageMap_05_over = newImage("/Images/location/locationmap_01-ImageMap_05_.gif");
		locationmap_01_ImageMap_06_over = newImage("/Images/location/locationmap_01-ImageMap_06_.gif");
		locationmap_01_ImageMap_07_over = newImage("/Images/location/locationmap_01-ImageMap_07_.gif");
		locationmap_01_ImageMap_08_over = newImage("/Images/location/locationmap_01-ImageMap_08_.gif");
		preloadFlag = true;
	}
}

//Magazine Online popup window
function MagazinePopup()
{
newwindow = window.open("/Flash/shalfoon_book.html","Magazine","toolbar=0,menubar=0,resizable=0,scrollbars=0,width=" + screen.width + ",height=" + screen.height + "");
newwindow.moveTo(0,0);
}





var root = "/Shared/media/images/ContentImages/";
if (document.images)
{    for(var i=1; i< 3; i++){
        var obj = new Image(100,25); 
        obj.src= root + i + ".jpg"; 
    }
}

function switchContentImage(){
    var imgContentImage = document.getElementById("imgContentImage");
    if(imgContentImage!=null){
        var image = root + randomnumber(1, 2) + ".jpg";
        imgContentImage.src = image;
    }
    
}

//Script by hscripts.com          -->
//copyright of HIOX INDIA         -->
//more scripts @ http://www.hscripts.com -->
function randomnumber(num1, num2)
{
	num1 = parseInt(num1);
	num2 = parseInt(num2);

	var generator = Math.random()*(num2-num1);
	generator = Math.round(num1+generator);
	return generator;

}
//Script by hscripts.com -->

/*
 * This is the function that actually highlights a text string by
 * adding HTML tags before and after all occurrences of the search
 * term. You can pass your own tags if you'd like, or if the
 * highlightStartTag or highlightEndTag parameters are omitted or
 * are empty strings then the default <font> tags will be used.
 */
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}

/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function highlightSearchTerms(searchValueId, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  var searchText = document.getElementById(searchValueId).value;
  var rootElement = document.getElementById('SearchableArea');

  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  var bodyText = rootElement.innerHTML;

  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  rootElement.innerHTML = bodyText;
  return true;
}
