function selectCode(tid) 
{
	tid.focus();
	tid.select();
};
function show(name, sfs) 
{
	hideObjects();
	document.getElementById('overlay').style.display = 'block';
	document.getElementById('niWg').style.display = 'block';
	
	//alert(sfs);
	var str = document.getElementById('code_source').value.replace('_name_', name);
	
	document.getElementById('code').value = str;
	document.getElementById('code').focus();
	document.getElementById('code').select();
//	alert(str);
	scroll(0,0);
	 
}

function hideObjects()
{
//	var hideEmbedCssText = '#niWg{background: #000; position: absolute;z-index:9999; border: solid 1px #fefefe; top: 50%; left: 50%;}	#niWg[id] { position:fixed;	z-index:9999; }	#overlay { position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:999; background-color:#000; -moz-opacity: 0.5; opacity:0.5; filter: alpha(opacity=50); } body, html { height: 100%; } body { overflow-y: hidden; }';
	//var hideEmbedCssText = ' body, html { height: 100%; } body { overflow-y: hidden; }';
	
     //insertStyle(hideEmbedCssText);
	 
	 
	//var hideEmbedCssText1 = ' body, html { height: 100%; } body, html { overflow-y: hidden; overflow-x: hidden; margin: 0px; padding: 0px;}';
	
   // insertStyle(hideEmbedCssText1); 

	
//	 document.body.style.overflowY = 'hidden';
//	 document.body.style.overflowX = 'hidden';
	// insertStyle( hideEmbedCssText);
/*	
  if (document.getElementById) {
    var windowHeight=getWindowHeight();
    if (windowHeight>0) {
      var contentHeight=document.getElementById('content').offsetHeight;
	  alert(contentHeight);
  	}
}
*/
	
	
	
	opacity('overlay', 1, 50, 500);
	opacity('niWg', 1, 100, 500);
	scroll(0,0);
	//alert(document.body.height);
//	 document.getElementById('overlay').style.height = '1000px';
}

function showObjects()
{

	//document.body.style.overflowY = 'scroll';
      
	var hideEmbedCssText = 'body { overflow-y: auto; overflow-x: auto;}';
	insertStyle( hideEmbedCssText);	
	
	// document.body.style.overflowY = 'scroll';
	 //document.body.style.overflowX = 'scroll';	
	//document.getElementById('overlay').style.display = 'none';
	//document.getElementById('niWg').style.display = 'none';	 
	opacity('overlay', 50, 0, 500);
	opacity('niWg', 100, 0, 500);
	
	clearStyle(hStyle);
	
}

function insertStyle ( styleText) 
{ 
	var style = document.createElement('style')
	style.type = 'text/css';
	try 
	{
 		style.appendChild( document.createTextNode( styleText ) );
 	}
 	catch(e) 
 	{ 
 		style.styleSheet.cssText = styleText;
 	}
	 var head = document.getElementsByTagName('head')[0];
	 if (!head) 
	 {
	     head = document.createElement('head');
	     document.body.parentNode.insertBefore(head, document.body);
  	 }
    hStyle = style;
    head.appendChild(style);
	//alert(style);
}

function clearStyle(style) 
{
    if (style.parentNode) style.parentNode.removeChild(style);
}





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 + ")";
	if (opacity == 0) {
		document.getElementById(id).style.display = 'none';		
	}
}

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);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

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)
}

	


