function ChangeImage(linkRel,imageId){

document.getElementById('ImageChanger').innerHTML = "<a href='" + linkRel +"'><img src='images/" + imageId + ".png' border='0'></a>";

}
function ChangeText(Text){

document.getElementById('TextChanger').innerHTML = "Click the image of the " + Text + " to navigate to that page.";

}

function JustChangeImage(imageId){

document.getElementById('ImageDisplay').innerHTML = "<img src='images/" + imageId + ".jpg' border='0'>";

}

function ToggleDiv(DivID){

if(document.getElementById(DivID).style.display == "none"){
document.getElementById(DivID).style.display= "block";
}
else{
document.getElementById(DivID).style.display= "none";
}
}

function HideDiv(DivId){
document.getElementById(DivId).style.display= "none";
}

// BROWSER CHECK FOR NOT SUPPORTED BROWSERS
function doCheck()
{
var name = navigator.appName.toLowerCase(); 

if ( name != 'microsoft internet explorer')
{
	msg = 'You are browsing with ' + name + '. ';
	msg += 'This site has been primarily designed for Internet Explorer, so sorry if you encounter any problems using ' + name + '.';
	alert(msg);
}

return false;
}

//--------------------------------------------------------------------------------------------------------------------------
// MAKE HIDDEN/VISIBLE VARIABLES CONSISTENT FOR ALL BROWSERS
if (document.layers) 				// CHECK FOR NETSCAPE-LIKE FEATURES
{
  visible = 'show';
  hidden = 'hide';
}
 else if (document.all) 			// CHECK FOR IE-LIKE FEATURES
{
  visible = 'visible';
  hidden = 'hidden';
}

//--------------------------------------------------------------------------------------------------------------------------
// BROWSER CHECK FOR MENU ITEMS ROLLOVER (HIGHLIGHT) EFFECTS 

function VersionNav(Netscape, Explorer)
{
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
  else 
	return false;
}
 
//------------------------------------------END VERSIONNAV-----------------------------------------------------------------
// TOGGLE THE DROPDOWN MENUS

function toggle(menu)
{
  if (document.layers)				// CHECK FOR NETSCAPE-LIKE FEATURES
    theMenu = document.layers[menu];
	
  else if (document.all)			// CHECK FOR IE-LIKE FEATURES
    theMenu = document.all(menu).style;

// NOW TOGGLE THE MENU
  if (theMenu.visibility == visible) 	
    theMenu.visibility = hidden;
  else 
    theMenu.visibility = visible;
}
//------------------------------------------------ END TOGGLE --------------------------------
// HIDE ALL MENUS

function hideMenus(menu)
{
  if (document.layers)				// CHECK FOR NETSCAPE-LIKE FEATURES
    menuToHide = document.layers[menu];
	
  else if (document.all)			// CHECK FOR IE-LIKE FEATURES
    menuToHide = document.all(menu).style;

// NOW TOGGLE THE MENU
  if (menuToHide.visibility == visible) 	
    menuToHide.visibility = hidden;

}
//------------------------------------------------ END HIDEMENUS --------------------------------

// PROTECT IMAGES FROM A RIGHT CLICK
function protect(evt) 
{
  if (navigator.appName != 'Microsoft Internet Explorer')
  {
    if (evt.which != 3) 
      return true;
  };
  alert("Sorry, you don't have permission to right-click.");
  return false;
}


function trap() 
{
  if(document.images)
  {
    if(navigator.appName != 'Microsoft Internet Explorer')
    {
      for(i = 0; i < document.images.length; i++)
        document.images[i].onmousedown = protect;
    }
    else
    {
      for(i = 0; i < document.images.length; i++)
        document.images[i].oncontextmenu = protect;
    }
  }
}
// ------------------------------------ END PROTECT IMAGES -----------------------------



// COOKIE STUFF
// NAME, LAST VISITED, HOW MANY TIMES VISITED

// set expiry date to 30 days
var expDays = 30;			
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 

// get when they were last here
function When(info)
{
	var rightNow = new Date()
	var WWHTime = 0;
	WWHTime = GetCookie('WWhenH')
	WWHTime = WWHTime * 1
	var lastHereFormatting = new Date(WWHTime);
	var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
	var lastHereInDateFormat = "" + lastHereFormatting;
	var dateMonth = lastHereInDateFormat.substring(4,10)
	var timeOfDay = lastHereInDateFormat.substring(11,16)
	if (navigator.appName == 'Netscape')
		var year = lastHereInDateFormat.substring(58,62)
	else
		var year = lastHereInDateFormat.substring(28,33)
	var WWHText = dateMonth + " " + year;
	SetCookie ("WWhenH", rightNow.getTime(), exp)
	return WWHText
}

function set()
{
	SetCookie ('WWhenH', 0, exp);
}
	
// Cut the cookie up
function getCookieVal (offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

// read cookie 
function GetCookie (name) 
{
	var arg = name + "="; 
	var alen = arg.length;	
	var clen = document.cookie.length;	
	var i = 0;
	while (i < clen) 
	{
		var j = i + alen;	
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) 
			break;
	}
	return null;
}

// set the cookie values
function SetCookie (name, value) 
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// reset the cookie
function DeleteCookie (name) 
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

//------------------------------------------------ END COOKIE STUFF --------------------------------

// get Last Modified Date and format it to  MMM DD YYYY
function writeLastChanged(lastChange)
{
	var fmonth = lastChange.substring(0,2);
	var fday = lastChange.substring(3,5);
	if(fday.substring(0,1) == '0')
		fday = fday.substring(1,2);
	var yearIndex = lastChange.indexOf(' ',0) - 2;
	var fyear = "20" + lastChange.substring(yearIndex, yearIndex+2);
	
	if (fmonth == '01') monthName = 'Jan';
	else if (fmonth == '01') monthName = 'Jan';
	else if (fmonth == '02') monthName = 'Feb';
	else if (fmonth == '03') monthName = 'Mar';
	else if (fmonth == '04') monthName = 'Apr';
	else if (fmonth == '05') monthName = 'May';
	else if (fmonth == '06') monthName = 'Jun';
	else if (fmonth == '07') monthName = 'Jul';
	else if (fmonth == '08') monthName = 'Aug';
	else if (fmonth == '09') monthName = 'Sept';
	else if (fmonth == '10') monthName = 'Oct';
	else if (fmonth == '11') monthName = 'Nov';
	else if (fmonth == '12') monthName = 'Dec';
	
	lastChangedDate = monthName + " " + fday + " " + fyear;
		return lastChangedDate; 
}
//-------------------------------------------------LAST MODIFED DATE--------------------------------------

// START CLOCK
function writeTime()
{
	if (!document.layers&&!document.all)
		return
	var Digital=new Date()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	var seconds=Digital.getSeconds()
	var dn="AM"
	if (hours>12)
	{
		dn="PM"
		hours=hours-12
	}
	if (hours==0)
		hours=12
	if (minutes<=9)
		minutes="0"+minutes
	if (seconds<=9)
		seconds="0"+seconds

	myclock = "<DIV STYLE='color: #000000; font-family: verdana; font-size:8pt'><B>" + hours + ":" + minutes + ":" + seconds + " " + dn + "</B></DIV>";

	if (document.layers)
	{
		document.layers.liveclock.document.write(myclock)
		document.layers.liveclock.document.close()
	}
	else if (document.all)
		liveclock.innerHTML=myclock
	
	setTimeout("writeTime()",1000)
}

//------------------------------------------------ END START CLOCK --------------------------------

// ADD to favourites for IE
var favouriteUrl="http://www.ZFlex.co.za"
var favouriteTitle="Z-Flex Cables and Connectors"
      
function addFavourite()
{
	if (document.all)
	window.external.AddFavorite(favouriteUrl,favouriteTitle)
}

//------------------------------------------------ END ADD TO FAVOURITES-----------

// SEARCH THE WEB
function searchTheWeb()
{
	searchTerm = document.searchForm.webSearch.value;    
	if(searchTerm != "")
	{
		searchTerm = searchTerm.replace(/\s/ig, "+");
		window.location = "http://search.yahoo.com/bin/search?p=" + searchTerm;
	}
}

//------------------------------------------------ END SEARCH THE WEB ------------------------