function SwapImage(ElementName,state) {
  eval("document." +ElementName+ ".src='images/nav_" +ElementName+ "_" +state+ ".gif'");
  
}
function SwapProduct(ElementName,state) {
  eval("document." +ElementName+ ".src='images/prod_" +ElementName+ "_" +state+ ".gif'");
  
}
function SwapDip(ElementName,state) {
  eval("document." +ElementName+ ".src='images/dip_" +ElementName+ "_" +state+ ".gif'");
  
}
function SwapJPG(ElementName,state) {
	 //alert( "document." +ElementName+ ".src='images/" +ElementName+ "-" +state+ ".jpg'");
 eval("document." +ElementName+ ".src='images/" +ElementName+ "-" +state+ ".jpg'");
  
}


function nextLayer(a,id){
			
	for(i=1;i<=6;i++){
		var obj = document.getElementById(a +i);
		if(i==id){
        	obj.style.visibility = "visible" ;
		}
		else{
			obj.style.visibility = "hidden" ;
		}
	}
}
function toggleSwap(a){
  var style1 = document.getElementById(a).style;
  
  if(style1.display=="block"){
	 
	 style1.display = style1.display="none";
  }
  else{
	 style1.display = style1.display="block";
  }
 
}


//Slider Controls

var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 3000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed = 10;	// Speed of fading	(Lower value = faster)
var slideshow2_stats = new Array();
var slideshow2_slideIndex = new Array();	// Index of current image shown
var slideshow2_slideIndexNext = new Array();	// Index of next image shown
var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity = new Array();	// Initial opacity
var slideshow2_imagesInGallery = new Array();	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
var reverseShow = false;


function createParentDivs(imageIndex,divId)
{
	if(imageIndex==slideshow2_imagesInGallery[divId]){	
		showGallery(divId);
	}else{
		var imgObj = document.getElementById(divId + '_' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		if(!slideshow2_imageDivs[divId])slideshow2_imageDivs[divId] = new Array();
		slideshow2_imageDivs[divId][slideshow2_imageDivs[divId].length] =  imgObj;

		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs(imageIndex,divId);	
	}		
}

function showGallery(divId)
{
	if(reverseShow){
		slideshow2_slideIndex[divId]--;	// Index of next image to show
		if(slideshow2_slideIndex[divId]== -1)slideshow2_slideIndex[divId]=slideshow2_imageDivs[divId].length -1;
		slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]-1;	// Index of the next next image
		if(slideshow2_slideIndexNext[divId]==-1  )slideshow2_slideIndexNext[divId] = slideshow2_imageDivs[divId].length -1;
		
	}
	else{
		if(slideshow2_slideIndex[divId]==-1)slideshow2_slideIndex[divId]=0; else slideshow2_slideIndex[divId]++;	// Index of next image to show
		if(slideshow2_slideIndex[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndex[divId]=0;
		slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]+1;	// Index of the next next image
		if(slideshow2_slideIndexNext[divId]==slideshow2_imageDivs[divId].length  )slideshow2_slideIndexNext[divId] = 0;    //alert(slideshow2_slideIndexNext[divId]);
	}
		
	slideshow2_currentOpacity[divId]=100;	// Reset current opacity

	// Displaying image divs
	
	slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity=1)';
	}else{
		
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = 0.01;
	}
	
	
	setTimeout('revealImage("' + divId + '")',slideshow2_timeBetweenSlides);		
}

function revealImage(divId)
{
	if(slideshow2_noFading){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';
		showGallery(divId);
		return;
	}
	slideshow2_currentOpacity[divId]--;
	if(document.all){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity[divId]+')';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity[divId])+')';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity[divId]/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity[divId]/100)));
	}
	if(slideshow2_currentOpacity[divId]>0){
			setTimeout('revealImage("' + divId + '")',slideshow2_fadingSpeed);
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';	
		showGallery(divId);
	}
}

function initImageGallery(divId)
{
	var slideshow2_galleryContainer = document.getElementById(divId);
	slideshow2_slideIndex[divId] = -1;
	slideshow2_slideIndexNext[divId] = false;
	
	var galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('img');
	for(var no=0;no<galleryImgArray.length;no++){
		galleryImgArray[no].id = divId + '_' + no;
	}
	
	slideshow2_imagesInGallery[divId] = galleryImgArray.length;
	createParentDivs(0,divId);		
	
}


//***********************************
//***********************************
//Start OF smart phone check functions
//***********************************
//***********************************
var deviceIphone = "iphone";
var deviceIpod = "ipod";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current device is an iPhone.
function DetectIphone()
{
   if (uagent.search(deviceIphone) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPod Touch.
function DetectIpod()
{
   if (uagent.search(deviceIpod) > -1)
      return true;
   else
      return false;
}

//**************************
// Detects if the current device is an iPhone or iPod Touch.
function DetectIphoneOrIpod()
{
    if (DetectIphone())
       return true;
    else if (DetectIpod())
       return true;
    else
       return false;
}

var deviceAndroid = "android";

//**************************
// Detects if the current device is an Android OS-based device.
function DetectAndroid()
{
   if (uagent.search(deviceAndroid) > -1)
      return true;
   else
      return false;
}


//**************************
// Detects if the current device is an Android OS-based device and
//   the browser is based on WebKit.
function DetectAndroidWebKit()
{
   if (DetectAndroid())
   {
     if (DetectWebkit())
        return true;
     else
        return false;
   }
   else
      return false;
}

var deviceWinMob = "windows ce";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current browser is a Windows Mobile device.
function DetectWindowsMobile()
{
   if (uagent.search(deviceWinMob) > -1)
      return true;
   else
      return false;
}

var deviceBB = "blackberry";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current browser is a BlackBerry of some sort.
function DetectBlackBerry()
{
   if (uagent.search(deviceBB) > -1)
      return true;
   else
      return false;
}

var devicePalm = "palm";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current browser is on a PalmOS device.
function DetectPalmOS()
{
   if (uagent.search(devicePalm) > -1)
      return true;
   else
      return false;
}

var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function DetectS60OssBrowser()
{
   if (uagent.search(engineWebKit) > -1)
   {
     if ((uagent.search(deviceS60) > -1 || 
          uagent.search(deviceSymbian) > -1))
        return true;
     else
        return false;
   }
   else
      return false;
}
//***********************************
//***********************************
//END OF smart phone check functions
//***********************************
//***********************************


//***********************************
//START this is for the smart phone cookies
//***********************************
//***********************************

//gets the URL Var
function getURLVar(urlVarName) 
{
	//divide the URL in half at the '?'
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1])
	{
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++)
		{
			if(urlVars[i])
			{
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) 
				{
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}


//set a javascript cookie function
function SetCookie(cookieName,cookieValue,nDays) 
{
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

//get the javascript cookie value or ""
function getCookie(c_name)
{
	if (document.cookie.length>0)
  	{
  		c_start=document.cookie.indexOf(c_name + "=");
	  	if (c_start!=-1)
    	{
    		c_start=c_start + c_name.length+1;
    		c_end=document.cookie.indexOf(";",c_start);
    		if (c_end==-1) 
				c_end=document.cookie.length;
    		
			return unescape(document.cookie.substring(c_start,c_end));
    	}
  	}
	return "";
}

//***********************************
//END this is for the smart phone cookies
//***********************************
//***********************************