// JavaScript Document
function rowChange(){
	
	var focusOn = false;
	
	items = YAHOO.util.Dom.getElementsByClassName("row");
	for (i = 0; i < items.length; i++){
		var rowOver = items[i];
		rowOver.onmouseover = function(){
			this.className = "rowOver";
		}
		rowOver.onmouseout = function(){
			this.className = "row";
		}
	}
	
	itemsAlt = YAHOO.util.Dom.getElementsByClassName("altRow");
	for (i = 0; i < itemsAlt.length; i++){
		var rowOver = itemsAlt[i];
		rowOver.onmouseover = function(){
			this.className = "rowOver";
		}
		rowOver.onmouseout = function(){
			this.className = "altRow";
		}
	}
	
	itemsM = YAHOO.util.Dom.getElementsByClassName("mRowIn");
	for (i = 0; i < itemsM.length; i++){
		var rowOver = itemsM[i];
		rowOver.onmouseover = function(){
			if(!focusOn) {this.className = "rowOver"};
		}
		rowOver.onmouseout = function(){
			if(!focusOn) {this.className = "row"};
		}
		rowOver.onclick = function(){
			//alert(this.childNodes[0])
			//this.className = "cellSelected";
			this.childNodes[0].focus();
			//focusOn = true;
		}
	}
}
function changeBg(what){
	curClass = what.className;
	what.className = 'normal-hover';
}

function changeBgBack(what){
	what.className = curClass;
}

function setValue(id,val){
	YAHOO.util.Dom.get(id).innerText = val;
}
myValue = true;
function showHideValue(id){
	if(myValue){
	YAHOO.util.Dom.get(id).style.display = "block";
	myValue = false;
	}else{
	YAHOO.util.Dom.get(id).style.display = "none";	
	myValue = true;
		}
	
}

function trimFormFeilds(){
//alert('setting tab');
	try {
	   for(i=0; i<document.forms[0].elements.length; i++){
	     if (document.forms[0].elements[i].readOnly == false)
		 {
		   try {
		    document.forms[0].elements[i].value=Trim(document.forms[0].elements[i].value) ; 
		    } catch(error) {}       
		 }
	   } 
	 } catch (error) {}
}

//To trim white spaces
function Trim(TRIM_VALUE) {
    if (TRIM_VALUE.length < 1) {
        return"";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if (TRIM_VALUE == "") {
        return "";
    }
    else {
        return TRIM_VALUE;
    }
}

function trimCompanyRegistrationFeilds(){
//alert('setting tab');
	try {
	   for(i=0; i<document.forms[0].elements.length; i++){
	     if (document.forms[0].elements[i].readOnly == false)
		 {
		   try {
		    document.forms[0].elements[i].value=trimCData(document.forms[0].elements[i].value) ; 
		    } catch(error) {}       
		 }
	   } 
	 } catch (error) {}
}

//To trim white spaces, Underscorers ad dates
function trimCData(TRIM_VALUE) {
    if (TRIM_VALUE.length < 1) {
        return"";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if (TRIM_VALUE == "") {
        return "";
    } else if(TRIM_VALUE == "_"){
        return "";
    } else if(TRIM_VALUE == "11/11/1111"){
        return "";
    } else if(TRIM_VALUE == "00"){
        return "";
    }
    else {
        return TRIM_VALUE;
    }
}

//To trim white spaces in right side of a field
function RTrim(VALUE) {
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    if (v_length < 0) {
        return"";
    }
    var iTemp = v_length - 1;

    while (iTemp > -1) {
        if (VALUE.charAt(iTemp) == w_space) {
        }
        else {
            strTemp = VALUE.substring(0, iTemp + 1);
            break;
        }
        iTemp = iTemp - 1;
    }
    return strTemp;

}

//To trim white spaces in left side of a field
function LTrim(VALUE) {
    var w_space = String.fromCharCode(32);
    if (v_length < 1) {
        return"";
    }
    var v_length = VALUE.length;
    var strTemp = "";

    var iTemp = 0;

    while (iTemp < v_length) {
        if (VALUE.charAt(iTemp) == w_space) {
        }
        else {
            strTemp = VALUE.substring(iTemp, v_length);
            break;
        }
        iTemp = iTemp + 1;
    }
    return strTemp;
}

function disableFormElements()
{
  try {
	   for(i=0; i<document.forms[0].elements.length; i++)
           {
             if (document.forms[0].elements[i].type !='button' && document.forms[0].elements[i].type !='hidden') 
             {
                           try {
                            document.forms[0].elements[i].disabled = true;
                            } catch(error) {}       
              } 
           }
	 } catch (error) {}
}

function enableFormElements()
{
  try {
	   for(i=0; i<document.forms[0].elements.length; i++)
           {
             
                           try {
                            document.forms[0].elements[i].disabled = false;
                            } catch(error) {}       
             
           }
	 } catch (error) {}
}


