function showTR(id) {
		if(document.getElementById('TR'+id).style.display == "none") {
			document.getElementById('TR'+id).style.display = ""; // for mozilla inherit, IE - inline
			if(document.getElementById('IM'+id)) {
				document.getElementById('IM'+id).src = "images/details_close.png";
			}
		} else {
			document.getElementById('TR'+id).style.display = "none";
			if(document.getElementById('IM'+id)) {
				document.getElementById('IM'+id).src = "images/details_open.png";	
			}
		  }
}

function trOver(row){
	row.className=row.className.replace('out','over');
}
function trOut(row){
	row.className=row.className.replace('over','out');
}

function showInfo(id, board) {
		url = "showInfo.php";

		if(document.getElementById('TR'+id).style.display == "none") {
			document.getElementById("Span_"+id).innerHTML="<IFrame src='"+url+"?id="+id+"&page="+board+"' width='100%' height='400' scrolling='no' frameborder='0' id='frame"+id+"'></IFrame>";
			document.getElementById('TR'+id).style.display = ""; // for mozilla inherit, IE - inline
			document.getElementById('IM'+id).src = "images/details_close.png";
			document.getElementById('mainTR'+id).className = 
			  document.getElementById('mainTR'+id).className.replace( "over", "click");
			document.getElementById('mainTR'+id).className = 
			  document.getElementById('mainTR'+id).className.replace( "out", "click");
			document.getElementById('mainTR'+id).className = 
			  document.getElementById('mainTR'+id).className.replace( "visited", "click");			  
		} else {
			document.getElementById("Span_"+id).innerHTML="";			
			document.getElementById('TR'+id).style.display = "none";
			document.getElementById('IM'+id).src = "images/details_open.png";
			document.getElementById('mainTR'+id).className = 
			  document.getElementById('mainTR'+id).className.replace("visited", "click");			
			document.getElementById('mainTR'+id).className = 
			  document.getElementById('mainTR'+id).className.replace( "click", "visited");			  			  
		  }
}

function selectAd(selectedId) {
	var adId = document.getElementById("adId" + selectedId);
	var forwardIdVal = document.board.selectedId.value;
	var val = "";
	
	if( adId.checked==false || adId.checked=="false" ) {
		list=forwardIdVal.split(",");

	for( i=0 ; i<list.length ; i++){
			if(list[i]!=selectedId ) {
				if(val.length>0)
					val = val+","+list[i];
				else
					val = list[i];
			}
		}
		forwardIdVal = val;
	}
	else{
		if(forwardIdVal.length > 0)
		{
			//alert("second and above = " + forwardIdVal);
			forwardIdVal += "," + selectedId;
		}
		else
		{
			//alert("initiate = " + forwardIdVal);
			forwardIdVal += selectedId;
		}
	}
	document.board.selectedId.value = forwardIdVal;
	 
	Set_Cookie("selectedId", forwardIdVal, 0, '/', '', '' );
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

if(document.referrer != "http://"+window.location.hostname+window.location.pathname) 
	Delete_Cookie("selectedId", '/', '');
	
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function printSelected() {
	if(document.board.selectedId.value == "") return false;
	page = window.location.hostname + window.location.pathname;
	window.open("http://" + page + "?task=print&nohtml=1&selectedId="+document.board.selectedId.value);
}

function showMedia(id, page, media) {
	window.open("http://" + window.location.hostname + "/showMedia.php?page="+page+"&media="+media+"&id="+id);
}

//return true if the pressed key is numeric
function isNumberKey(evt) {              
	var charCode = (evt.which) ? evt.which : event.keyCode       
   if (charCode > 31 && (charCode < 48 || charCode > 57))
   	return false;
   return true;
}