function labelMng(elmt, txt, mode)
{
	if(elmt.value == '' && mode == true)
		elmt.value= txt;
	if(elmt.value == txt && mode == false)
		elmt.value= '';

}

function download(file) {
	if (file) {
		open (file);
	}
	else {
		alert("Sorry the file you were looking for doesn't exist!");
	}
}


function shareIt(to, sURL, sTitle)
{
	if(to=='fb')
	{
		var f='http://www.facebook.com/sharer.php?src=bm&v=4&i=1254492933&u='+sURL+'&t='+sTitle;
		window.open(f,'sharer','toolbar=0,status=0,resizable=1,width=626,height=420');
	}
	if(to=='tw')
	{
		var f='http://twitter.com/share?_=1285591967324&count=none&original_referer='+sURL+'&text='+sTitle+'&url='+sURL+'&via=cpuid_softwares';
		window.open(f,'twitter','toolbar=0,status=0,resizable=1,width=650,height=450');
	}
	if(to=='dg') {
		var f='http://digg.com/submit?phase=2&url='+sURL+'&title='+sTitle+'&bodytext='+sTitle+'&topic=technology';
		window.open(f,'digg','toolbar=0,status=0,scrollbars=1,resizable=1,width=960,height=450');
	}
	if(to=='bz') {
		var f='http://www.google.com/reader/link?url='+sURL+'&title='+sTitle+'&srcTitle='+sTitle;
		window.open(f,'buzz','toolbar=0,status=0,resizable=1,width=750,height=450');
	}
	if(to=='ml')
	{
		var subject = sTitle;
		var body_message = sURL;
		var f='mailto:?subject='+subject+'&body='+body_message;
		window.open(f,'emailWindow');
	}
}

function toggleDisplay(divId, mode)
{
  oObj = document.getElementById(divId);
  if (oObj)
  {
  	if(mode!=null) {
  		oObj.style.display=mode;
  	} else {
	    if (oObj.style.display == "block" || oObj.style.display =='')
	      oObj.style.display="none";
	    else
	        oObj.style.display="block";
  	}
  }
}

function fadeOut(divId) 
{
	var oObj = document.getElementById(divId);
	if(oObj.style.opacity == '') {
		oObj.style.opacity = parseInt(1);
	}
	oObj.style.opacity = (parseFloat(oObj.style.opacity)-0.05);
	if(oObj.style.opacity > 0)
		setTimeout("fadeOut('"+divId+"')", 50);
}
function fadeIn(divId) 
{
	var oObj = document.getElementById(divId);
	if(oObj.style.opacity == '') {
		oObj.style.opacity = parseInt(0);
	}
	oObj.style.opacity = (parseFloat(oObj.style.opacity)+0.05);
	if(oObj.style.opacity < 1)
		setTimeout("fadeIn('"+divId+"')", 50);
}

function promptMessage(msg)
{
	alert(msg);
}

function init() {
	document.search.submit.value='';
}


debug=false;
function trace(theObj)
{
	if(debug!=true) 
	{
		var divs = (document.getElementById('console_log')).getElementsByTagName('*');
		for(var i in divs) {
			if(divs[i].style) {
				divs[i].style.display='none';
			}
		}
		document.getElementById('console_log').className='consoleLog';
		debug=true;
	}
	
	var output = "";
	if( theObj !== undefined) 
	{
		if(theObj.constructor == Array || theObj.constructor == Object)
		{
			output += "<pre>";
			for(var p in theObj)
			{
				if( theObj[p].constructor == Array||
					theObj[p].constructor == Object)
				{
					output += "<small>["+p+"] => "+typeof(theObj)+"</small><br>";
					output += trace(theObj[p]);
				} else {
					output += "["+p+"] => "+theObj[p]+"";
				}
			}
			output += "</pre>";
		}
		else
		{
			output += "<small>["+typeof(theObj)+"]</small><br>";
			output += theObj+"<br>";
		}
		document.getElementById('console_log').innerHTML += "<p>"+output+"</p>";
		document.getElementById('console_log').scrollTop = document.getElementById('console_log').scrollHeight;

	}
}
