// Preload MouseOver Images
var use_images = new Array("");
var pl_images = new Array();
for(i=0;i<use_images.length;i++)
{
   pl_images[i] = new Image();
   pl_images[i].src = "images/" + use_images[i];
}

// SubMenu Operation
var submenuin = "";
var submenutime = 100;
function showSubMenu(menuID)
{
   submenuin = menuID;
   document.getElementById(menuID).style.display = "block";
   document.getElementById(menuID).style.zIndex = 5;
}
function hideSubMenu(menuID)
{
   document.getElementById(menuID).style.zIndex = 4;
   setTimeout("doHideSubMenu('" + menuID + "')",submenutime);
   submenuin = "";
}
function doHideSubMenu(menuID)
{
   if(submenuin != menuID)
      document.getElementById(menuID).style.display = "none";
}
function getTopNode(linkElem)
{
   tn = "";
   le = linkElem;
   while (tn != "TABLE")
   {
      le = le.parentNode;
	  tn = le.tagName;
   }
   return le.id;
}

// Flash Detection
function hasFlashVersion(theVersion)
{
   if(!self["MM_FlashCanPlay_" + theVersion])
      return false;
   else
      return true;
}
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
for(i=3;i<=10;i++)
{
   if (plugin)
   {
      var words = navigator.plugins["Shockwave Flash"].description.split(" ");
      for(j=0; j<words.length; j++)
      {
         if (isNaN(parseInt(words[j])))
            continue;
         self["MM_PluginVersion_" + i] = words[j]; 
      }
      self["MM_FlashCanPlay_" + i] = self["MM_PluginVersion_" + i] >= i;
   }
   else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1))
   {
      document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
      document.write('on error resume next \n');
      document.write('MM_FlashCanPlay_' + i + ' = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + i + ')))\n');
      document.write('</SCR' + 'IPT\> \n');
   }
}

// Flash Embedding
function insertFlashApp(theFile, theWidth, theHeight, theFlashVersion, theAlternateCode, theBGColor, theQuality, theID, theWindowMode)
{
   if(!theFlashVersion || !parseInt(theFlashVersion) || parseInt(theFlashVersion) == "")
      theFlashVersion = 3;
   if((!theBGColor && theBGColor != 0) || theBGColor == "")
      theBGColor = "#FFFFFF";
   if((!theQuality && theQuality != 0) || theQuality == "")
      theQuality = "high";

   if(hasFlashVersion(parseInt(theFlashVersion)) && !(!theFile && theFile != 0) && theFile != "" && !(!theWidth && theWidth != 0) && theWidth != "" && !(!theHeight && theHeight != 0) && theHeight != 0)
   {
      var theFlashEmbedCode = "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n"
         + "	CODEBASE=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + theFlashVersion + ",0,0,0\"\n";

      if(!(!theID && theID != 0) && theID != "")
         theFlashEmbedCode += "	ID=\"" + theID + "\"\n";

      theFlashEmbedCode += "	WIDTH=\"" + theWidth + "\"\n"
         + "	HEIGHT=\"" + theHeight + "\"\n";

      theFlashEmbedCode += "	>\n"
      + "	<PARAM NAME=\"movie\" VALUE=\"" + theFile + "\">\n"
      + "	<PARAM NAME=\"quality\" VALUE=\"" + theQuality + "\">\n"
      + "	<PARAM NAME=\"bgcolor\" VALUE=\"" + theBGColor + "\">\n";

      if(!(!theWindowMode && theWindowMode != 0) && theWindowMode != "")
         theFlashEmbedCode += "	<PARAM NAME=\"wmode\" VALUE=\"" + theWindowMode + "\">\n";

      theFlashEmbedCode += "	<EMBED SRC=\"" + theFile + "\"\n";

      if(!(!theID && theID != 0) && theID != "")
         theFlashEmbedCode += "		NAME=\"" + theID + "\"\n";

      theFlashEmbedCode += "		WIDTH=\"" + theWidth + "\"\n"
         + "		HEIGHT=\"" + theHeight + "\"\n"
         + "		QUALITY=\"" + theQuality + "\"\n"
         + "		BGCOLOR=\"" + theBGColor + "\"\n";

      if(!(!theWindowMode && theWindowMode != 0) && theWindowMode != "")
         theFlashEmbedCode += "		WMODE=\"" + theWindowMode + "\"\n";

      theFlashEmbedCode += "		TYPE=\"application/x-shockwave-flash\"\n"
         + "		PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">\n"
         + "	</EMBED>\n"
         + "</OBJECT><BR>";

      document.write(theFlashEmbedCode);
   }
   else if(theAlternateCode)
      document.write(theAlternateCode);
}

// Home page video playing
function playHomeVid(theVideo)
{
	var vidWidth = "320";
	var vidHeight = "275";
	var targetElem = document.getElementById("video-box");
	var vidcode = "";
	vidcode += "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"\n"
		+ "	CODEBASE=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"\n"
		+ "	WIDTH=\"" + vidWidth + "\"\n"
		+ "	HEIGHT=\"" + vidHeight + "\">\n"
		+ "	<PARAM NAME=\"movie\" VALUE=\"" + theVideo + "\">\n"
		+ "	<PARAM NAME=\"quality\" VALUE=\"high\">\n"
		+ "	<PARAM NAME=\"bgcolor\" VALUE=\"#484848\">\n"
		+ " <PARAM NAME=\"wmode\" VALUE=\"opaque\">\n"
		+ "	<EMBED SRC=\"" + theVideo + "\"\n"
		+ "		WIDTH=\"" + vidWidth + "\"\n"
		+ "		HEIGHT=\"" + vidHeight + "\"\n"
		+ "		QUALITY=\"high\"\n"
		+ "		BGCOLOR=\"#484848\"\n"
		+ "		WMODE=\"opaque\"\n"
		+ "		TYPE=\"application/x-shockwave-flash\"\n"
		+ "		PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">\n"
		+ "	</EMBED>\n"
		+ "</OBJECT>\n";
	targetElem.innerHTML = vidcode;
}

// Rotating Client Testimonials

// The order of display : True - Random / False - Sequential
var randomOrder = false;
// Default Width of the image (if not set individually)
var defaultWidth = 309;
// Default Height of the image (if not set individually)
var defaultHeight = 225;
// An array of the images to be rotated (Image Path[, Width of the Image[, Height of the Image]])
// If the width and height is not specified, the Default value specified above will be used
// var arImg = new Array('images/1.gif','images/2.gif','images/3.gif');
var arImg = new Array(['images/testimonial-1.jpg'],['images/testimonial-2.jpg'],['images/testimonial-3.jpg'],['images/testimonial-5.jpg'],['images/testimonial-6.jpg'],['images/testimonial-8.jpg'],['images/testimonial-9.jpg']);

function rotateImage(){
    if(randomOrder){
        index = Math.floor(Math.random() * arImg.length);
    }else{
        var index = getCookie('rotate_image');
        index = index ? index : 0;
        index = ++index % arImg.length;
    }
    (img = document.getElementById('image_id')).src = arImg[index][0];
    img.width = (arImg[index][1]) ? arImg[index][1] : defaultWidth;
    img.height = (arImg[index][2]) ? arImg[index][2] : defaultHeight;
    setCookie('rotate_image', index);
}
/*
Functions for storing and retrieving cookies from my previous example
Check http://www.weberdev.com/get_example-4570.html
*/

function getCookie(name) {
    var sPos = document.cookie.indexOf(name + '=');
    var len = sPos + name.length + 1;
    if((!sPos) && (name != document.cookie.substring(0, name.length))){
        return null;
    }
    if(sPos == -1){
        return null;
    }
    var ePos = document.cookie.indexOf(';', len);
    if(ePos == -1) ePos = document.cookie.length;
    return unescape(document.cookie.substring(len, ePos));
}

function setCookie(name, value, expires, path, domain, secure){
    var today = new Date();
    if(expires){
        expires = expires * 1000 * 3600 * 24;
    }
    document.cookie = name+'='+escape(value) +
        ((expires) ? ';expires=' + new Date(today.getTime() + expires).toGMTString() : '') +
        ((path) ? ';path=' + path : '') +
        ((domain) ? ';domain=' + domain : '') +
        ((secure) ? ';secure' : '');
}