if(!md) var md = document;

function $(id){ return md.getElementById(id).value; }

function swf_postload(id, sh, swfDir){

	sfPath = sh["swfFileName"];
	if(swfDir) sfPath = swfDir +sfPath;
	if(!sh["align"]) sh["align"] = "";
	if(!sh["quality"]) sh["quality"] = "best";
	if(!sh["bgcolor"]) sh["bgcolor"] = "#FFFFFF";

	shtml = "\n<object type=\"application/x-shockwave-flash\"";
	shtml += "\ndata=\"";
	shtml += sfPath;
	shtml += "\"";
	shtml += "\nwidth=\"";
	shtml += sh["width"];
	shtml += "\"\nheight=\"";
	shtml += sh["height"];
	shtml += "\"\nid=\"";
	shtml += sh["id"];
	shtml += "\"\nalign=\"";
	shtml += sh["align"];
	shtml += "\">";
	shtml += "\n\t<param name=\"movie\" value=\"";
	shtml += sfPath;
	shtml += "\" />\n\t<param name=\"quality\" value=\"";
	shtml += sh["quality"];
	shtml += "\" />\n\t<param name=\"bgcolor\" value=\"";
	shtml += sh["bgcolor"];
	shtml += "\" />";

	if(sh["FlashVars"]){
		var fv = sh["FlashVars"].split(":");
		shtml += "\n\t<param name=\"flashVars\" value=\"";
		shtml += fv[0] +"=" +fv[1];
		shtml += "\" />";
	}

	if(sh["wmode"]){
		shtml += "\n\t<param name=\"wmode\" value=\"";
		shtml += sh["wmode"];
		shtml += "\" />";
	}

	shtml += "\n</object>";

	//alert(shtml);

	var md = document;
	md.getElementById(id).innerHTML = shtml;
}


//
function simple_command_builder(cmd){
	return "?act=" +cmd;
}

//
function get_action(){
	var strURL = location.href;
	return strURL.substr(strURL.indexOf("?"));
}


//
function set_field(fieldName, fieldValue, sr, ma){
	var lform = md.forms.lform;
	lform[fieldName].value = fieldValue;
	if(ma){
		ma = String(ma);
		if(ma.length > 2) lform.action = simple_command_builder(ma);
		else lform.action = get_action();
	}
	if(sr) lform.submit();
}

//
function set_form_action(act, sr){
	var lform = md.forms.lform;
	lform.action = act;
	if(sr) lform.submit();
}


//
function check_filterview(act){
	var lform = md.forms.lform;
	if($("orderBy") != "..."){
		lform.action = act ? simple_command_builder(act) : get_action();
		lform.submit();
	}
}



//
function hilite_tr(tblID, obj, cn){

	var current_cn = obj.className;

	if(cn == "trselected"){
		var tbl = md.getElementById(tblID);
		var t = "";
		var tr = tbl.getElementsByTagName("tr");

		for(var i = 1; i < tr.length; i++){
			tr.item(i).className = "none";
		}
		obj.className = cn;
	}
	else if(current_cn == "trselected" && cn == "trhover") return;
	else if(current_cn == "trselected" && cn == "none") return;
	else if(current_cn == "trselected" && cn == "trselected") obj.className = "none";
	else obj.className = cn;
}

//
function check_login(){

	var lform = md.forms.lform;

	if($("uid").length < 4){
		alert("campo { username }: inserire un nome utente valido");
		return false;
	}
	if($("pwd").length < 5){
		alert("campo { password }: inserire una password piu' lunga");
		return false;
	}

	lform.submit();
}



