function showSend2Friend() {
  var friendbkg = document.getElementById("friendbkg");
  var send2friend = document.getElementById("send2friend");
  var friendHeight = 180;
  myHeight = (window.innerHeight / 2) - friendHeight
	|| document.documentElement.scrollTop + (document.documentElement.clientHeight/2 - friendHeight)
	|| document.body.scrollTop + (document.body.clientHeight/2 - friendHeight);
  friendbkg.style.height = document.body.clientHeight + 'px';
  send2friend.style.top = myHeight + 'px';
  friendbkg.className = 'sendShow';
  send2friend.className = 'sendShow';
}

function closeSend2Friend() {
  var friendbkg = document.getElementById("friendbkg");
  var send2friend = document.getElementById("send2friend");
  friendbkg.className='sendHidden';
  send2friend.className='sendHidden';
}

function MM_setTextOfTextfield(objId,x,newText) { //v9.0
  with (document){ if (getElementById){
    var obj = getElementById(objId);} if (obj) obj.value = newText;
  }
}

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];}
}

function P7_MultiClass2() { //v1.0 by PVII
 var args=P7_MultiClass2.arguments;if(document.getElementById){
  for(var i=0;i<args.length;i+=2){if(document.getElementById(args[i])!=null){
  if(document.p7setdown){for(var k=0;k<p7dco.length-1;k+=2){
  if(args[i]==p7dco[k]){args[i+1]=p7dco[k+1];break;}}}
  document.getElementById(args[i]).className=args[i+1];}}}
}

function flevToggleCheckboxes() { // v1.1
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	var sF = arguments[0], bT = arguments[1], bC = arguments[2], oF = MM_findObj(sF);
    for (var i=0; i<oF.length; i++) {
		if (oF[i].type == "checkbox") {if (bT) {oF[i].checked = !oF[i].checked;} else {oF[i].checked = bC;}}} 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function unblur() {
  this.blur();
}

function blurLinks() {
  if (!document.getElementById) return;
  theLinks = document.getElementsByTagName("A");
  theAreas = document.getElementsByTagName("AREA");
  for(i=0; i<theLinks.length; i++) {theLinks[i].onfocus = unblur;}
  for(i=0; i<theAreas.length; i++) {theAreas[i].onfocus = unblur;}
} 
  
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;
 
      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

/***********************************************************************
                 Angelwatt Image Viewer version 1.1.3
************************************************************************
Author: Kendall Conrad of Angelwatt.com
Home page: http://www.angelwatt.com/coding/image_viewer.php
Description: Takes links to images and makes the links show the image on
the page rather than opening a new page.
License:
* This work is licensed under a Creative Commons Attribution-Share Alike
  3.0 United States License 
  http://creativecommons.org/licenses/by-sa/3.0/us/
Last Update: 2008-04-02
***********************************************************************/
function AngelwattImageViewer(id)
{
	
  /****  User Settings  ****/
  // Loading image: path/file.jpg
  var loadImg   = 'loading.gif';
  var bgOpacity = 0.80;     // Background opacity: 0-1 (except for IE)
  var textColor = '#fff';  // Text color for loading message
  var bgColor   = '#000';  // Background color for the slide
  /**** End User Settings ****/
  
  var y, yScroll, yPage, x, centerY, centerX;
  var regImg = /\.(jpg|jpeg|gif|png|bmp)$/i; // match image types

  CenterImg = function (image) {
    image.style.top = centerY - ((image.height + 40) / 2) +"px";
    image.style.left = centerX - (image.width / 2) +"px";
    if (parseInt(image.style.top,10) < yScroll) {
      image.style.top = yScroll +'px';
    }
  };
  ShowImg = function () {
    i = document.getElementById('slideImg');
    CenterImg(i);
    i.style.zIndex = 5; // bring image to front
    slideLoad.innerHTML = ''; // remove loading message
  };
  HideSlide = function () {
    slide.style.display = 'none';
    if (document.getElementById('slideImg')) {
      document.getElementById('slideImg').parentNode.removeChild(
        document.getElementById('slideImg'));
    }
  };
  FindLinkedImages = function(id) {
    var links;
    if (id != null) {
      links = document.getElementById(id).getElementsByTagName('a');
    }
    else { links = document.getElementsByTagName('a'); }
    for (var a=0, l=links.length; a < l; a++) {
      if (regImg.test(links[a].href)) {
        links[a].onclick=function(e){ChangeSlide(this); return false;};
      }
    }
  };
  ChangeSlide = function (target) {
    var img = new Image();
    if (loadImg != '') {
      slideLoad.innerHTML = '<img src="'+ loadImg +' "'+
        'alt="Loading" width="20" height="20" '+
        'style="position:relative; display:inline; z-index:2; '+
        'margin:0 auto; padding:0; border:none; cursor:default;" />'+
        '<br />Loading...';
    }
    else { slideLoad.innerHTML = 'Loading...'; }
    slide.style.display = 'block'; // put up slide with loading msg

    // Get screen height, viewport height
    y = window.innerHeight
       || document.documentElement.clientHeight
       || document.document.clientHeight;
    // find horizontal page position
    yScroll = window.pageYOffset
       || document.documentElement.scrollTop
       || document.body.scrollTop;
    // Get full height of the page
    yPage = self.innerHeight + window.scrollMaxY
       || document.body.scrollHeight
       || document.body.offsetHeight;
    // Set slide background to full height of page
    document.getElementById('slideBG').style.height =
      (yPage < y) ? '100%' : yPage + "px";
    // Get page width
    x = window.innerWidth
       || document.documentElement.clientWidth
       || document.body.clientWidth;
    centerY = y/2 + yScroll;
    centerX = x/2;
    // center loading image
    slideLoad.style.marginTop = centerY-64 +"px";

    img.onload = function()
    {
      /*** Create image tag and style it ***/
      img.id    = 'slideImg';
      img.alt   = '';
      img.title = 'Click to close';
      img.style.position = 'absolute';
      img.style.display  = 'block';
      img.style.margin   = '0 auto';
      img.style.border   = '20px solid #fff';
      img.style.cursor   = 'pointer';
      img.style.zIndex   = 0; // hide the image away until loaded
      img.onclick = HideSlide;

      CenterImg(img); // attempt to center it
      // add slide to page
      slide.insertBefore(img, slide.firstChild);
      ShowImg(); // needed for IE
    };
    img.src = target.getAttribute('href');
  };
  // Create slide HTML and assign styling
  var slide = document.createElement('div');
  slide.id             = 'slide';
  slide.style.display  = 'none';
  slide.style.position = 'absolute';
  slide.style.top      = '0px';
  slide.style.left     = '0px';
  slide.style.width    = '100%';
  slide.style.height   = '100%';

  // Create and style background
  var sBg = document.createElement('div');
  sBg.id                    = 'slideBG';
  sBg.style.position        = 'absolute';
  sBg.style.top             = '0px';
  sBg.style.left            = '0px';
  sBg.style.margin          = '0 auto';
  sBg.style.width           = '100%';
  sBg.style.textAlign       = 'center';
  sBg.style.backgroundColor = bgColor;
  sBg.style.opacity         = bgOpacity;
  sBg.style.filter = 'alpha(opacity='+ bgOpacity*100 +')';
  sBg.style.zIndex          = '2';
  sBg.onclick               = HideSlide;

  // Create and style loading message
  var slideLoad = document.createElement('p');
  slideLoad.style.margin   = '0 auto';
  slideLoad.style.fontSize = '12px';
  slideLoad.style.color    = textColor;

  // Build slide
  sBg.appendChild(slideLoad);
  slide.appendChild(sBg);
  body = document.getElementsByTagName('body')[0];
  body.appendChild(slide);
  body.style.height = "100%";
  FindLinkedImages(id);
}
/*** Ensure onload isn't overwritten ***/
function appendOnLoad(fx)
{ 
  var old = window.onload;
  if (typeof old != 'function') { window.onload = fx; }
  else { window.onload = function() { old(); fx(); }; }
}
/*** SlideShow argument is the id attribute to element where there are
linked images that need the slide show functionality. Providing no
arguments will result in it searching out all links to images. ***/
//appendOnLoad ( function() { AngelwattImageViewer(); } );

function setField(id, value) {
  var field = document.getElementById(id);
  field.value = value;
}

function setCookie(c_name,value,expiredays) {
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
  if (document.cookie.length>0) {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      c_end = document.cookie.indexOf(";",c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
      }
    }
  return "";
}

function isValidEmail(email) {
  if ((email.indexOf('@') < 0) || ((email.charAt(email.length-4) != '.')
	&& (email.charAt(email.length-3) != '.'))) {
	  return false;
  }
  return true;
}

function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); }
