/* 	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.
*/

/***********************************************************************************/
//
// 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(); }
   }
/*********************************************************************************
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>

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



/*******************************************************************************
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; }


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>

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

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}