function startNavList(menuid, menuclass) {
if (document.all&&document.getElementById) {
navRoot = document.getElementById(menuid);
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
	this.className+=" "+menuclass;
 	if(document.getElementById('titlespan'))
  	{	
  		var titlespan = document.getElementById('titlespan');
  		titlespan.style.visibility='hidden';
  	}//end if 
  
  }//end function
  
  node.onmouseout=function() {
  	 this.className=this.className.replace(" "+menuclass, "");
 	if(document.getElementById('titlespan'))
  	{
  		var titlespan = document.getElementById('titlespan');
  		titlespan.style.visibility='visible';
  	}//end if
   }//end function
   }
  }
 }
}

function startNavMenus()
{
	startNavList('navmenuhoriz','over');
}

function toggleOn( targetId ){
   
   var new_target = targetId+'a';
     if (document.getElementById)
     {
        target = document.getElementById( new_target );
        var newClassName = targetId+'on';
        target.className  = newClassName;
		
     }
 
    }

function toggleOff( targetId ){
    var new_target = targetId+'a';
     if (document.getElementById)
     {
        target = document.getElementById( new_target );
        var newClassName = targetId+'off';
        target.className  = newClassName;

     }
 
    }

function turnOff( targetId ){
     if (document.getElementById){
        target = document.getElementById( targetId );
                target.style.display = "none";
            }
        }
        
function turnOn( targetId ){
     if (document.getElementById){
        target = document.getElementById( targetId );
                target.style.display = "block";
				
            }
        }


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 opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

var running = 'true';
var intervalID;
var clickedtransform = 'false';
var image_array =  new Array();
function onClickBlendimage(divid, imageid, imagefile, millisec)
{
	window.clearInterval(intervalID);
	running = 'false';
	clickedtransform='true';
	blendimage(divid, imageid, imagefile, millisec);
	clickedtransform='false';
}

function blendimage(divid, imageid, imagefile, millisec) {
	
	if(running == 'true' || clickedtransform =='true')
	{
			
		var tempimage = document.getElementById(imageid).src;
		
		var speed = Math.round(millisec / 100);
		var timer = 0;
		
		//set the current image as background
		document.getElementById(divid).style.backgroundImage = "url(" + tempimage + ")";
		
		//make image transparent
		changeOpac(0, imageid);
		
		//make new image
		document.getElementById(imageid).src = imagefile;

		//fade in image
		for(i = 0; i <= 99; i++) {
			setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
			timer++;
		}
		
		//alert(tempimage +' : '+imagefile);
	}

	
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}
	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function startImageRotation(div,image)
{
 for (var i = 0; i < image_array.length; i++)
 {	
		//window.setTimeout("blendimage('clickdiv', 'clickimage', '"+image_array[i]+"', '500')", parseInt(i)*2000);
		window.setTimeout("blendimage('"+div+"','"+ image+"', '"+image_array[i]+"', '500')", parseInt(i)*2000);
		
 }
}

function stopImageRotation()
{
 	window.clearInterval(intervalID);
	running = 'false';
	clickedtransform='false';
}

function mouseOverImage(id)
{
	changeOpac('70', id);

}

function mouseOutImage(id)
{
	changeOpac('100', id);
}

function clickStartRotation(div,image,passed_image_array)
{
	running = 'true';
	image_array = passed_image_array;
	startImageRotation(div,image);
	
	intervalID = window.setInterval("startImageRotation('"+div+"','"+image+"')", 8000);
	return true;
}

function selectJump(select_id)
{
	var newIndex = document.getElementById(select_id).selectedIndex; 
var cururl = document.getElementById(select_id).options[document.getElementById(select_id).selectedIndex].value; 
	window.location = cururl;
}

function commercialStartSlideShow()
{
	clickStartRotation('clickdiv','clickimage',image_array);
}

function clearLogin()
{
	if(document.getElementById('username').value=='Username') 
	{
			document.getElementById('username').value=''; 	
			document.getElementById('pass').value=''; 
	}
}
function submitReview()
{	
	//alert('here');
	document.getElementById('open1').style.display = 'none';
	document.getElementById('open2').style.display = 'none';
	
	document.getElementById('closed1').style.display = 'block';
	document.getElementById('closed2').style.display = 'block';
	document.getElementById('closed3').style.display = 'block';
	document.getElementById('closed4').style.display = 'block';
}
