// JavaScript Document
//
//  common.js
//
//--------------------------------------------------------------
//    Contains:
//
//  -- MM Scripts 
// 			MM_preloadImages - load images with page to avoid download lag time upon call
//			MM_findObj - wrapper for getElementByID
//--------------------------------------------------------------
//  -- Common Scripts
//			blockError = don't display error message to user for little things
//			noRightClick = capture RT mouse events and display message.
//			disableText = capture text selection and disable completely
//			showDateTime = displays updated tdate & Time in Statusbar (effectively hiding links on hover
//			do_reload - reload page (duh!)
//			SetLayerToEdge = anchors top-Left of layer and extends to Vert/Horiz/Both edge			
//			stretchBgImage = allow use of smaller BG image; make backgrud image stretch to size of page display.
//			breakoutOfFrameset = Disallow site as Frame in foreign site.						
//--------------------------------------------------------------
//  -- Window Scripts
//			[many]

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];}}
}
MM_preloadImages('images/button_n.gif','images/button_h.gif','images/button_p.gif')


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;
}
//--------------------------------------------------------------

//   BLOCK ERROR  

function blockError(){return true;}
window.onerror = blockError;

//   Disablee Right Mouse actions  

// Set the message for the alert box
am = "Thank You For Your Interest\nIn\nNeo•Paradigms!";

// Setup for browser types
// ===========================
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"
// ===========================
function noRightClick(e) {
   if (bNS && e.which > 1){
      alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     alert(am)
     return false;
   }
}
// ===========================
// activate the script in the page upon load
document.onmousedown = noRightClick;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = noRightClick;

//--------------------------------------------------------------

//	disable page selection of text

function disabletext(e){
return false
}

function reEnable(){
return true
}

// ===========================
// activate the script in the page upon load
//if the browser is IE4+
document.onselectstart=new Function ("return false")

//if the browser is NS6
if (window.sidebar){
document.onmousedown=disabletext
document.onclick=reEnable
}
//---------------------------------------------------------

//	Show Date & Time vs Link info on Hover
function showDateTime() {
   window.setTimeout( "showDateTime()", 100 );
   dt = new Date();
   self.status = dt.toString();
}
showDateTime();
//---------------------------------------------------------

//  Alternate link hide method, just blank it out on mouse event

function hidestatus(){
window.status=''
return true
}

//if (document.layers)
//document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

//document.onmouseover=hidestatus
//document.onmouseout=hidestatus
//---------------------------------------------------------

//	SetLayerToEdge
function do_reload() {location.reload();}

function SetLayerToEdge(layerID,setWidth, SetHeight,iLeft,iTop,iWidth,iHeight) { //v4.1.1
  if (document.layers || document.all || document.getElementById){
  var winWidth, winHeight, width, height, leftX, topY, newWidth, newHeight;

  //onresize = do_reload;

  winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
  winHeight = (document.all)?document.body.clientHeight:window.innerHeight;

  width   = parseInt(iWidth);
  height  = parseInt(iHeight);
  leftX = parseInt(iLeft);
  topY = parseInt(iTop);

    newWidth = (winWidth - leftX);
    if (newWidth<1){
    newWidth = 1;
    }
    newHeight = (winHeight - topY);
    if (newHeight<1){
    newHeight = 1;
    }

    layerObj = (document.getElementById)?document.getElementById(layerID):MM_findObj(layerID);

    if (layerObj!=null) {
    layerObj = (layerObj.style)?layerObj.style:layerObj;
    layerObj.left = (setWidth=="true")?leftX:layerObj.left;
    layerObj.width = (setWidth=="true")?newWidth:layerObj.width;
    layerObj.top = (SetHeight=="true")?topY:layerObj.top;
    layerObj.height = (SetHeight=="true")?newHeight:layerObj.height;
      }
  }//if
}
//---------------------------------------------------------


// STRETCH BACKGROUND 
// assumes the page contains a parent table named "MainTable"
function stretchBgImage() {
	if (document.all.backgroundPic.style.setExpression) {
	 document.all.backgroundPic.style.setExpression("height","document.all.MainTable.offsetHeight");
	 document.recalc();
	}
//alert("in stretchBgImage");
}
ie5 = (document.all && document.getElementById && !document.fireEvent)?true:false;
ie55= (document.all && document.fireEvent && !document.createComment)?true:false;
ie6 = (document.all && document.fireEvent && document.createComment)?true:false;
if (!window.opera && (ie5 || ie55 || ie6)) onload=stretchBgImage;

//---------------------------------------------------------

//	Ensure that page is not usurped by other webpage
function breakoutOfFrameset() {
if(top.location != window.location)
  top.location.replace(window.location.href);
}


//---------------------------------------------------------

//  Window Functions...

// Pass window features as string
function launchwin(winurl,winname,winfeatures)
{
  //This launches a new window and then
  //focuses it if window.focus() is supported.
  newwin = window.open(winurl,winname,winfeatures);
  if(parseInt(navigator.appVersion) >= 4)
  {
    //delay a bit here because IE4 encounters errors
    //when trying to focus a recently opened window
    setTimeout('newwin.focus();',250);
  }
}


// Fill Screen with Window
function launchFullWin(winurl,winname)
{
  //This launches a new window and then
  //focuses it if window.focus() is supported.
    var winl = 0;//screen.width / 2;
    var wint = 0;//screen.height / 2;
  newwin = window.open(winurl,winname,'scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,top=' + wint + ',left=' + winl + ',width=' + screen.width + ',height=' + screen.weight);
  if(parseInt(navigator.appVersion) >= 4)
  {
    //delay a bit here because IE4 encounters errors
    //when trying to focus a recently opened window
    setTimeout('newwin.focus();',250);
  }
}

//  Screen centered, Pass features list as string
function launchCenteredWin(url, name, width, height, otherfeatures)
{
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  newwin = window.open(url, name, str + ',' + otherfeatures);
  if(parseInt(navigator.appVersion) >= 4)
  {
  //delay a bit here because IE4 encounters errors
  //when trying to focus a recently opened window
  setTimeout('newwin.focus();',250);
  }
}

//  Defualt winPos and size, allow scrolling and resize, no other features.
function launchNewsWin(winurl,winname)
{
  //This launches a new window and then
  //focuses it if window.focus() is supported.
  newwin = window.open(winurl,winname,'scrollbars=yes,resizable=yes,width=800,height=600');
  if(parseInt(navigator.appVersion) >= 4)
  {
    //delay a bit here because IE4 encounters errors
    //when trying to focus a recently opened window
    setTimeout('newwin.focus();',250);
  }
}

//  Window fills screen, chromeless and no way to get a hold of.  Don't do this!
function launchWallpaper(winurl,winname)
{
  //This launches a new window and then
  //focuses it if window.focus() is supported.
  newwin = window.open(winurl,winname,'scrollbars=no,resizable=no,width=515,height=385');
  if(parseInt(navigator.appVersion) >= 4)
  {
    //delay a bit here because IE4 encounters errors
    //when trying to focus a recently opened window
    setTimeout('newwin.focus();',250);
  }
}


// Scrolling is only option.  No window features other than scroll  if allowed
function openChromelessWindow(openUrl, winName, wWidth, wHeight, canScroll){
  var posx = 0;
  var posy = 0;
  var resize = "no"

  posx = Math.ceil( (window.screen.width  - wWidth) / 2 );
  posy = Math.ceil( (window.screen.height - wHeight) / 2 );
  if (canScroll) { resize="yes"}

  var sFeatures = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + resize + ",resizable=no,width=" + wWidth + ",height=" + wHeight + ",top=" + posy + ",left=" + posx;

  var splashWin = window.open(openUrl, winName, sFeatures, true);

  splashWin.focus();

}


// Neo specific; open movie in a formated window
function popMedia(openUrl, wWidth, wHeight){
  var posx = 0;
  var posy = 0;
  var adjHeight = wHeight + 140;
  var adjWidth = wWidth + 60;
  var movieWidth = "" + wWidth;
  var movieHeight = "" + wHeight;
  var fullURL = openUrl + "?mvW=" + movieWidth + "?mvH=" + movieHeight;

  posx = Math.ceil( (window.screen.width  - wWidth) / 2 );
  posy = Math.ceil( (window.screen.height - wHeight) / 2 );

  var sFeatures = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=" + adjWidth + ",height=" + adjHeight + ",top=" + posy + ",left=" + posx;

  var splashWin = window.open(fullURL , "mpop", sFeatures, true);

  splashWin.focus();

}

// Begin POP-UP SIZES AND OPTIONS CODE

function popUpWindow(URL) {
var slideshow_width = 708
var slideshow_height = 700
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+slideshow_width+',height='+slideshow_height+'');");
}

// Neo specific
function popUp(URL,iWidth,iHeight,sTag) {
var view_width = iWidth + 60;
var view_height = iHeight + 140;
var posx = 0;
var posy = 0;

posx = Math.ceil( (window.screen.width  - view_width) / 2 );
posy = Math.ceil( (window.screen.height - view_height) / 2 );

var look='toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,top='+posy+',left='+posx+',width='+view_width+',height='+view_height+','
popwin=window.open("","",look)
popwin.document.open()
popwin.document.write('<html><head><title>NeoParadigms designs the Traditional to the Outrageous!</title>')
popwin.document.write('<link rel=StyleSheet href="neo2003.css" type="text/css" media="screen">')
popwin.document.write('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">')
popwin.document.write('<script language="JavaScript">')
popwin.document.write('function noRightClick() {')
popwin.document.write('if (event.button==2) {')
popwin.document.write('alert(\'Thank you for your interest in Neo•Paradigms!\')')
popwin.document.write('}')
popwin.document.write('}')
popwin.document.write('document.onmousedown=noRightClick')
popwin.document.write('</script>')
popwin.document.write('</head>')
popwin.document.write('<body bgcolor="#02445C" background="images/background-pop-ups.jpg" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0" class="popup">')
popwin.document.write('<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center">')
popwin.document.write('<br><center>')
popwin.document.write('<TABLE cellpadding="15" cellspacing="0" border="1" bordercolor="#FFFFFF" style="border-collapse: collapse"><tr><td>')
popwin.document.write('<img src="'+URL+'"><br>')
popwin.document.write('</td></tr></table>')
popwin.document.write('</td></tr>')

// If a desription is present, print it.
if (sTag != "") {
popwin.document.write('<tr><td valign="top" align="center">' + sTag )
popwin.document.write('</td></tr>')
}

popwin.document.write('<tr><td valign="top" align="center">')
popwin.document.write('<br><form><input type=submit value="Close" onmouseover="this.className=\'buttonon-popups\'" onmouseout="this.className=\'button-popups\'" class="button-popups" onClick=\'self.close()\'></form><br>')
popwin.document.write('</center>')
popwin.document.write('</td></tr></table>')
popwin.document.write('</body></html>')
popwin.document.close()
}

// Neo specific
function popUpWeb(URL,sTag) {
var view_width = 708
var view_height = 700
var look='toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+view_width+',height='+view_height+','
popwin=window.open("","",look)
popwin.document.open()
popwin.document.write('<html><head><title>NeoParadigms designs the Traditional to the Outrageous!</title>')
popwin.document.write('<link rel=StyleSheet href="neo2003.css" type="text/css" media="screen">')
popwin.document.write('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">')
popwin.document.write('<script language="JavaScript">')
popwin.document.write('function noRightClick() {')
popwin.document.write('if (event.button==2) {')
popwin.document.write('alert(\'Thank you for your interest in Neo•Paradigms!\')')
popwin.document.write('}')
popwin.document.write('}')
popwin.document.write('document.onmousedown=noRightClick')
popwin.document.write('</script>')
popwin.document.write('</head>')
popwin.document.write('<body bgcolor="#02445C" background="images/background-pop-ups.jpg" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginheight="0" marginwidth="0" class="popup">')
popwin.document.write('<TABLE cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center">')
popwin.document.write('<br><center>')
popwin.document.write('<TABLE cellpadding="15" cellspacing="0" border="1" bordercolor="#FFFFFF" style="border-collapse: collapse"><tr><td>')
popwin.document.write('<img src="'+URL+'"><br>')
popwin.document.write('</td></tr></table>')
popwin.document.write('</td></tr>')

// If a desription is present, print it.
if (sTag != "") {
popwin.document.write('<tr><td valign="top" align="center">' + sTag )
popwin.document.write('</td></tr>')
}

popwin.document.write('<tr><td valign="top" align="center">')
popwin.document.write('<br><form><input type=submit value="Close" onmouseover="this.className=\'buttonon-popups\'" onmouseout="this.className=\'button-popups\'" class="button-popups" onClick=\'self.close()\'></form><br>')
popwin.document.write('</center>')
popwin.document.write('</td></tr></table>')
popwin.document.write('</body></html>')
popwin.document.close()
}



// Begin full screen

function fullScreen() {
  window.open(location.href,'fullscreen','fullscreen,scrollbars')
}

// End -->
