

	function confirmit(){
		
		var msg = 'Are you sure?'
		
		if ( arguments.length > 0 ) {
			msg = arguments [ 0];
		}
		
		var ans = confirm(msg);
		
		if ( ans ) {
			return true;
		}else{
			return false;
		}
		
		
	}
	
	/* 
		The last argument can be an array where we can put more hidden fields name/value pairs
	*/
	
	function  common_submitFormWithAction	(  formid, action, value  ){

		form1 = document.getElementById( formid );
		
		//append hidden attribute
		form1.appendChild(  common_createHidden(action, value) );

		//if the array has been passed
		if ( arguments.length ==4 ) {
			var list = arguments[3];
			for(var z=0; z< list.length; z= z+2 ) {
					//alert("adding " + list[z] + " with value " + list[z+1] );
					form1.appendChild(  common_createHidden(list[z], list[z+1]) );
			}
		}
		
		form1.submit();

		return false;
	}

	
	function  common_submitForm	(  formid ){

		form1 = document.getElementById( formid );
		
		form1.submit();

		return false;
	}
	
	
	function common_createHidden( name, value ) {
			var input = document.createElement("input");
			input.setAttribute("type", "hidden");
			input.setAttribute("name", name);
			input.setAttribute("value", value );
			return input;
	}
	
	function common_showElement( id, flag ){
		//alert( id + flag);
		var obj = document.getElementById( id );
		if ( obj ) {
			if ( flag) {
				obj.style.display = "block";
			}else{
				obj.style.display = "none";
			}
		}else{
			alert( id + " not found ");
		}
	}
	
	function common_removeChildren( obj ){
	
		while ( obj.hasChildNodes() ) {
					
			var anode = obj.lastChild;
			obj.removeChild(anode); 

		}
	}
	
		
	function common_appendChildToDropDown ( dropdownobj, valueelement, nameelement, valueselected ){
		
			if ( dropdownobj ){
				
					var newelement = document.createElement("option" );				
					newelement.setAttribute("value", valueelement );
					newelement.appendChild( document.createTextNode( nameelement ) );
					
					if ( valueelement == valueselected ) {
							newelement.setAttribute("selected", true);
					}
					
					dropdownobj.appendChild( newelement );			
			}
			
	}

	
	function common_setValue( obj_id, avalue ) {
		var obj = document.getElementById( obj_id ) ;
		if ( obj ){
			obj.value = avalue;
		}
	} 
	
	var  windowCommon1a = null;
	function common_openWindow( url, width, height ) {
				
			var x = (screen.width - width) / 3;
			var y = (screen.height - height) / 3;		

		
			var optionString = "scrollbars=yes,location=no,resizable=yes,status=no,";
			optionString += "height=" + height + ",width=" + width;
			optionString += ",screenX="+ x +",screenY="+ y +",top="+ y +",left="+ x;

		    if (!windowCommon1a ||windowCommon1a.closed) {
		    	windowCommon1a = window.open(url,"windowCommon1a",optionString);
		    } else {
		    	// window already exists, so bring it forward
			    windowCommon1a.location.href=url;
			    windowCommon1a.focus();
			}
			
	}
	
	function common_trim( str){ 
		return str.replace(/^\s*|\s*$/g,"");
	}
	
	function common_max( value, max, suffix){
		
		var temp = value + "";
		
		if ( temp.length > max ){
		
			temp = temp.substring( 0, max ) + suffix;
		}
		
		return temp;
		
	
	}
	
	
	
	

