var IE6 = (window.VBArray && document.implementation);

if (IE6) try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}  

var win_open_handler = null;

function win_open(url, name, width, height, dwidth, dheight,options){
	if (!dwidth) dwidth = 0;
	if (!dheight) dheight = 0;	
	if (!options) options = '';
	posLeft = (screen.width) ? (screen.width-width)/2 : 0;
	posTop = (screen.height) ? (screen.height-height)/2 : 0;
	var str = 'width='+(width+dwidth)+',height='+(height+dheight)+',left='+0+',top='+0+','+options;
	win_open_handler = window.open(url,name,str);
}

// collapse

//********************************************************
var ExpandImageSrc = appPath + '/images/icon-plus.jpg';
var CollapseImageSrc = appPath + '/images/icon-minus.jpg'; 
var speed = 5;
var increment = 15; 
//********************************************************


//Code
//********************************************************
var iTimer;
//var calcHeight;
function toggleDiv(divToShow, imgID){
	var help = document.getElementById(divToShow);
	
	if(help.style.display != "block") {
		if(imgID){
			document.getElementById(imgID).setAttribute('src',CollapseImageSrc);
		}
		showDiv(divToShow);
		Expand(divToShow);
	}
	else {	
		if(imgID){
			document.getElementById(imgID).setAttribute('src',ExpandImageSrc);
		}
		collapse(divToShow);
	}
}
function Expand(divName) {
	var help = document.getElementById(divName);		
	var height = help.offsetHeight;
	if(height < calcHeight){
		help.style.height = height + (calcHeight - height < increment ? (calcHeight - height) : increment) + "px";
		iTimer = setTimeout( "Expand('" + divName +"')" , speed);
	}
	else{
		clearTimeout(iTimer);
	}	
}		
function collapse(divName) {

	var help = document.getElementById(divName);		
	var height = help.offsetHeight;
	if(height > increment){
		help.style.height = height - increment + "px";
		iTimer = setTimeout( "collapse('" + divName +"')" , speed);
	}
	else{
		clearTimeout(iTimer);
		help.style.height ="100%";
		help.style.display = "none";
	}	
}		
function showDiv(divName){
	var div = document.getElementById(divName);
	div.style.display = "block";
	//calcHeight = div.offsetHeight;
	div.style.height = "0px";
}

