
function getFlash(flVersion, flName, flColor, flWidth, flHeight, wMode) {
	//alert('getFlash')
	var flCodeBase;
	
	if (flVersion == '6')
		flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
	else if (flVersion == '7')
		flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
	else
		flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0";
	
	var _flashhtml ='<OBJECT '
	+ 'classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000"'
	+ ' codebase=" ' + flCodeBase
	+ ' ID="flash"'
	+ ' WIDTH=' + flWidth
	+ ' HEIGHT=' + flHeight + '>'
	+ '<PARAM NAME=movie VALUE="' + flName + '">'
	+ '<PARAM NAME=quality VALUE=high>'
	+ '<PARAM NAME=bgcolor VALUE=' + flColor + '>'
	+ '<PARAM NAME=wmode VALUE='+ wMode + '>'
	+ '<EMBED src="' + flName + '"'
	+ ' name="flash"'
	+ ' quality=high bgcolor=' + flColor
	+ ' WIDTH=' + flWidth
	+ ' HEIGHT=' + flHeight
	+ ' WMODE='+ wMode
	+ ' TYPE="application/x-shockwave-flash"'
	+ ' PLUGINSPAGE="http://www.macromedia.com/shockwave/'
	+ 'download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
	+ '</EMBED></OBJECT>'
	
	document.write(_flashhtml)
}

function writeIt(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="testclass">' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function swapImage(currentName,imageName){
	document.images[currentName].src= eval(imageName+'Up.src'); }

function unSwap(currentName,imageName){
	document.images[currentName].src=eval(imageName+'Down.src'); }

function OpenWindow( url, width, height, opt , name ) {
	window.open( url, (name || "OutsideWindow"), "width="+(width || 714)+",height="+(height || 536)+","+(opt ||  "scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes")).focus();
}

function mag(id){		
	var myHTML = '<img src="../img/datasheetindex/'+id+'_large.jpg" width="200">';	
	return overlib(myHTML, TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass',BGCLASS,'DatasheetbgClass')
	
}
	
function unmag(){
	return nd();
}
	
	
	
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<strong class='silonex'>";
    highlightEndTag = "</strong>";
  }
  
  // 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;
}

function highlightSearchTerms(searchText, 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
  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 = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
  	//alert(searchArray[i])
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;
  return true;
}

function highlightanchor(){
		var _itemref = document.location.hash;
		_itemref = _itemref.substring(1, _itemref.length);
		var x = document.getElementById(_itemref);
		var y = x.parentNode.parentNode;
		y.setAttribute('bgcolor','#ffcc00');
}


function mailme(recipient,domain){
		
		var _address=new String("mailto:" + recipient + "@"+ domain)
		document.location.href=  _address
	
}

function verify(){

	var verified = true;
	
	myForm = document.forms['ContactForm']
	// check that a recipient has been selected
	if(myForm.recipient.value != null && myForm.recipient.value != "undfined"){
		
	}
	else{
		verified = false;
		alert('please select a contact to recieve this email')
	} 
	// check that a subject has been entered
	if(myForm.subject.value.length > 1){ }
	else{
		verified = false;		
		alert('please enter the subject of your email')	
	}
	// check that a valid email address is provided		
	var _validaddy = validateEmail(myForm.email.value,1,1)
	if (_validaddy == false)
	{
		verified = false;
		alert('please enter a valid email address')
	}	
	//check that a message has been entered
	if(myForm.message.value.length<1){
		verified = false;
		alert('please enter your message')
	}
	return verified
}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}


window.onload = function(){
	highlightSearchTerms('<strong>Silonex</strong> Inc.',true);
	highlightSearchTerms('Silonex Inc.',true);
	highlightSearchTerms('Silonex',true);
}

