/* 	File: 	 smdev.js
Authors: Various
Compiled by: Humberto Olarte Cupas
Company: sol media development
Description: smdev.js is a compilation of several javascript
funtions to provide a centralized environment with all the common
routines needed for website operation. It includes browser
detection, css loading, alternate text, popup windows,
email validation.

Some of the code included here was coded by other authors and
is so specified where needed.
*/
/****************************************************************/
//
// Browser detection Routines
//
/* ***********************************************************
** DETECT.JS - JS Browser/Version/Platform Detection Library
** =========================================================
** This library contains functions to detect/return the user's
** browser, version, and platform and to jump to a URL if
** the user is using a specified browser and/or version and/or
** platform. It's yours for free; please maintain this header!
**
** To load this library in an HTML doc, put the following
** line in the doc's HEAD (before any other SCRIPT tags):
**
** <SCRIPT SRC="/main2/js/detect.js" LANGUAGE="JavaScript"></SCRIPT>
**
** Author      Ver  Date    Comments
** ======      ===  ====    ========
** Rick Scott  1.0  1/1/00  First release
**
** Copyright 2000, Rick Scott, all rights reserved.
*********************************************************** */

/* ***********************************************************
** Functions
** =========
** getBrowser()
**   returns browser: "netscape", "ie", "other"
** getBrowserVer()
**   returns browser version number or "n/a"
** getPlatform()
**   returns browser OS: "mac", "win", "unix", "other"
** ifBVPjump(browser, version, platform, URL);
**   jumps to URL if user's browser, version, platform all
**   match the first three arguments
**   browser - "netscape", "ie", "other", "any"
**   version - "#.x", "#.#[#]", "any"
**             "#.x" matches any version #
**               ex: "4.x" matches 4.0, 4.05, 4.5, etc.
**             "#.#[#]" matches only version #.#[#]
**               ex: "4.05" matches 4.05, not 4.0, 4.5
**   platform - "mac", "win", "unix", "other", "any"
**   URL - relative or absolute URL
**   examples:
**     ifBVPjump("ie", "4.x", "win", "ie4winpage.html");
**       would jump to ie4winpage.html if the user's BVP
**       were IE, 4.x, Windows
**     ifBVPjump("IE", "4.x", "win", "ie4winpage.html");
**       wouldn't work because "ie" is case-sensitive
**    ifBVPjump("any", "any", "unix", "unixpage.html");
**       would jump to unixpage.html if user's P were UNIX
**     ifBVPjump("any", "any", "any", "index.html");
**       would jump to index.html regardless of user's BVP
** isNetscape()
**   returns true if Netscape, false if not
** isIE()
**   returns true if IE, false if not
** isVer3()
**   returns true if version is 3.x, false if not
** isVer4()
**   returns true if version is 4.x, false if not
** isVer4up()
**   returns true if version is 4.0+, false if not
**   this is a quick way to test for DHTML capability
** isVer5()
**   returns true if version is 5.x, false if not
** isMac()
**   returns true if OS is Mac, false if not
** isWin()
**   returns true if OS is Windows, false if not
** isUNIX()
**   returns true if OS is UNIX, false if not
*********************************************************** */


/**********************************************************************************/
/***********************************************************************************/
//
// Popup Window script
//

//function NewWindow(mypage, myname, w, h, scroll) {
//	var winl = (screen.width - w) / 2;
//	var wint = (screen.height - h) / 2;
//	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
//	win = window.open(mypage, myname, winprops)
//	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
//}


function newWindow(url,name,features){
   var newWin = window.open(url,name,features);
}


/*********************************************************************************
Use Example for Popup script:
<a href="/about_us/nut_tables/nt_vanilla.html" onclick="NewWindow(this.href,'name','320','340','yes');return false;">
<img src="/main/images/facts_vanilla.jpg" width="160" height="140" border="0">
Vanilla</a>

**********************************************************************************/
function nxPopup(mypage,myname,w,h,pos,infocus)

{
      if(pos=='random'){
      LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
      TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
}
      if(pos=='center'){
            LeftPosition=(screen.width)?(screen.width-w)/2:100;
            TopPosition=(screen.height)?(screen.height-h)/2:100;
}
      else if((pos!='center' && pos!='random') || pos==null){
LeftPosition=50;TopPosition=50;
      }
      settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition +',location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=0,dependent=0';
      clipPopupWindow=window.open('',myname,settings);
      if(infocus=='front'){clipPopupWindow.focus();clipPopupWindow.location=mypage;}
}

/*
Usage:
<a href="javascript:nxPopup('/company/print.php','nxPopup','300','400','center','front');">Print Articles</a>

*/

//The following code converts TD to link:

function Arr(src,clrOver) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}
function Aba(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}
function Cli(src) {
	if(event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
	}
}

//Ends TD convert

/*******************************************************************************
The following code creates and updated roman numeral for the copyright notice
********************************************************************************/
var date = new Date();
year = date.getYear();
year = year - 0;
if (year < 70) { year += 2000; }
if (year < 1000) { year +=1900; }

//var LMDate = new Date( document.lastModified );
//year = LMDate.getYear();
//year = year - 0;
//if (year < 70) { year += 2000; }
//if (year < 1000) { year +=1900; }

//function MyConvert(){
//temp  = document.romanguy.my_year.selectedIndex;
//temp2 = document.romanguy.my_year.options[temp].value;
//document.romanguy.yahoo.value = Roman(temp2);
//}

function Init() {
this.length = Init.arguments.length;
for ( var i = 0; i < this.length; i++ ) this[ i + 1 ] = Init.arguments[ i ];
}
function Roman(number) {
if (number < 1000) { alert(number+" is too small\nMinumum value is 1000"); number = 1; }
if (number > 5999) { alert(number+" it too big\nMaximum value is 5999"); number = 5999; }
var roman_unit = new Init("","I","II","III","IV","V","VI","VII","VIII","IX");
var roman_tens = new Init("","X","XX","XXX","XL","L","LX","LXX","LXXX","XC");
var roman_hund = new Init("","C","CC","CCC","CD","D","DC","DCC","DCCC","CM");
var roman_thou = new Init("","M","MM","MMM","MMMM","MMMMM");

var v = 0; var w = 0; var x = 0; var y = 0;
v = ((number - (number % 1000)) / 1000) + 1;
number = (number % 1000);
w = ((number - (number % 100)) / 100) + 1;
number = (number % 100);
x = ((number - (number % 10)) / 10) + 1;
y = (number % 10) + 1;
return (roman_thou[v] + roman_hund[w] + roman_tens[x] + roman_unit[y]);
}

/***********************************************************************************
The following goes wherever you need the roman year to appear:

<script language="JavaScript"><!-- document.write(Roman(year)) // --></script>

************************************************************************************/



/***********************************************************************************
Image fade show rotator

************************************************************************************/



// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = '/slideshow/mainslide_01.jpg'
Pic[1] = '/slideshow/mainslide_02.jpg'
Pic[2] = '/slideshow/mainslide_03.jpg'
Pic[3] = '/slideshow/mainslide_04.jpg'
Pic[4] = '/slideshow/mainslide_05.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

