// JavaScript Document

var popUpWin=0;

function popUpWindow(width, height, URLStr)
  {
    if (typeof(SymRealWinOpen)!="undefined")
        window.open = SymRealWinOpen;

    var left = (screen.width/2) - width/2;
    var top = (screen.height/2) - height/2;
    if(popUpWin)
      {
        if(!popUpWin.closed) popUpWin.close();
      }
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
    if (popUpWin==null)
        ; //alert("Please enable popups for this site");
    else
        popUpWin.focus()
  }

function popUpWindowFlexible(width, height, URLStr)
  {
    if (typeof(SymRealWinOpen)!="undefined")
        window.open = SymRealWinOpen;

    var left = (screen.width/2) - width/2;
    var top = (screen.height/2) - height/2;
    if(popUpWin)
      {
        if(!popUpWin.closed) popUpWin.close();
      }
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=Yes,menubar=no,scrollbars=Yes,resizable=Yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
    if (popUpWin==null)
        ; //alert("Please enable popups for this site");
    else
        popUpWin.focus()
  }

function getElement(id)
  {
  	return typeof(document.getElementById)=="undefined" ?
           document.all[id] : document.getElementById(id);
  }
 

function showElement(id)
  {
	getElement(id).style.display = '';		  
  }
  
function hideElement(id)
  {
	getElement(id).style.display = 'none';		  
  }


function setCookie (name, value)
  {
    var date = new Date();
    if (typeof(date.setFullYear)!="undefined")
       date.setFullYear(date.getFullYear()+2);
    else
       date.setYear(date.getYear()+2);
    document.cookie = name + "=" + escape(value) + ";path=/;expires=" + date.toGMTString();
  }
  
function setTimeZoneCookie()
  {
	var visitortime = new Date();
	setCookie('TimezoneOffset', visitortime.getTimezoneOffset()/60);
  }
  
setTimeZoneCookie();

function showMenu(me) 
 {
	for(var i=0; i<me.childNodes.length; i++)	{
		var node = me.childNodes[i];
		if (node.className=='subMenu') {
			node.style.display = '';
		}
	}
 }

function hideMenu(me) 
 {
	for(var i=0; i<me.childNodes.length; i++)	{
		var node = me.childNodes[i];
		if (node.className=='subMenu') {
			node.style.display = 'none';
		}
	}
 }

var min=8;
var max=16;
var tags = ['p','div','li','td','a'];
function increaseFontSize() {
   for (var i in tags) {
	   var tag = tags[i];
	   var p = document.getElementsByTagName(tag);
	   for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 12;
		  }
		  if(s!=max) {
			 s += 1;
		  }
		  p[i].style.fontSize = s+"px"
	   }
   }
}
function decreaseFontSize() {
   for (var i in tags) {
	   var tag = tags[i];
	   var p = document.getElementsByTagName(tag);
	   for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 12;
		  }
		  if(s!=min) {
			 s -= 1;
		  }
		  p[i].style.fontSize = s+"px"
	   }   
   }
}

slideTimer  = null;
nextSlideName = null;
function nextSlide(name, trans)
  {
	if (trans==null) trans=true;
	currentSlide = name;  
	var preLoad = slides[name]['preLoad'];
	if (document.all && trans)
	  {
		document.images[name].style.filter="blendTrans(duration=2)"
		document.images[name].style.filter="blendTrans(duration=crossFadeDuration)"
		document.images[name].filters.blendTrans.Apply()
	  }
	document.images[name].src = preLoad[slides[name]['slidei']].src;
	document.images[name].alt = preLoad[slides[name]['slidei']].alt;
	document.images[name].onclick = linkURL;
	if (document.all && trans)
	  {
		document.images[name].filters.blendTrans.Play()
	  }
	slides[name]['slidei']++;
	if (slides[name]['slidei'] == slides[name]['pictures'].length) slides[name]['slidei'] = 0;
	slideTimer = setTimeout("nextSlide('" + name + "')", slides[name]['speed']);
 }

slides = [];

function showSlide(name, pictures, speed, links)
  {
	var preLoad = [];
	for (i = 0; i < pictures.length; i++)
	  {
		preLoad[i] = new Image();
   	    preLoad[i].src = pictures[i];
		preLoad[i].alt = links[i];

	  }
	slides[name] = { 'slidei' : 1, 'pictures' : pictures, 'speed' : speed, 'preLoad' : preLoad, 'links' : links };
	nextSlide(name);
  }
  
function CPauseSlide(name) {
	if (slideTimer)
		clearTimeout(slideTimer);
}

function CNextSlide(name) {
	CPauseSlide(name);
	nextSlide(name, false);
}

function CResetSlide(name) {
	CPauseSlide(name);
	slides[name]['slidei'] = 1;
	nextSlide(name, false);
}

function linkURL(event)
  {
	//location.href = this.alt;
  }

function blogDialog(id, show) 
  {
	var button = id + '_button';
	var form   = id + '_form';
	if (show) {
		showElement(form);
		hideElement(button);
	} else {
		hideElement(form);
		showElement(button);
	}
  }
  
function validateBlog(form) {
	var name = String(form.Name.value);
	var email = String(form.Email.value);
	var comment = String(form.Comment.value);
	
	if (name.length<3) {
		alert("Please enter your name");
		return false;
	}
	if (!email.match(/^[^@]*@.+/, email)) {
		alert("Please enter a valid email address");
		return false;
    }
	if (comment.length<3) {
		alert("Please enter a comment");
		return false;
	}
	alert("Thank you for your comment.   Your comment will be added to the blog after review");
}
