
//Parses URL (multiple uses)

//entire url
var url = window.location.toString();

//array of entire url
//[0] -> http:
//[1] -> (empty string)
//[2] -> cabig.cancer.gov
//[3] -> default.asp
var urlparts = url.split('/');


//******************************FADING DIVS*******************************************//

var fadeSelected = 0;
var next = 0;
var fadeTimeout = 0;

function fadeIn(id){

	if(fadeTimeout) { window.clearTimeout(fadeTimeout); }
	
	if(fadeSelected != 0){
		$("#fade_" + fadeSelected).fadeOut(2000);
	}
	else {
		$("#fade_1").fadeOut(2000);
	}		
	$("#fade_" + id).fadeIn(2000);

	fadeSelected = id;
	setImageTimeout();
}

function setImageTimeout(){
	if(fadeSelected != 0){
		if(fadeSelected == 3){
			next = 1;
		}
		else{
			next = fadeSelected + 1;
		}
	}
	else{
		next = 2;
	}
	fadeTimeout = window.setTimeout("fadeIn(next)", 20000);
}


//******************************DROP DOWN MENU*******************************************//

var ddmenuitem	= 0;
//rounded bottom
var ddmenuitem_bottom = 0;
var cont = 0;
var cont_id = 0;
var temp = 0;


var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);

function mopen(container, id){


if (browser=="Microsoft Internet Explorer"){
	if(urlparts[3] == "default.asp" || urlparts[3] == ""){
		//because ie6 makes my life miserable every day
		document.getElementById("fade").style.zIndex = "-1";
		document.getElementById("fade_1").style.zIndex = "-1";
		document.getElementById("fade_2").style.zIndex = "-1";
		document.getElementById("fade_3").style.zIndex = "-1";
	}
}
	
	
	if(ddmenuitem) {
		ddmenuitem.style.visibility = 'hidden';
		//hides rounded bottom
		ddmenuitem_bottom.style.visibility = "hidden";
	}

	cont = document.getElementById(container)
	temp = container.split("_");
	cont_id = temp[0];
	cont.style.background = "url('/objects/images/index_r2_" + cont_id + "_f3.jpg')";
	
	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
		
	//shows rounded bottom
	ddmenuitem_bottom = document.getElementById(id+"_bottom")
	ddmenuitem_bottom.style.visibility = "visible";
}

function mout(){

if (browser=="Microsoft Internet Explorer"){
	if(urlparts[3] == "default.asp" || urlparts[3] == ""){
		//because ie6 makes my life miserable every day
		document.getElementById("fade").style.zIndex = "1";
		document.getElementById("fade_1").style.zIndex = "1";
		document.getElementById("fade_2").style.zIndex = "1";
		document.getElementById("fade_3").style.zIndex = "1";
	}
}

	if(cont) { 
		if(!temp[1]){
		cont.style.background = "url('/objects/images/index_r2_" + cont_id + "_f2.jpg')"; 
		}
	}
	
	if(ddmenuitem){
		ddmenuitem.style.visibility = "hidden";
		//hides rounded bottom
		ddmenuitem_bottom.style.visibility = "hidden";
	}
}


//******************************BOX CONTENT ROTATE*******************************************//

var boxImageList = new Array();
var boxQuoteList = new Array();
var boxSaidByList = new Array();

var boxTimeout = 0;

//counter 
var boxCounter = 0;

//0 if playing, 1 if paused
var pause = 0;

//boxImageList[0] = "/objects/images/quotepic1.jpg";
boxImageList[0] = "/objects/images/quotepic3.jpg";
boxImageList[1] = "/objects/images/quotepic2.jpg";
boxImageList[2] = "/objects/images/quotepic4.jpg";

//boxQuoteList[0] = "&quot;caBIG<span class='sup'>&reg;</span> is, I believe, the most important initiative undertaken by the cancer research enterprise in the entire history of the war on cancer.&quot;";
boxQuoteList[0] = "&quot;We were particularly impressed by the scope and vision of this ambitious program, which is playing such a critical role in shaping the future of cancer research.&quot;"
boxQuoteList[1] = "&quot;What is required in cancer research to find definitive answers is a system to share data and leverage all the events in the cancer world. caBIG<span class='sup'>&reg;</span> is, therefore, right on target.&quot;";
boxQuoteList[2] = "&quot;I view caBIG<span class='sup'>&reg;</span> as being absolutely essential to our strategic mission. &quot;";

//boxSaidByList[0] = "<span class='saidByName'>Anna Barker, Ph.D.</span><br/><span class='saidByTitle'>Deputy Director, Strategic Scientific Initiatives<br/>National Cancer Institute</span>";
boxSaidByList[0] = "<span class='saidByName'>Kevin Davies</span><br/><span class='saidByTitle'>Editor in Chief<br/>Bio-IT World</span>";
boxSaidByList[1] = "<span class='saidByName'>Kim Lyerly, M.D.</span><br/><span class='saidByTitle'>Director<br/>Duke Comprehensive Cancer Center</span>";
boxSaidByList[2] = "<span class='saidByName'>Louis Weiner, M.D.</span><br/><span class='saidByTitle'>Director<br/>Lombardi Comprehensive Cancer Center Georgetown University</span>";

function loadBoxContent(counter){
	
	if(boxTimeout) { window.clearTimeout(boxTimeout); }

	document.getElementById("boxImage").src = boxImageList[counter];
	document.getElementById("quote").innerHTML = boxQuoteList[counter];
	document.getElementById("saidBy").innerHTML = boxSaidByList[counter];
	
	if(pause == 0){
		initializeTimer();
	}
	
	//TEST
	//console.log(counter);
	
}

function initializeTimer(){
	boxTimeout = window.setTimeout("nextBox()", 10000);
}

function nextBox(){
	if(boxCounter == (boxImageList.length - 1)){
			boxCounter = 0;
	}
	else boxCounter++;
	loadBoxContent(boxCounter);
}

function lastBox(){
	if(boxCounter == 0){
		boxCounter = boxImageList.length - 1;
	}
	else boxCounter--;
	loadBoxContent(boxCounter);
}

function pauseTimer(){
	if(boxTimeout) { window.clearTimeout(boxTimeout); }
	pause = 1;
	
	var pausebutton = document.getElementById("pause");

	pausebutton.onclick = function(){ 
		playTimer();
	}
	pausebutton.src = "/objects/images/play.gif";
}

function playTimer(){
	pause = 0;
	initializeTimer();
	
	var playbutton = document.getElementById("pause");

	playbutton.onclick = function(){ 
		pauseTimer();
	}
	playbutton.src = "/objects/images/pause.gif";
}

//******************************VIDEO ARCHIVE PAGE******************************//

var videoDiv = 0;
var videoSubDiv = 0;
var videoDivMiddle = 0;
var top = 0;
var bottom = 0;
var middle = 0;

function selectvideo(id){
	
	if(videoDiv){
		top.innerHTML = "<img src='/objects/images/video_whitetop.jpg'>";
		bottom.innerHTML = "<img src='/objects/images/video_whitebottom.jpg'>";
		middle.style.borderLeft = "none";
		middle.style.borderRight = "none";
		middle.style.width = "202px";
	}
	
	videoDiv = "video" + id;
	videoTop = id + "top";
	videoBottom = id + "bottom";
	
	middle = document.getElementById(videoDiv);
	middle.style.width = "198px";
	middle.style.borderLeft = "solid 2px #31bff2";
	middle.style.borderRight = "solid 2px #31bff2";
	
	top = document.getElementById(videoTop);
	top.innerHTML = "<img src='/objects/images/video_whitetop_selected.jpg'>"
	
	bottom = document.getElementById(videoBottom);
	bottom.innerHTML = "<img src='/objects/images/video_whitebottom_selected.jpg'>"
	
	chooseItem(id);

}

//******************************HOMEPAGE******************************//

function execute(){
	setImageTimeout()
	loadBoxContent(boxCounter);	
}


//******************************PRINT-FRIENDLY VIEW******************//

function Clickheretoprint()
{ 
  var disp_setting="toolbar=no,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("news_interior_content").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>caBIG</title>');
   docprint.document.write('<style type="text/css">');
   docprint.document.write('body{ font-family:sans-serif; font-size:12px; color:#000000; line-height:18px;}')
   docprint.document.write('.news_section_head{ font-size: 11pt; color: #60a7c6; font-weight: bold;}')
   docprint.document.write('#img_in_text{float: right;padding: 10px;}');
   docprint.document.write('</style>')
   docprint.document.write('</head><body onLoad="self.print()">');
   docprint.document.write("<div style='width:500px;padding-left:20px;'>")
   docprint.document.write('<img src="/objects/images/cabig_logo.jpg" alt="caBIG"/><br/><br/>')
   docprint.document.write(content_vlue);          
   docprint.document.write('</div></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}





//******************************HIDE/SHOW TEXT*******************************************//




function show(id){
	document.getElementById(id).style.display = "block";
	document.getElementById(id + "_img").src = "/objects/images/bullet_expanded.gif";
	document.getElementById(id + "_a").href = "javascript:hide(" + id + ")";
}

function hide(id) {
	document.getElementById(id).style.display = "none";
	document.getElementById(id + "_img").src = "/objects/images/bullet_collapsed.gif";
	document.getElementById(id + "_a").href = "javascript:show(" + id + ")";
}



function show_noimg(id){
	document.getElementById(id).style.display = "block";
}


function hide_noimg(id){
	document.getElementById(id).style.display = "none";

}





