
// Switching div elements on and off

//here you place the ids of every element you want.

function switchId(id){	
	hideallids();
	showdiv(id);
}

function hideAllIds(){
	var ids=new Array('message','shade');
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hideDiv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	var done = false;
	
    //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++;
			
			if(i == opacEnd){
				done = true;	
			}
			
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	
	if(done){// Getting rid of the div
		setTimeout("hideDiv('" + id + "')",millisec);
	}
}

//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 fadeDiv(id) {
	//safe function to fade an element with a specified id
		
	// alert(id + 'will be faded by ' + time + ' milliseconds.');
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		
		if(opacity(id,100,0,500)){
			//
		}
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}


function submitFormUploadPics()
{
	var answer = true;
	
	if(document.upload.upFile.value == ''){
		answer = false;
	}
	
	if(!answer){
		alert('Pick a file');
	}
	return answer;
}

function showDiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function replaceDiv(id, replaceId) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(replaceId).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.replaceId.display = 'none';
		}
		else { // IE 4
			document.all.replaceId.style.display = 'none';
		}
	}
}

function submitTextEditor() {
//make sure hidden and iframe values are in sync before submitting form
//updateRTE('text'); //use this when syncing only 1 rich text editor ("rtel" is name of editor)
updateRTEs(); //uncomment and call this line instead if there are multiple rich text editors inside the form
//alert(document.textEdit.text.value) //alert submitted value
return true; //Set to false to disable form submission, for easy debugging.
}

function goTo(url) {
	document.location.replace(url);	
}


// Window popping
function winPop(url,width,height)
 {
   	window.open(url,"ExternalPlayer","location=false,status=false,scrollbars=false,width=" + width + ",height=" + height);
 	window.ExternalPlayer.moveTo(20,20);
 } 

function moveDiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		var divWidth = document.getElementById(id).style.width;
		var divHeight = document.getElementById(id).style.height;
		
		document.getElementById(id).style.left = screen.width / 2 - 100 + document.body.scrollLeft;
		document.getElementById(id).style.top = screen.height / 2 - 150 + document.body.scrollTop;
	}
		else {
			if (document.layers) { // Netscape 4
				document.id.style.left = screen.width / 2 -100 + document.body.scrollLeft;
				document.id.style.top = screen.height / 2 -140 + document.body.scrollTop;
			}
			else { // IE 4
				document.all.id.style.top = screen.height / 2 -140 + document.body.scrollTop;
				document.all.id.style.left = screen.width / 2 -100 + document.body.scrollLeft;
			}
		}	
}

function respond(respondId) {
	var id = 'respondId';
	
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).value = respondId; 	
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.value = respondId;
		}
		else { // IE 4
			document.all.id.value = respondId;
		}
	}
	
	moveDiv('respond');
	showDiv('respond');
	
}

function help(id,msg) {
		if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).innerHTML = msg; 
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.innerHTML(msg); 
		}
		else { // IE 4
			document.all.id.innerHTML(msg); 
		}
	}
	
	
	//setTimeout("showDiv(" + id + ")",50);
	showDiv(id);
}