function _goToURL(linkURL,newWin) {
	if(linkURL==null || linkURL=="") return;
	if(newWin!=null && (newWin==true || newWin=="true"))
		window.open(linkURL);
	else
		window.location.href = linkURL;
}




var toggleunitcontent = function(ele){
	if( JQ(ele).hasClass('frameclosed') ) {
		JQ(ele).removeClass('frameclosed').addClass('frameopened');
	} else {
		JQ(ele).removeClass('frameopened').addClass('frameclosed');
	}
	JQ(ele).parent().next().toggle( );
}

var hideInSec = function(ele, sec) {
	setTimeout(
		function() { JQ(ele).hide(); }, sec
	);
}



JQ(document).ready(function () {
	/* HIDE SECONDARY MENU IF EMPTY */
	if(JQ("#secondary_menu a").length==0) {
		JQ("#secondary_menu").hide();
		JQ("#page_content").css("margin-right","0");
	};

	/* SET DROPDOWN MENU ONCHANGE VALUE */
	JQ("select.dropdown").change(
		function() { eval(this.value); }
	);
	
	/* SET THE OVER ACTION */
	JQ("tr.onover").mouseover(
		function() {
			JQ(this).children("td").addClass("over");
		}
	).mouseout(
		function() {
			JQ(this).children("td").removeClass("over");
		}
	);
	
	/* SET CHECKABLE */
	JQ("th.selectall").click(
		function() {
			var c = JQ(JQ(this).parents("table").get(0)).find(":checkbox");
			var allchecked = true;
			jQuery.each(c, function(i,val) {
				allchecked = allchecked && val.checked;
    		});
    		jQuery.each(c, function(i,val) {
				val.checked = !allchecked;
    		});
		}
	);
	
	/* SINGLE LINKS ON SECONDARY MENU */
	JQ("#secondary_menu ul.level1").find("a").each(
		function(){
			if(JQ(this).parent()[0].tagName.toUpperCase()!="LI")
				JQ(this).wrap(document.createElement("li"));
		}
	);
	
	
	JQ("span.addrow").live("click", 
		function(){
			var rows = JQ(this).parents("ul.rows").get(0);
			var maxSize = JQ(rows).find("input.maxSize").get(0);
			if(maxSize!=null)
				maxSize = JQ(maxSize).val();
			else
				maxSize = 100000;
			if(JQ(rows).children("li.row").length < maxSize) {
				var thisrow = JQ(this).parents("li.row").get(0);
				var newrow = JQ(thisrow).clone(true).removeClass("row0");
				newrow.html(JQ(newrow).html().replace(/\[[0-9]+\]/ig,"["+(1+ Math.floor(9999 * Math.random()))+"]"));
				
				newrow.find(':input').each(function() {
    				var type = this.type;
    				var tag = this.tagName.toLowerCase();
    				if (type == 'text' || type == 'password' || tag == 'textarea')
      					this.value = "";
				    else if (type == 'checkbox' || type == 'radio')
      					this.checked = false;
				    else if (tag == 'select')
      					this.selectedIndex = -1;
  				});
				
				newrow.insertAfter(thisrow);
			}
		}
	);
	
	JQ("span.removerow").live("click", 
		function(){
			var rows = JQ(this).parents("ul.rows").get(0);
			var thisrow = JQ(this).parents("li.row").get(0);
			if(JQ(rows).children("li.row").length > 1)
				JQ(thisrow).remove();
			JQ(JQ(rows).children("li.row").get(0)).addClass("row0");
		}
	);

















	/* set click function on closeframe buttons */
	/*JQ(".frameclosed,.frameopened").click(
		function() { toggleunitcontent(this); }
	);
	*/
	/* hide all tooltips after their (n)sec class property */
	JQ(".mytooltip").each(
		function(i) { 
			var sec = JQ(this).attr('class').match(/\s+([0-9])+sec(\s+|$)/ig);
			if(sec) {
				hideInSec(this,((sec+'').replace(/sec$/ig,''))*1000);
			}
		}
	);
	
	
		
});



function prova(){
	ajaxRequest('page5uFormBean', $H({'onFailureCallback': '','sourcePage': 'page5u', 'isForm': true, 'pressedLink' : 'button#ln59u'}));
	JQ("#fld4u").val("");
}