/* <![CDATA[ */
// A. Roper
// A set of generic javascript functions for use of forms etc

// this function takes and object such as a div and a text style and changes the objects style
function obj_change_style(obj, css) {
	obj.className=css;
}

function obj_id_change_style(sID, css) {
	
	obj = document.getElementById(sID);
	obj.className=css;
}

function show_hide_itm(sMnu, v) {

	// check the object exists
	if(document.getElementById(sMnu)){
		// get the object
		obj = document.getElementById(sMnu);
									
		if (obj.style){
			obj=obj.style;
			//v=(v=='show')?'visible':(v='hide')?'hidden':v; 
			v=(v=='show')?'block':(v='hide')?'none':v; 
		}
		
		obj.display = v;
		
	}
}

function page_load_handler() {

}

function check_length_jump(obj, i_length, s_jump_to) {
	// check the length of the input and jumps the cursor to another form field specified
	// used on date fields
	if (obj.value.length >= i_length)
	{
		document.getElementById(s_jump_to).focus();
	}
}

function set_form_focus() {
	if (document.forms.length > 0) {
		
		var field = document.forms[0];
		
		for (i = 0; i < field.length; i++) {
		
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
				document.forms[0].elements[i].focus();
				break;
         }
      }
   }
}

// web control custom validations
function validateLength(oSrc, args){ 
	if (args.Value = '') {
		args.IsValid = false;
	} else if (args.Value.length >= 6) {
		args.IsValid = false;
	} 
}

function openPrintWindow(sPage)
{
    window.open(sPage,'','fullscreen=no,toolbar=no, scrollbars=yes, menubar=no');
}

function PopUpQuestions(pagename)
{
    window.open(pagename,'','height=700,width=850,toolbar=no, scrollbars=yes, menubar=no');
}

function ClearDateTXTDefault(obj)
{
    if (obj.value == '(dd/mm/yyyy)') 
    {
        obj.value ='';
    }
}

function selectBoxSetValue(selectBoxID, setValue) {
    
    var selectBox = document.getElementById(selectBoxID);  

    for (i=0;i<selectBox.length;i++)
    {

        if (setValue == selectBox.options[i].value) {

            selectBox.options[i].selected = true;
            return;
        }
    }
}

/* ]]> */