function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

var ban = 1;
var vidPlaying = 0;

function initImage(imageId) {
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  //alert(opacity);
  obj.style.filter = "alpha(opacity:" + opacity + ")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}
function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj, opacity);
      opacity -= 10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
    }
  }
}

function imageChange(){
	if(vidPlaying != 1){
	document.getElementById('showerImg').src = 'images/vidThumb' + ban + '.jpg';
/*	if(!isIE()){
		window.setTimeout('fadeOut(\'text' + ban + '\',90)',10);
	}else{
		document.getElementById('text' + ban).style.visibility = 'hidden';
	}*/
	ban++;
	if(ban > 10){
		ban=1;
	}
	document.getElementById('fader').style.visibility = 'hidden';
	document.getElementById('fader').style.filter = "alpha(opacity:0)";
	document.getElementById('faderImg').src = 'images/vidThumb' + ban + '.jpg';
	window.setTimeout('initImage(\'fader\')',10);
	
/*	if(!isIE()){
		document.getElementById('text' + ban).style.filter = "alpha(opacity:0)";
		window.setTimeout('initImage(\'text' + ban + '\')',10);
	}else{
		document.getElementById('text' + ban).style.visibility = 'visible';
	}*/
	}
}
function updateBKG(){
	var ratio = 2255/2180;
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
		if(document.body.offsetWidth > document.body.offsetHeight){
			document.getElementById('background').width=document.body.offsetWidth;
			temp = Math.round(document.body.offsetWidth/ratio);
			document.getElementById('background').height = temp;
		}else{
			document.getElementById('background').height=document.body.offsetHeight;
			temp = Math.round(document.body.offsetHeight*ratio);
			document.getElementById('background').width=temp;
		}
	}else{
		if(window.innerWidth > window.innerHeight){
			document.getElementById('background').width=window.innerWidth;
			temp = Math.round(window.innerWidth/ratio);
			document.getElementById('background').height = temp;
		}else{
			document.getElementById('background').height=window.innerHeight;
			temp = Math.round(window.innerHeight*ratio);
			document.getElementById('background').width=temp;
		}
	}
}
function cssClassChange(cl,theid) {
	var e = document.getElementById(theid);
    e.setAttribute("className",cl);//for IE       
    e.setAttribute("class",cl);
}
function confirmSubmit(){
	var agree=confirm("Are you sure you want to delete this?");
	if (agree){
		return true ;
	}else{
		return false ;
	}
}

function swapImgRestore() {
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function swapTopImgRestore() {
	var i,x,a=document.srt; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { 
	var d=document;
	if(d.images){
		if(!d.p) d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments;
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){
			 d.p[j]=new Image; 
			 d.p[j++].src=a[i];
		}
	}
}

//preloading the mouseover images
function preloadAllImages() {

	//buttons on the top bar that are only on this index page
	preloadImages('images/icon-downloadHL.png');
	preloadImages('images/icon-chatHL.png');
	preloadImages('images/icon-helpHL.png');
	preloadImages('images/icon-demoHL.png');
}

function findObj(n, d) {
	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=findObj(n,d.layers[i].document);
	return x;
}

function swapImageTop() {
	var i,j=0,x,a=swapImageTop.arguments;
	document.srt=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){
		document.srt[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function swapImage() {
	var i,j=0,x,a=swapImage.arguments;
	document.sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){
		document.sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}
