/*
  AJAX Functions
		VERSION : 0.1
		DATE : 12 Fév 2007
		AUTHOR : David
		COMMENTS :   
*/

			
var ajax = new AJAX(); 
			

// runs ajax and the fill_node_html
function Show_Html( node_name, script ) {
	
	ajax.method = "GET";
	ajax.requestFile = AJAX_PHP_ROOT + script;	
	ajax.onCompletion = new Function( "Fill_Node_With_Html('" + node_name + "')" );
	ajax.runAJAX();		

}



// fill html element's innerhtml value
function Fill_Node_With_Html( node_name ) {	
	var content = ajax.response;
	if ( content ) { 
		document.getElementById( node_name ).innerHTML = content;
	}	
}



// check if the value inputed for the specified field is unique
function mSql_Check_Unique_Column( table_name, column, obj_input, id, msg ) { 
	var ajax = new AJAX();
	ajax.method = "GET";
	ajax.requestFile = AJAX_PHP_ROOT + "mysql_check_unique_column.php";	
	ajax.setVar('table_name', table_name);
	ajax.setVar('column', column);
	ajax.setVar('input_name', obj_input.name);
	ajax.setVar('input_value', obj_input.value);
	ajax.setVar('id', id);
	ajax.setVar('msg', getTxt(msg));
	ajax.execute = true;
	ajax.runAJAX();				
}


// check if the specified fields combination is unique
function mSql_Check_Related_Columns( table_name, columns, obj_input_1, obj_input_2, msg ) { 
	var ajax = new AJAX();
	ajax.method = "GET";
	ajax.requestFile = AJAX_PHP_ROOT + "mysql_check_related_columns.php";	
	ajax.setVar('table_name', table_name);
	ajax.setVar('columns', columns);
	ajax.setVar('input_name_1', obj_input_1.name);
	ajax.setVar('input_value_1', obj_input_1.value);
	ajax.setVar('input_name_2', obj_input_2.name);
	ajax.setVar('input_value_2', obj_input_2.value);
	ajax.setVar('msg', Get_Txt(msg));
	ajax.execute = true;
	ajax.runAJAX();				
}



// show departments in a select
function Show_Specification( type_id, spec_id, select_width ) { 

	var ajax = new AJAX();
	ajax.method = "GET";
	ajax.requestFile = AJAX_PHP_ROOT + "show_specification.php";

	ajax.setVar('type_id', type_id);
	ajax.setVar('spec_id', spec_id);
	if( !select_width ){ select_width = "182"; }
	ajax.setVar('select_width', select_width);
	
	if( BrowserDetect.browser == "Explorer" ){
		ajax.setVar('browser_detect', 1);
	}
	else
	{
		ajax.setVar('browser_detect', 0);
	}
				
	ajax.execute = true;
	ajax.runAJAX();				
}





function Show_Reminder( table_name, field_name, value ) { 

	var ajax = new AJAX();
	ajax.method = "GET";
	ajax.requestFile = AJAX_PHP_ROOT + "show_reminder.php";

	ajax.setVar('table_name', table_name);
	ajax.setVar('field_name', field_name);
	ajax.setVar('value', value);
	
	ajax.execute = true;
	ajax.runAJAX();				
}

function Check_Unique_URL( column, obj_input, id, parent_id, msg ) { 
 var ajax = new AJAX();
 ajax.method = "GET";
 ajax.requestFile = AJAX_PHP_ROOT + "check_unique_url.php"; 
 ajax.setVar('column', column);
 ajax.setVar('input_name', obj_input.name);
 ajax.setVar('input_value', obj_input.value);
 ajax.setVar('id', id);
 ajax.setVar('parent_id', parent_id);
 if (typeof Get_Txt != 'undefined' ) {
   ajax.setVar('msg', Get_Txt(msg));
 } else {
   ajax.setVar('msg', msg);
 }
 ajax.execute = true;
 ajax.runAJAX();    
}

