/*

	Oncolex Global JavaScript functions
	Roy Lachica 
	last modified 21.Feb 07
	
*/


//preload mouseover images
pic1= new Image(); 
pic1.src="/images/menu_tab_krefttyper_o.gif";

pic2= new Image(); 
pic2.src="/images/menu_tab_prosedyrer_o.gif";

pic3= new Image(); 
pic3.src="/images/menu_tab_gray_white_separato.gif";

pic4= new Image(); 
pic4.src="/images/menu_tab_white_separato.gif";

pic5= new Image(); 
pic5.src="/images/headers/generalInfoPage_index_o.gif";

pic6= new Image(); 
pic6.src="/images/headers/generalInfoPage_kvali_o.gif";

pic7= new Image(); 
pic7.src="/images/headers/generalInfoPage_forum_o.gif";	
	
pic8= new Image(); 
pic8.src="/images/headers/generalInfoPage_om_o.gif";		

//preload tips en venn bottom
pic9= new Image(); 
pic9.src="/images/toolsPanel_bottom.gif";		
			
			
		


//imgFolder : what folder to read images from
function ImagePlayer(imgFolder)
{	

	if(!imgFolder)
	{
		alert('Bildeplayer ikke riktig initialisert. Mangler parameter bildesekvensID');
	}
	else
	{	
		window.open('/imagePlayer.aspx?id=' + imgFolder ,'ImagePlayerPopup','width=600,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
	}
}


function KeyDowntSetfocus(ctrl)
{
	// process only the Enter key
	if (event.keyCode == 13)
	{
		// cancel the default submit
	event.returnValue=false;
	event.cancel = true;
					
	document.getElementById(ctrl).focus();
	document.getElementById(ctrl).select();
	}
}

function KeyDownHandler(btn)
{
						
	// process only the Enter key
	if (event.keyCode == 13)
	{

		// cancel the default submit
		event.returnValue=false;
		event.cancel = true;
		alert(document.getElementById(btn).id);
		// submit the form by programmatically clicking the specified button
		document.getElementById(btn).click();
	}
}




//function VideoPopup(group,num)
//{
//	var strGroup = parseFloat(group).toString();
//	var strNum = parseFloat(num).toString();
//	alert('uten brightcove');
//	if(strGroup = "NaN" && strNum != "NaN"){				
//		window.open('/video/?clipGrp='+group+'&clipNum='+num,'VideoPopup','width=650,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
//	}else{
//		alert('Video popup ikke riktig initialisert. Mangler parametre');
//	}
//}
//For Brachove
function VideoPopup(group,num)
{
	var arrGroup = group.split(',');
	if(arrGroup.length > 1) 
	{
	    //var strNum = num.toString();
		window.open('/video/?'+ arrGroup[0]+'|'+arrGroup[1],'VideoPopup','width=650,height=640,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
				//window.open('/video/?clipGrp='+group+'&clipNum='+num,'VideoPopup','width=650,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
	}
	else
	{
		window.open('/video/?'+arrGroup[0],+ 'VideoPopup','width=588,height=410,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');
	}
	
}
function StandardPopup(page)
{				
	window.open(page,'StandardPopup','width=400,height=270,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=1,copyhistory=no,resizable=no');
}

		

var urlAddress = "http://www.oncolex.no"; var pageName = "Onkolex - Onkologisk Prosedyreverk "; 

function addToFavorites(){ 
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName) 
	} else { 
		alert("Beklager. Din nettleser støtter ikke denne funksjonen."); 
	} 
} 



function toggleTextSection(id)
{ 
	obj = document.getElementById(id);
	obj.style.display = obj.style.display=='none' ? '' : 'none';
	
	objhidden = document.getElementById(id+'_hidden');
	if(objhidden){				
		objhidden.style.display = objhidden.style.display=='none' ? '' : 'none';
	}
}


	
function toggleShow(targetObjectId,img) 
{	
	swapPlusMinusImg(img);	
	changeObjectVisibility(targetObjectId); 		
	
} 



function swapPlusMinusImg(img){
	
	if(img.src.indexOf('plus.gif')>0){ //cant find image over marker, so display as image over 
 		pos = img.src.indexOf('plus.gif');
		strStart = img.src.substr(0,pos);
		strEnd = img.src.substr(pos,img.src.length-pos);
		img.src = strStart + 'minus.gif';
		//alert(img.src);
	}else{ 	
		pos = img.src.indexOf('minus.gif');
		//alert(pos);
		strStart = img.src.substr(0,pos);	
		//strEnd = img.src.substr(pos+2,img.src.length-pos-2);
		//alert(strEnd);
		img.src = strStart + 'plus.gif';
	}  
}


function hideLayer(targetObjectId) 
{
	if(window.currentlyVisiblePopup) {
		changeObjectVisibility(targetObjectId);		
	}
} 

	

function changeObjectVisibility(objectId) {
	// get a reference to the cross-browser style object and make sure the object exists
	var styleObject = getStyleObject(objectId);
	if(styleObject) {
	//if (styleObject.visibility == 'hidden')
	if (styleObject.display == 'none')
	{
		styleObject.display = '';		
	}else{
		styleObject.display = 'none';			
	}
	} else {
	}
} 
		


function getStyleObject(objectId) {
	// cross-browser function to get an object's style object given its id
	if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
	} else {
	return false;
	}
} // getStyleObject




function setHeight(){	
	obj = document.getElementById('main1');
	obj.style.height = document.body.scrollHeight - 129 + 'px';  //'800px';
}
	

function sendTip()
{    
	CallBack1.Callback(); 
}		


function activateSendTipFriend(){
	obj = document.getElementById('SendTipMailFriend');	
	if(obj)	obj.value = '1';		
}
		
	
function activateSendTipEditors(){
	obj = document.getElementById('SendTipMailEditors');	
	if(obj)	obj.value = '1';		
}


function swapimage(img){
	pos = img.src.indexOf('_o.gif');
	if(pos == -1){ //cant find image over marker, so display as image over 
 		pos = img.src.indexOf('.gif');
		strStart = img.src.substr(0,pos);
		strEnd = img.src.substr(pos,img.src.length-pos);
		img.src = strStart + '_o' + strEnd;
		
	}else{ 	
		strStart = img.src.substr(0,pos);	
		strEnd = img.src.substr(pos+2,img.src.length-pos-2);
		//alert(strEnd);
		img.src = strStart + strEnd;
	}  
}


function hideFrontPageSelectBox(){	
	obj = document.getElementById('_ctl3_ddKreftType');	
	if(obj){	
		obj.style.visibility = 'hidden';
	}	
}




function hideToTopButton(overRide){
	if((document.body.clientHeight >= document.body.scrollHeight) || (overRide)){ 		
		
		obj = document.getElementById('toTop');	
		if(obj){ 	
			obj.style.visibility = 'hidden';
		}	
	}
}	


function navigateTo(whereTo){


}

	
	



			
function ShowTooltip(text1,text2,text3,text4,text5)
{
	document.getElementById("td0").innerText=text1; 
	document.getElementById("td1").innerText=text2;
	document.getElementById("td2").innerText=text3;
	document.getElementById("td3").innerText=text4;			
}



function HideTooltip()
{
	document.getElementById("td0").innerText=""; 
	document.getElementById("td1").innerText="";
	document.getElementById("td2").innerText="";
	document.getElementById("td3").innerText="";	
}



function framePrint(whichFrame){
	parent[whichFrame].focus();
	parent[whichFrame].print();
}

var rowNo = 0;
var lineNo = 0;	

function n_window(theurl)
{
	// set width and height
	var the_width=710;
	var the_height=500;
	// set window position
	var from_top = 20 + (lineNo * 20);
	var from_left = 20 + (lineNo * 20) + (rowNo*40);
	lineNo++;
	if (lineNo>5){
		rowNo ++;
		lineNo=0;
	}
	
	// set other attributes
	var has_toolbar='no';
	var has_location='no';
	var has_directories='no';
	var has_status='no';
	var has_menubar='no';
	var has_scrollbars='yes';
	var is_resizable='no';
	// atrributes put together
	var the_atts='width='+the_width+',height='+the_height+',top='+from_top+',screenY='+from_top+',left='+from_left+',screenX='+from_left;
	the_atts+=',toolbar='+has_toolbar+',location='+has_location+',directories='+has_directories+',status='+has_status;
	the_atts+=',menubar='+has_menubar+',scrollbars='+has_scrollbars+',resizable='+is_resizable;
	window.open(theurl,'',the_atts);	
	window.document.selection.value='';
}




	
	
	
	
	