// Decide on Flash
var flashFile, altImageFile, altLink, width, height

function decideOnFlash(flashFile, altImageFile, altLink, width, height)
{
    if (pluginlist.indexOf("Flash")!=-1)
    {
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
    	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
    	document.write('ID="script" width="' +width+ '" height="' +height+ '" align="">');
    	document.write('<param name=movie value="' +flashFile+ '"><param name=quality value=high>');
        document.write('<param name=bgcolor value=#ffffff>'); 
    	document.write('<embed src="' +flashFile+ '" quality=high bgcolor=#ffffff ');
    	document.write('swLiveConnect=false width ="' +width+ '" height="' +height+ '" name="script" align="" ');
    	document.write('type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
    	document.write('</embed>');
    	document.write('</object>');
    }
    else if (altImageFile != '' && altLink != '')
    {
        document.write('<a href="' +altLink+ '"><img src="' +altImageFile+ '" width="' +width+
            '" height="' +height+ '" usemap="#script" border=0></a>');
    }
}

// Detect Plugins

//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer


var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);

if (ie && win) {	pluginlist = /* detectIE("Adobe.SVGCtl","SVG Viewer") + */detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTime.QuickTime","QuickTime") + detectIE("wmplayer.ocx","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
		nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = /* detectNS("image/svg-xml","SVG Viewer") + */detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

//SAMPLE USAGE- detect "Flash"
//if (pluginlist.indexOf("Flash")!=-1)
//document.write("You have flash installed")

// Image Pop Up

// Example
// <a href="toyotatercel.jpg" onClick="imagePopUp(this.href,700,500,'Nick's Car');return false" target=_blank>
var width,height
var image,ext
var cond1,cond2
function imagePopUp(image,width,height,title)
{
    var html
    
    cond1="width="+(width)+"";
    cond2="height="+(height)+"";
    
    html = "<html><head><title>" + title + "</title></head>"
    html += "<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0"
    html += " style='overflow: -moz-scrollbars-none'>"
    html +="<a href='javascript:;' onClick='window.close()'><img src='"+image+"' border=0 alt='Click picture to close window'></a>"
    html += "</body></html>"
    
    ImageWindow=window.open("", "imagepopup"+width,"toolbar=no,scrollbars=no,menubar=no,top=50,left=50,"+cond1+","+cond2);
    ImageWindow.document.write(html)
    ImageWindow.document.close()
    if (ImageWindow) ImageWindow.focus();
}

// Pop Up

// Example
// <a href="http://www.espn.com/" onClick="popUp(this.href,'cs',700,500);return false" target=_blank>
var newWin = null;
function popUp(URL, type, width, height) {
  if (newWin != null && !newWin.closed)
    newWin.close();
  var options="";
  if (type=="nav")
  	options="toolbar,resizable,scrollbars,height="+
      height+",width="+width;
  if (type=="cs")
  	options="resizable,scrollbars,height="+
      height+",width="+width;
  if (type=="console")
    options="resizable,height="+
      height+",width="+width;
  if (type=="fixed")
    options="scrollbars,height="+
      height+",width="+width;
  if (type=="elastic")
    options="toolbar,menubar,scrollbars,"+
      "resizable,location,height="+
      height+",width="+width;
  newWin = window.open(URL, 'newWin', options);
  newWin.focus();
}

function clearDefault(el)
{
    if (el.defaultValue==el.value)
        el.value = "";
    unsetClass(el, "unfilled");
}

function resetDefault(el, defaultValue)
{
    if (el.value=="")
        setClass(el, "unfilled");
    if (el.value=="")
        el.value = defaultValue;
}

function setClass (element, className) {
   var classNames = getClassNames(element);
   var alreadySet = false;
   for (var i = 0; i < classNames.length; i++) {
     if (classNames[i] == className) {
       alreadySet = true;
       break;
     }
   }
   if (!alreadySet) {
     element.className =
/\S/.test(element.className) ? element.className + ' ' + className :
className;
   }
}

function unsetClass (element, className) {
   var pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)');
   element.className = element.className.replace(pattern, '$1$2');
} 

 function getClassNames (element) {
   var classNames = element.className.split(/\s+/g);
   return classNames;
} 


function getWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}