var nKeyCode;
var sKeyCode;

document.onkeydown = runKeyDown;
document.onkeyup = runKeyUp;
//document.onkeydown = cancelCopyPaste;
//document.oncontextmenu = cancelRightClick;
function runKeyUp(e){
	getKeyCode(e)
}
function runKeyDown(e)
{
	getKeyCode(e);
	cancelEnterKey();
	//cancelCopyPaste();
	//nKeyCode=window.event.keyCode;
}

function cancelEnterKey()
{
    var activeItemID = document.activeElement.getAttribute("id");
    if ( window.event.keyCode == 13 )
    {
        if ( activeItemID != "auctLogin_UserName" && activeItemID != "auctLogin_PassWd" 
                && activeItemID != "auctLogin_UID" && activeItemID != "auctLogin_passwd"){ 
			if(document.activeElement.getAttribute("tagName")!='TEXTAREA')window.event.returnValue = false;
        }
    } 
}
function getKeyCode(e){
	if (!e) e = window.event;
	nKeyCode=e.keyCode;
	sKeyCode=String.fromCharCode(e.keyCode);
	return false;
}

// ####################################################


function doCaptureSubmit(sSubmitName)
{
    if( window.event.keyCode == 13 )
    {
        document.getElementById(sSubmitName).click();
    }
}

function enterClick(event, clickControlId){
	if ((event.which&&event.which==13)||(event.keyCode&&event.keyCode==13)){
		var oClickControl=document.getElementById(clickControlId);
		if(typeof(oClickControl)=='object'&&oClickControl!=null){
			if(oClickControl.tagName=='INPUT'){
				oClickControl.click();
			}
			else{
				//click method does not work in mozilla (maybe sometimes or always) so implement the __doPostBack call
				//link does not have a click method
				var onclickscript=oClickControl.getAttribute('onclick');
				if(typeof(onclickscript)=='function'){
					eval(onclickscript+';anonymous();');
				}
				else{
					eval(onclickscript);
				}				
				eval(oClickControl.getAttribute('href'));
				//__doPostBack(clickControlId.replace('_','$'),'')
			}
			return false;
		}
		else{
			return true;
		}
	}
	else{
		return true;
	}
}


// ####################################################
function doFocus(sEleFocus)
{
    var oUserName = document.getElementById(sEleFocus);
    oUserName.focus();
}

function goOutside(argLink)
{
    //var oWin = new Object()   
    //alert("Found function ")
    //return false;
    var ratio, theWidth, theHeight, theTop, theLeft, yesNo, anyString   
    var serverName = "not localhost"
    //alert("serverName: " + serverName )
    var oWind = null
    
    theHeight = window.screen.height
    //for size of window
    ratio=(theHeight==600)?0.6:0.6; 
    
    if ( serverName.toLowerCase() == "localhost" )
    {
        theHeight = theHeight * ratio
        yesNo = "yes"
    }
    else
    {
        theHeight = theHeight * 0.70
        yesNo = "no"
    }
    theWidth = window.screen.width
    theWidth = theWidth * 0.80
    //theWidth = 900    
    //alert("Sesssion user: " + UserID )
    // I removed this coz AOL is causing problem,  ?UserID=nobody
    
    //theHeight = "300"
    anyString = "height=" + theHeight + ",width=" + theWidth + ","
            + "top=" + theHeight*0.10 + ",left=" + theWidth*0.10 + ","      
            + "fullscreen=no,toolbar=" + yesNo + ",location=" + yesNo + ",status=" + yesNo + ","
            + "menubar=" + yesNo + ",scrollbars=yes,resizable=yes"  
        
    open("..//miscellaneous//f07frameset.aspx?theLink=" + argLink + "\"", null, anyString)
    //oWin.frames[1].src = argLink
}

// ##################################################################

function openLearnMore(argID)
{
    var ratio, theWidth, theHeight, theTop, theLeft, yesNo, anyString
    var oWind = null
    
    //alert("argID is: " + argID )
    theHeight = window.screen.height * 0.80 
    theWidth = window.screen.width * 0.80   
    theTop = (window.screen.height - theHeight ) * 0.4
    theLeft = (window.screen.width - theWidth ) * 0.5
    
    anyString = "height=" + theHeight + ",width=" + theWidth + ","
            + "top=" + theTop + ",left=" + theLeft + ","                        
    
            + "fullscreen=no,toolbar=no,location=no,status=yes,"
            + "titlebar=no,menubar=no,scrollbars=yes,resizable=yes" 
    open("../static/f13LearnMore.aspx?flag=" + argID, "LearnMore", anyString)
    //open("../static/f921learnMore.aspx?flag=" + argID, "", anyString)
    
}

// ##################################################################

function openChildWindow(sURL, sName, sWidth, sHeight, sAttributes)
{
    var ratio, theTop, theLeft, yesNo
    var oWind = null
    theTop = (window.screen.height - sHeight ) * 0.4
    theLeft = (window.screen.width - sWidth ) * 0.5
    
    sAttributes = "height=" + sHeight + ",width=" + sWidth + ","
            + "top=" + theTop + ",left=" + theLeft + ","                        
            + "fullscreen=no,toolbar=no,location=no,status=yes,"
            + "titlebar=no,menubar=no,scrollbars=yes,resizable=yes"
    open(sURL, sName, sAttributes)
}
// ###################################################

// ##########################################################

function maskPhone(objThis)
{   
    var strPhone = new String(objThis.value)
    var phoneLength = strPhone.length()
    var strValidString = new String("()-1234567890")
    var i, anyChar
    for( i = 0; i < strPhone.length ; i++ )
    {
        anyChar = strPhone.substr(i, 1)
        if ( strValidString.indexOf(anyChar) == -1 )
        {
            return;
        }
    }
    // .................................................
    switch ( phoneLength )
    {
        case 3:
            if ( sFirstChar != "(" )
            {
                objThis.value = "(" + strPhone + ")"
            }
            break;
        case 4:
            objThis.value = strPhone + ")"
            break;
        case 8:
            objThis.value = strPhone + "-"
            break;
    }
}


function doMapPhone(othis)
{   
    var sPhone=new String(othis.value);
    var nLenPhone=sPhone.length;
    var sLastChar=sPhone.substr(nLenPhone-1,1);
    var sFirstChar=sPhone.substr(0,1);
    var sValidString='()-1234567890';
    var sValidChar='';
    var bValidChar=false;
    var i;
    for(i=0;i<sValidString.length;i++)
    {
        sValidChar=sValidString.substr(i,1);
        if(sValidChar==sLastChar){
            bValidChar=true;
            break;
        }
    }
    if(!bValidChar)
    {
        othis.value=sPhone.substr(0, nLenPhone-1);
        return;
    }
	switch(nLenPhone){
		case 3:
			if(sFirstChar!='(')othis.value='('+sPhone+')';
			break;
		case 4:
			if(nKeyCode==8){
				othis.value=sPhone.substr(1,2);
			}
			else{
				othis.value=sPhone+')';
			}
			break;
		case 8:
			if(nKeyCode==8){
				othis.value=sPhone.substr(0,7);
			}
			else{
				othis.value=sPhone+'-';
			}
			break;
		case 13:
			//alert(sPhone);
			break;
	}
}
function doMapDate(othis)
{   
    var sDate=new String;
    sDate=othis.value;
    var nLenDate=sDate.length;
    var sLastChar=sDate.substr(nLenDate-1,1);
    var sFirstChar=sDate.substr(0,1);
    var sValidString='-1234567890';
    var sValidChar='';
    var bValidChar=false;
    var i;
    for(i=0;i<sValidString.length;i++)
    {
        sValidChar=sValidString.substr(i,1);
        if(sValidChar==sLastChar)
        {
            bValidChar=true;
            break;
        }
    }
    if(!bValidChar)
    {
        othis.value=sDate.substr(0, nLenDate-1);
        return;
    }

    var bConvert=false;
	switch(nLenDate){
		case 2:
			bConvert=true;
			break;
		case 5:
			bConvert=true;
			break;
		case 10:
			//alert(sDate);
			break;
	}
	if(bConvert){
		if(nKeyCode==8){
			othis.value=sDate.substr(0,nLenDate-1);
		}
		else{
			othis.value=sDate+'-';
		}
	}
}
function doMapDriverLicense(othis)
{   
    var sDriverLicense=new String;
    sDriverLicense=othis.value;
    var nLenDriverLicense=sDriverLicense.length;
    var sLastChar=sDriverLicense.substr(nLenDriverLicense-1,1);
    var sFirstChar=sDriverLicense.substr(0,1);
    var sValidString='-1234567890';
    var sValidChar='';
    var bValidChar=false;

	var regex=new RegExp('[a-zA-Z]{1}');
	if(nLenDriverLicense==1){
		if(sFirstChar.match(regex)!=null){
			bValidChar=true;
		}
	}
	else{
		var i;
		for(i=0;i<sValidString.length;i++)
		{
			sValidChar=sValidString.substr(i,1);
			if(sValidChar==sLastChar)
			{
				bValidChar=true;
				break;
			}
		}
	}
    if(!bValidChar)
    {
        othis.value=sDriverLicense.substr(0, nLenDriverLicense-1);
        return;
    }

    var bConvert=false;
	switch(nLenDriverLicense){
		case 4:
			bConvert=true;
			break;
		case 8:
			bConvert=true;
			break;
		case 11:
			bConvert=true;
			break;
		case 15:
			bConvert=true;
			break;
		case 17:
			//alert(sDriverLicense);
			break;
	}
	if(bConvert){
		if(nKeyCode==8){
			othis.value=sDriverLicense.substr(0,nLenDriverLicense-1);
		}
		else{
			othis.value=sDriverLicense+'-';
		}
	}
}


//to get an element when you only know part of its ID and the Element decendant it belongs to
//sPartEleId - end part of elements id
//sTag - Name of the Tag to search in
function getElementIdByElement(ElementDecendant, PartEleId, Tag)
{
    var aTag=ElementDecendant.getElementsByTagName(Tag);
    var regex=new RegExp(PartEleId+'$', 'i');
    
	var EleId=new String()
    for(i=0;i<aTag.length;i++)
    {
		EleId=aTag[i].id;
		if(EleId.match(regex)!=null){
            return EleId;
            break;
        }
    }
    return '';
}

//to get an element when you only know part of its ID
//sPartEleId - part of elements id
//sTag - Name of the Tag to search in
function getElementId(PartEleId, Tag)
{
	return getElementIdByElement(window.document.body, PartEleId, Tag);
/*
    var aTag=window.document.body.getElementsByTagName(sTag);
    for(i=0;i<aTag.length;i++)
    {
        if(aTag[i].id.indexOf(sPartEleId)!=-1)
        {
            return aTag[i].id;
            break;
        }
    }
    return '';
*/
}

//to get an element when you only know part of its ID
//sPartEleId - part of elements id
//sTag - Name of the Tag to search in
function getElementIdOLD(sPartEleId, sTag)
{
    var aTag=window.document.body.getElementsByTagName(sTag);
    for(i=0;i<aTag.length;i++)
    {
        if(aTag[i].id.indexOf(sPartEleId)!=-1)
        {
            return aTag[i].id;
            break;
        }
    }
    return '';
}

//to get an element when you only know part of its ID from a parent element
//oEle - pass in parent element
//sPartEleId - part of elements id
//sTag - Name of the Tag to search in
function getElementIdViaEle(oEle, sPartEleId, sTag)
{
    var aTag=oEle.getElementsByTagName(sTag);
    for(i=0;i<aTag.length;i++)
    {
        if(aTag[i].id.indexOf(sPartEleId)!=-1)
        {
            return aTag[i].id;
            break;
        }
    }
    return '';
}

//to get an element Collection when you only know part of its ID
//sPartEleId - part of elements id
//sTag - Name of the Tag to search in
function getElementCol(sPartEleId, sTag)
{
    var aTag=window.document.body.getElementsByTagName(sTag);
    var aEle=new Array()
    var k=0;
    for(i=0;i<aTag.length;i++)
    {
        if(aTag[i].id.indexOf(sPartEleId)!=-1)
        {
			aEle[k]=aTag[i];
            k++;
        }
    }
    return aEle;
}


//to clear data fields descendant objects/nodes of given Element Id - EleId
//requires clearDataElementsViaObject
function clearDataElementsViaId(EleId,includeReadOnlyDisabled){
	var oEle=document.getElementById(EleId);
	clearDataElementsViaObject(oEle,includeReadOnlyDisabled);
}
//to clear data fields descendant objects/nodes of given Element object - oEle
function clearDataElementsViaObject(oEle,includeReadOnlyDisabled){
	if(typeof(includeReadOnlyDisabled)=='undefined')includeReadOnlyDisabled=false;
	var inputList=oEle.getElementsByTagName('INPUT');
	var inputType;
	for(i=0;inputList[i];i++){
		//alert(inputList[i].getAttribute('type'));
		inputType=inputList[i].getAttribute('type');
		switch(inputType){
			case 'text':
				if(!inputList[i].disabled){
					inputList[i].value='';
				}
				else if(includeReadOnlyDisabled&&inputList[i].disabled){
					inputList[i].value='';
				}
				break;
			case 'hidden':
				if(!inputList[i].disabled){
					inputList[i].value='';
				}
				else if(includeReadOnlyDisabled&&inputList[i].disabled){
					inputList[i].value='';
				}
				break;
			case 'password':
				if(!inputList[i].disabled){
					inputList[i].value='';
				}
				else if(includeReadOnlyDisabled&&inputList[i].disabled){
					inputList[i].value='';
				}
				break;
			case 'radio':
				if(!inputList[i].disabled){
					inputList[i].checked=false;
				}
				else if(includeReadOnlyDisabled&&inputList[i].disabled){
					inputList[i].checked=false;
				}
				break;
			case 'checkbox':
				if(!inputList[i].disabled){
					inputList[i].checked=false;
				}
				else if(includeReadOnlyDisabled&&inputList[i].disabled){
					inputList[i].checked=false;
				}
				break;
		}
	}
	var selectList=oEle.getElementsByTagName('SELECT');
	for(i=0;selectList[i];i++){
		if(!selectList[i].disabled){
			selectList[i].selectedIndex=0;
		}
		else if(includeReadOnlyDisabled&&selectList[i].disabled){
			selectList[i].selectedIndex=0;
		}
	}
	var textareaList=oEle.getElementsByTagName('TEXTAREA');
	for(i=0;textareaList[i];i++){
		//textareaList[i].innerHTML='';
		textareaList[i].value='';
	}
}


//to capture location of the mouse during a mouse down event
//requires MouseDown function
//mseDwnX - mouse x position during mouse down
//mseDwnY - mouse y position during mouse down
function doStartMouseDown()
{
    //alert('doStartMouseDown');
    ie=(document.all);
    ns=(document.layers);
    //(ns)?window.captureEvents(Event.MOUSEMOVE):0;
    (ns)?window.onMouseDown=MouseDown:document.onmousedown=MouseDown;
}
function MouseDown(e)
{
    if (!e) var e = window.event;
    //alert(e.which);
    mseDwnY = (e.pageY)?e.pageY-(window.pageYOffset):(e.clientY)?e.clientY:0;
    mseDwnX = (e.pageX)?e.pageX:(e.clientX)?e.clientX:0;
    //alert('mseDwnY: '+mseDwnY+'\nmseDwnX: '+mseDwnX);
}

//generates div and displays it where the mouse has been clicked, on clicking the div will hide div
//sIdentifier - identifier for the div, generated id for div is identifier with '_div_show' appended
//sDisplay - the body text to be displayed
//sHeader - if present will show in header otherwise will use default header text
//doStartMouseDown() needs to be called before this function is called
//requires createDisplayTab and doManipAll function
function doCreateShow(sIdentifier,sDisplay,sHeader){
    //alert('doCreateShow');
    var oDiv;
    if(document.getElementById(sIdentifier+'_div_show')){
        oDiv=document.getElementById(sIdentifier+'_div_show');
    }
    else{
        if(typeof(mseDwnY)!='number'){
            doStartMouseDown();
            var oEvent;
            if(!ie)oEvent=document.onmousedown;
            MouseDown(oEvent);
        }
        oDiv=document.createElement('DIV');
        document.body.appendChild(oDiv);
        oDiv.id=sIdentifier+'_div_show';
        oDiv.style.position='absolute';
        oDiv.style.backgroundColor='#eee';
        oDiv.style.width='250px';
        oDiv.style.overflow='auto';
        //oDiv.onclick=doCreateShow(sIdentifier);
        strIdentifier=sIdentifier;
        //if(ie)oDiv.onclick=doCreateShowClick;
        //oDiv.setAttribute("onClick", "javascript:doCreateShow('"+sIdentifier+"');");
        oDiv.setAttribute("onClick", "javascript:doManipAll('"+sIdentifier+"');");
        var oTable=createDisplayTab(sDisplay,sHeader);
        oDiv.appendChild(oTable);
        oDiv.style.display='none';
    }

    //alert('doCreateShow mouse start');

    var nDivHeight=100;
    var nSpaceBelow=window.document.body.clientHeight-mseDwnY;
    //alert('nSpaceBelow: '+nSpaceBelow);
    //alert('doCreateShow mouse end');

    if (oDiv.style.display!='none')
    {
        //if(ie)doCloseAll();
        oDiv.style.display='none';
        //oDiv.style.zIndex=-100;
        oDiv.style.top='-1000px';
        oDiv.style.left='-1000px';
    }
    else
    {
        doManipAll();
        var oBod=document.body;
        var nHeight=oBod.clientHeight;
        nHeight=(mseDwnY>nDivHeight)?(mseDwnY+nDivHeight>nHeight)?-nDivHeight:0:0;
        oDiv.style.display='block';
        //oDiv.style.zIndex=9999;
        oDiv.style.top=mseDwnY+oBod.scrollTop+nHeight+'px';
        oDiv.style.left=mseDwnX+oBod.scrollLeft+'px';
        /*
        alert('oDiv.style.top: '+oDiv.style.top+
                '\noDiv.style.left: '+oDiv.style.left+
                '\nnHeight: '+nHeight+
                '\nmouse\nmseDwnY: '+mseDwnY+
                '\nmseDwnX: '+mseDwnX+
                '\nclient\nwidth: '+oBod.clientWidth+
                '\nheight: '+oBod.clientHeight+
                '\nleft: '+oBod.clientLeft+
                '\ntop: '+oBod.clientTop+
                '\nscrolling\nwidth: '+oBod.scrollWidth+
                '\nheight: '+oBod.scrollHeight+
                '\nleft: '+oBod.scrollLeft+
                '\ntop: '+oBod.scrollTop);
        */
    }
	oDiv.style.zIndex=9999;
    oDiv.style.height=nDivHeight+'px';
    //alert('doCreateShow end');
}

//generates table with header and body display text
//sDisplay - text to be displayed
//sHeader - display header cell text, if null uses default
function createDisplayTab(sDisplay,sHeader){
    //alert('createDisplayTab start');
    if (typeof(sHeader)=='undefined')sHeader='Conductor Help';
    //setup table nodes

    var oTab=document.createElement('TABLE');
    var oTBod=document.createElement('TBODY');
    var oRowHd=document.createElement('TR');
    var oRow=document.createElement('TR');
    var oTh=document.createElement('TH');
    var oThClose=document.createElement('TH');
    
    var oTd=document.createElement('TD');
    var oText;
    //append table nodes
    oText=document.createTextNode(sHeader);
    oTh.appendChild(oText);
    oRowHd.appendChild(oTh);
    oText=document.createTextNode('X'); //0215=×
    oThClose.appendChild(oText);
    oRowHd.appendChild(oThClose);
    //oTh.style.width='100%';

    oText=document.createTextNode(sDisplay);
    oTd.appendChild(oText);
    oRow.appendChild(oTd);
    //oTd.setAttribute('colspan','2');
    
    
    oTBod.appendChild(oRowHd);
    oTBod.appendChild(oRow);
    oTab.appendChild(oTBod);
    
    //set table attributes  
    oTab.setAttribute('width', '100%');
    oTab.setAttribute('height', '100%');
    oTab.setAttribute('border', '1');
    oTab.setAttribute('cellpadding', '2');
    oTab.setAttribute('cellspacing', '2');
    oTab.setAttribute('bordercolor', '#666666');
    //oTab.setAttribute('class', 'fnItem');
    oTab.className='fnItem';
    //oTh.setAttribute('height', '0px');
    oTh.style.height='0px';
    oTh.style.width='235px';
    if(ie)oThClose.onclick=doManipAll;
    oThClose.setAttribute("onClick", "javascript:doCreateShow('"+strIdentifier+"');");
    oThClose.style.width='15px';
    oThClose.id='close_div_cell_'+strIdentifier;

    

    //oTh.setAttribute('bgcolor', '#6666ee');
    //alert('createDisplayTab01');
    oTh.style.backgroundColor='#6666ee';
    //alert('createDisplayTab03');
    
    //oTd.setAttribute('height', '100%');
    oTd.style.height='100%';
    //oTd.setAttribute('bgcolor', '#ffffff');
    oTd.style.backgroundColor='#fff';
    //oTd.setAttribute('valign', 'top');
    oTd.style.verticalAlign='top';
    oTd.colSpan='2';

    //alert('createDisplayTab end');
    
    //oTab.onclick=alert;
    oTab.style.zIndex=9999;
    return oTab;
}
function doManipAll(sIdentifier){
    var sExtra='_div_show';
    var aTag=window.document.body.getElementsByTagName('DIV');
    for(i=0;i<aTag.length;i++){
        if(ie){
            if(aTag[i].id.indexOf(sExtra)!=-1)aTag[i].style.display='none';
        }
        else{
            aTag[i].style.zIndex=999;
            if(typeof(sIdentifier)=='string'&&aTag[i].id.indexOf(sIdentifier)!=-1)aTag[i].style.zIndex=1000;
        }
    }
/*
    //doCreateShow(strIdentifier);
    var sPrefix='close_div_cell_';
    var nLenCheck=20;
    var aTag=window.document.body.getElementsByTagName('TH');
    for(i=0;i<aTag.length;i++){
        if(aTag[i].id.indexOf(sPrefix)!=-1){
            alert(window.pageYOffset);
            alert('\nCellY: '+objY(aTag[i])+' - mseDwnY: '+mseDwnY+' - CellY+: '+(objY(aTag[i])+nLenCheck)+
                    '\nCellX: '+objX(aTag[i])+' - mseDwnX: '+mseDwnX+' - CellX+: '+(objX(aTag[i])+nLenCheck)  );
            if(mseDwnY>objY(aTag[i])&&objY(aTag[i])+nLenCheck>mseDwnY&&mseDwnX>objX(aTag[i])&&objX(aTag[i])+nLenCheck>mseDwnX){
                //alert('this is the one to close:'+aTag[i].id.replace('close_div_cell_',''));
                doCreateShow(aTag[i].id.replace(sPrefix,''));
                //hide all help div where close cell in this location
            }
        }
    }*/
}
function objX(obj)
{
    var nObjPosX=0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            nObjPosX+=obj.offsetLeft;
            obj=obj.offsetParent;
        }
    }
    else if (obj.x){
        nObjPosX+=obj.x;
    }
    return nObjPosX;
}
function objY(obj){
    var nObjPosY=0;
    if (obj.offsetParent)   {
        while (obj.offsetParent){
            nObjPosY+=obj.offsetTop;
            obj=obj.offsetParent;
        }
    }
    else if (obj.y){
        nObjPosY+=obj.y;
    }
    return nObjPosY;
}

//******************
function limitTextArea(p_oThis, p_limit)
{   
       //alert("Now fire")  
       var theString = new String() 
       if (p_oThis.value.length > p_limit)  
       {        
              //p_oThis.length = p_limit        
              //alert("Now up inside IF")       
              theString = p_oThis.value     
              p_oThis.value = theString.substr(0, p_limit)  
       }
}



function cancelCopyPaste()
{
    var tagName = new String();
    tagName = document.activeElement.getAttribute("tagName");
    
    if ( tagName.toUpperCase() == "TEXTAREA" )
    {
        if (window.event.ctrlKey == true )
        {
            window.event.cancelBubble = true;
            window.event.returnValue = false
        }       
        
        
    }   
}
function cancelRightClick()
{    
    var strTagName = new String();
    strTagName = document.activeElement.getAttribute("tagName");

    if ( strTagName.toUpperCase() == "TEXTAREA" )
    {
        alert("Action not allowed here")
        return false;
    }
    
} 
//*******************
function selectAll(p_this, p_partOfID)
{
    //it will check all checkboxes whose ID includes the parameter p_partOfID
    var x, isChecked
    var strElemID = new String()    
    var obj_checkBox = new Object()
    var arrChBoxes = new Array();
    var theID = new String()
    isChecked = p_this.checked
    arrChBoxes = window.document.getElementsByTagName("input")
    for(x=0; x < arrChBoxes.length; x++)
    {
        obj_checkBox = arrChBoxes[x]
        theID = arrChBoxes[x].id
        
        if (obj_checkBox.getAttribute("type", 0) == "checkbox" && theID.indexOf(p_partOfID) > -1 )
        {
            obj_checkBox.checked = isChecked
        }
    }
}
function selectAllText(sSelectTextId, sSelectText, sDeselectTxt){
	var oSelectText=document.getElementById(sSelectTextId);
	oSelectText.innerHTML=(oSelectText.innerHTML==sSelectText)?sDeselectTxt:sSelectText;
}




function goto_nav(othis, sNavCode, sHash, sQry){
	if(typeof(sQry)!='string')sQry='';
	//alert('in goto_nav');
	sHash=(typeof(sHash)=='string')?'&hash='+sHash:'';
	var sWadi='';
	sWadi=document.location.search;
	if(sWadi.length==0){
		sWadi=document.forms[0].action;
		sWadi=sWadi.substring(sWadi.indexOf('?'));
	}
	var oCal=document.getElementById('auctRightMenu_auctCalendar_minical');
	//var sMinicaldisplaytype=(oCal.style.display=='block')?'&minicaldisplaytype=block':'';;
	var sPath='http://'+document.location.host
	//if(document.location.href.indexOf('sra.aleppoworld')==-1){sPath+='/adrc_sra'}
	if(document.location.href.indexOf('/miloed/')>0){sPath+='/miloed'}
	//sPath+='/page/p13sendto.aspx'+sWadi+'&nav='+sNavCode+sMinicaldisplaytype+sHash;
	sPath+='/page/p13sendto.aspx'+sWadi+'&nav='+sNavCode+sQry+sHash;
	//alert(sPath);
	//document.location.href=sPath;
	othis.href=sPath;
}
function goto_nsdisplay(othis, sNSDisplay, sHash){
	//alert('in goto_nsdisplay');
	sHash=(typeof(sHash)=='string')?'&hash='+sHash:'';
	var sWadi='';
	sWadi=document.location.search;
	if(sWadi.length==0){
		sWadi=document.forms[0].action;
		sWadi=sWadi.substring(sWadi.indexOf('?'));
	}
	var oCal=document.getElementById('auctRightMenu_auctCalendar_minical');
	//var sMinicaldisplaytype=(oCal.style.display=='block')?'&minicaldisplaytype=block':'';;
	var sPath='http://'+document.location.host
	if(document.location.href.indexOf('/miloed/')>0){sPath+='/miloed'}
	sPath+=sNSDisplay+sWadi+sHash;
	//alert(sPath);
	//document.location.href=sPath;
	othis.href=sPath;
}

//-------------------- START Used For Static Site Navigation --------------------
var siteMapXmlDocLoaded=false;
var siteMapXmlDoc;
function importSiteMapXML(subRoot){
	if(!siteMapXmlDocLoaded){
		var xmlFileName=subRoot+'common/sitemap.xml'
		if (document.implementation&&document.implementation.createDocument){
			siteMapXmlDoc=document.implementation.createDocument("","",null);
			siteMapXmlDoc.onload=siteMapXmlLoaded;
		}
		else if (window.ActiveXObject){
			siteMapXmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			siteMapXmlDoc.onreadystatechange=function () {
				if (siteMapXmlDoc.readyState==4) siteMapXmlLoaded()
			};
		}
		else{
			alert('XML not loaded - browser can not handle loading.');
			return;
		}
		siteMapXmlDoc.load(xmlFileName);
	}
}
function siteMapXmlLoaded(){siteMapXmlDocLoaded=true;}
function goto_nav_static(subRoot, othis, navaka, hash){
	if(!siteMapXmlDocLoaded){importSiteMapXML(subRoot)}

	var oAka=siteMapXmlDoc.getElementsByTagName('aka');
	var oNSDisplay=siteMapXmlDoc.getElementsByTagName('nsdisplay');

	for(i=0;oAka[i];i++){
		if(oAka[i].firstChild.nodeValue==navaka){
			hash=(typeof(hash)=='string'&&hash!='')?'#'+hash:'';
			//var path=oNSDisplay[i].firstChild.nodeValue+'.htm'
			var path=oNSDisplay[i].firstChild.nodeValue
			othis.href=subRoot+path.substr(1)+hash;
			break;
		}
	}
}
//-------------------- END Used For Static Site Navigation --------------------





//#############start show create div text components#################
//generates div and displays it where the mouse has been clicked, on clicking the close div will hide div
//sIdentifier - identifier for the div, generated id for div is identifier with '_divtext' appended - if none will generate one
//sDisplay - the body text to be displayed
//sHeader - if present will show in header otherwise will use default header text
//nDivW - div width default 200 min value 150
//nDivH - div height default 300 min value 60
//requires createDivText function and DivTextIncrement
//requires closeIndent finalizeCloseIndent invertBorderColor function and oCloseEle
var DivTextIncrement=0;
var oCloseEle=new Object();

function doCreateDivText(event, sDisplay,sHeader,sIdentifier,nDivW,nDivH){
	var x
	var y
	if (browser.isIE) {
		x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
	}
	if (browser.isNS){
		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}

	//set default values if undefined
	DivTextIncrement++;
	if(typeof(sIdentifier)=='undefined')sIdentifier='DivText'+DivTextIncrement;
	if(typeof(nDivW)=='undefined'){
		nDivW=200;
	}
	else if(nDivW<150){
		nDivW=150;
	}
	if(typeof(nDivH)=='undefined'){
		nDivH=300;
	}
	else if(nDivH<60){
		nDivH=60;
	}
	//check if div exist yet or not
    var oDivText;
    if(document.getElementById(sIdentifier+'_divtext')){
        oDivText=document.getElementById(sIdentifier+'_divtext');
    }
    else{
		oDivText=createDivText(sDisplay,sHeader,nDivW,nDivH);
		oDivText.id=sIdentifier+'_divtext';
        document.body.appendChild(oDivText);
    }
	oDivText.style.display='block';
    //set div location
	oDivText.style.top=y+'px';
	oDivText.style.left=x+'px';
}
//generates div with header and body display text
//sHead - display header cell text, if null uses default
//sBody - body text to be displayed
//nDivW - div width
//nDivH - div height
//requires css classes to exist .ShowDivContainer .ShowDivHead .ShowDivCloseContainer .ShowDivClose and .ShowDivBody
function createDivText(sBody,sHead,nDivW,nDivH){
	if (typeof(sHead)=='undefined')sHead='Help Text';
    //setup div container
    var oContainer=document.createElement('DIV');
    var oHead=document.createElement('DIV');
    var oCloseContainer=document.createElement('DIV');
    var oClose=document.createElement('DIV');
    var oBody=document.createElement('DIV');
    //set div classes and styles
	oContainer.className='ShowDivContainer';
	oHead.className='ShowDivHead';
	oCloseContainer.className='ShowDivCloseContainer';
	oClose.className='ShowDivClose';
	oBody.className='ShowDivBody';
	oContainer.style.zIndex=DivTextIncrement+5000;
	oHead.style.zIndex=DivTextIncrement+5000;
	oClose.style.zIndex=DivTextIncrement+5000;
	oBody.style.zIndex=DivTextIncrement+5000;
	oContainer.style.width=nDivW+'px';
    oContainer.style.height=nDivH+'px';
    //if(ie){
    /*
    if (browser.isIE){
		oHead.style.width=(nDivW-31)+'px';
	}
	else{
		oHead.style.width=(nDivW-22)+'px';
	}
	*/
    oBody.style.height=(nDivH-20)+'px';
	//set drag head
	//if(ie){
    if (browser.isIE){
		//oHead.onmousedown=function(){dragStart(event,oContainer.id)};//works
		oHead.onmousedown=function(){dragStart(event,this.parentNode.id)};
	}
	else{
        oHead.setAttribute("onmousedown", "javascript:dragStart(event,this.parentNode.id);");
	}
	//set close button
	oCloseContainer.onclick=function(){this.parentNode.style.display='none'};

    if (browser.isIE){
		oClose.onmousedown=function(){closeIndent(event,this,'down')};
	}
	else{
        oClose.setAttribute("onmousedown", "javascript:closeIndent(event,this,'down');");
	}
	//add text
	oHead.appendChild(document.createTextNode(sHead));
	//oHead.innerHTML=sHead;
	oClose.innerHTML='&times;';
	oBody.innerHTML=sBody;
	//append children
	oCloseContainer.appendChild(oClose);
	oContainer.appendChild(oCloseContainer);
	oContainer.appendChild(oHead);
	oContainer.appendChild(oBody);
	return oContainer;
}
function closeIndent(event, oEle, eventtype){
	if(oEle){
		oCloseEle.rootNode=oEle
	}
	else{
		return false;
	}
	if(eventtype=='down'){
		oCloseEle.state='OPEN';
		invertBorderColor(oCloseEle.rootNode);
		if (browser.isIE) {
			//this.attachEvent("onmouseout",function(){closeIndent(event,this,'out');});
		    oCloseEle.rootNode.attachEvent("onmouseout", finalizeCloseIndent);
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (browser.isNS) {
			//this.addEventListener("mouseout",function(){closeIndent(event,this,'out');}, true);
		    oCloseEle.rootNode.addEventListener("mouseout", finalizeCloseIndent, true);
			event.preventDefault();
		}
	}
	else if(eventtype=='over'){
		invertBorderColor(oCloseEle.rootNode);
	}
	
}
function finalizeCloseIndent(event){
  invertBorderColor(oCloseEle.rootNode)
  if (browser.isIE) {
    oCloseEle.rootNode.detachEvent("onmouseout", finalizeCloseIndent);
  }
  if (browser.isNS) {
    oCloseEle.rootNode.removeEventListener("mouseout", finalizeCloseIndent, true);
  }
}
function invertBorderColor(oEle){
	var width01;
	var style01;
	var hex01;
	
	var width02;
	var style02;
	var hex02;

	 if(document.defaultView){
		width01=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-top-width');
		style01=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-top-style');
		var color01=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-top-color');
		var oColor01=color01.replace(')','').replace('rgb(','').split(',');
		var r01=parseInt(oColor01[0]);
		var g01=parseInt(oColor01[1]);
		var b01=parseInt(oColor01[2]);
		hex01='#'+r01.toString(16)+g01.toString(16)+b01.toString(16);
		
		width02=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-bottom-width');
		style02=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-bottom-style');
		var color02=document.defaultView.getComputedStyle(oEle, '').getPropertyValue('border-bottom-color');
		var oColor02=color02.replace(')','').replace('rgb(','').split(',');
		var r02=parseInt(oColor02[0]);
		var g02=parseInt(oColor02[1]);
		var b02=parseInt(oColor02[2]);
		hex02='#'+r02.toString(16)+g02.toString(16)+b02.toString(16);
	 }
	 else if(oEle.currentStyle){
		width01=oEle.currentStyle.borderTopWidth;
		style01=oEle.currentStyle.borderTopStyle;
		hex01=oEle.currentStyle.borderTopColor;

		width02=oEle.currentStyle.borderBottomWidth;
		style02=oEle.currentStyle.borderBottomStyle;
		hex02=oEle.currentStyle.borderBottomColor;
	 }
	oEle.style.borderBottom=width01+' '+style01+' '+hex01;
	oEle.style.borderRight=width01+' '+style01+' '+hex01;

	oEle.style.borderTop=width02+' '+style02+' '+hex02;
	oEle.style.borderLeft=width02+' '+style02+' '+hex02;
}

//#############end show create div text components#################








//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
//dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}


// ##########################################################
// ##########################################################
// ##########################################################
// ---------------------------------------------------------
function showHideManyDivs(div_id)
{
	var anyID = new String(), x, strDisplay = new String();
	
	strDisplay = document.getElementById(div_id).style.display
	strDisplay = strDisplay.toLowerCase()
	
	//for (x = 0; x < document.all.length-1; x++)
	//{
	//	anyID = document.all.item(x).getAttribute("id", 0)		
		
	//	if ( anyID.indexOf("dvProg_", 0) > -1 )
	//	{		document.getElementById(anyID).style.display = "none"		}
	//}
	// -------------------------------------------------------------------
	//alert("Helo showHideManyDivs: " + div_id + "\nstrDisplay: " + strDisplay)
	
	//alert("document.getElementById(div_id).style.display: " + document.getElementById(div_id).style.display)
	
	
	if ( strDisplay == "block" )
	{	document.getElementById(div_id).style.display = "none"		}
	else
	{	document.getElementById(div_id).style.display = "block"		}
	
	//alert("document.getElementById(div_id).style.display: " + document.getElementById(div_id).style.display)

	
	return false;
}
function showhide(ele_id)
{
	var oEle=document.getElementById(ele_id);
	oEle.style.display=(oEle.style.display=='none')?'block':'none';
}
// ---------------------------------------------------------


function jTrim(p_bigString)
{
	var regul = new RegExp();
	var bigString = new String();
	
	bigString = p_bigString;
	regul = /^\s+|\s+$/g	
	bigString = bigString.replace(regul, "");	
	//alert("bigString is: '" + bigString + "'" 
	//			+ "\nLength: " + bigString.length )
	return bigString;
}
// ==============================================

function jTrimChar_Need_testing(p_bigString, p_char, p_oneOrAll)
{
	// p_oneOrAll must be:  "one", "all"
	var x, regul = new RegExp();
	var bigString = new String()
	bigString = jTrim(p_bigString)
	if ( p_oneOrAll == "one" )
	{
		regul = /^p_char|p_char$/
	}
	else if ( p_oneOrAll == "all" )
	{
		regul = /^p_char+|p_char+$/g
	}
	
	bigString = bigString.replace(regul, "")
	return bigString
}



function jTrimChar(p_bigString, p_char, p_oneOrAll)
{
	// oneOrAll must be:  "one", "all"
	var x
	var bigString = new String()
	bigString = jTrim(p_bigString)
	//alert("argStr was: '" + argStr + "'" )	
	if ( bigString.length > 0 )
	{
		for (x=0; x<bigString.length; i++)
		{
			if ( bigString.charAt(x) == p_char )
			{
				bigString = bigString.substr(1)
				x--
			}
			else
			{	break;		}			
		}
		for ( x = bigString.length-1; x>0; x--)
		{
			if ( bigString.charAt(x) == p_char )
			{
				bigString = bigString.substr(0, x)				
			}
			else
			{	break;	}
		}
	}
	//alert("trim argStr: '" + argStr + "'" )	
	return bigString
}

// ==============================================
function isCheckedAtLeastOne_OLD(p_partID)
{
	var arrayTagNames = new Array();
	var x, retValue, elem = new Object();
	retValue = false;
	
	arrayTagNames = document.getElementsByTagName("input")
	
	for (x=0; x < arrayTagNames.length - 1; x++)
	{
		elem = arrayTagNames[x]		
		if (elem.id.indexOf(p_partID) > -1 && elem.checked == true )
		{
			retValue = true;
			break;
		}
	}
	// ---------------------
	if ( retValue == false )
	{
		alert("Select at least one.")
	}
	//alert("Return: " + retValue)
	// ----------------------
	return retValue;
}

function isCheckedUnCheckedOne(p_partID, p_checked_unchecked, p_mesg)
{
	// p_checked_unchecked values: "one_checked" , "one_unchecked"
	// "one_checked": validates if at least one is checked.  Use this if you want mandatory
	// "one_unchecked": validates if at least one is un-checked, use this if you dont want the user to check all the boxes, 
	//					he cannot delete all the list
	var arrayTagNames = new Array();
	var x;
	var elem = new Object();
	var blnReturn;
	var blnChecking;
	blnReturn = false;	
	//alert("Helo isCheckedUnCheckedOne 1")
	//return false;
	
	if ( p_checked_unchecked == "one_unchecked" )
	{	blnChecking = false;   }
	else if ( p_checked_unchecked == "one_checked" )
	{	blnChecking = true;   }
	arrayTagNames = document.getElementsByTagName("input")
	//alert("Helo isCheckedUnCheckedOne 2")
	//return false;
	for (x=0; x < arrayTagNames.length - 1; x++)
	{
		elem = arrayTagNames[x]		
		if (elem.id.indexOf(p_partID) > -1 && elem.checked == blnChecking )
		{
			blnReturn = true
			break;
		}
	}
	// ===========================================
	if ( blnReturn == false )
	{	alert(p_mesg)		}
	return blnReturn;
}
// ====================================================
function isValidOtherTextBox(p_partID, p_strOtherText, p_mesg)
{
	var arrayLabelTagNames = new Array();
	var x, elem = new Object(), objCheckBox = new Object();
	p_strOtherText = jTrim(p_strOtherText);
	arrayLabelTagNames = window.document.getElementsByTagName("label", 0)
	for (x=0; x < arrayLabelTagNames.length - 1; x++)
	{
		elem = arrayLabelTagNames[x]		
		objCheckBox = elem.parentNode.children[0]
		if ( objCheckBox.id.indexOf(p_partID) > -1 && elem.innerText.toLowerCase().indexOf("other") > -1 )
		{
			if ( (objCheckBox.checked == true && p_strOtherText == "") 
							|| (objCheckBox.checked == false && p_strOtherText != "") )
			{	
				//alert("objCheckBox id: " + objCheckBox.id + ", \np_strOtherText: " + p_strOtherText + ", \np_mesg: " + p_mesg)
				alert(p_mesg)
				return false;
			}			
		}
	}
	return true;
}
// ###########################################################################

function colorTheCheckBox(p_this, p_type)
{
	var prevClass = new String()
	var newClass = new String()
	//prevClass = p_this.parentNode.className;	
	if ( p_this.checked == true )
	{
		p_this.parentNode.className = "chServ_selected"
	}
	else
	{
		p_this.parentNode.className = "chServ"
	}
}



/*
function colorTheCheckBox_old_061025(p_this)
{
	var x;
	var strin = new String()
	var arrInputs = new Array();
	var elem = new Object();
	var strOldColor;
	strin = "";
	
	if ( p_this.checked == true )
	{
		p_this.parentNode.className = "selectedRow"
	}
	else
	{
		p_this.parentNode.className = ""
	}
}
*/
// ###########################################################################

// ===================================================================
function getAttribValue(p_oneField, p_attrib)
{
	var indexOfAttrib, indexOfComma, attribLen, strTheValue = new String();
	p_oneField = jTrimChar(p_oneField, ",", "all") + ","
	indexOfAttrib = p_oneField.indexOf(p_attrib + "=")
	if ( indexOfAttrib == -1 )
	{	
		//alert ( "getAttribValue, indexOfAttrib: " + indexOfAttrib )
		return ""	
	}	
	indexOfComma = p_oneField.indexOf(",", indexOfAttrib)
	attribLen = p_attrib.length
	strTheValue = p_oneField.substr(indexOfAttrib + attribLen + 1, (indexOfComma-indexOfAttrib) - attribLen - 1 )
	/*	alert("getAttribValue, p_oneField: " + p_oneField 
				+ "\n p_attrib: " + p_attrib
				+ "\n indexOfAttrib: " + indexOfAttrib
				+ "\n indexOfComma: " + indexOfComma
				+ "\n attribLen: " + attribLen
				+ "\n strTheValue: " + strTheValue				)	*/
	return strTheValue;
}
// ======================================================================

// =======================================================================
function isValid( p_formID, p_string, p_isAlert, p_arraParam )
{
	/*  Example of p_string    -----------------------------------------------
	*	Standard Attributes: type, id, isManda, caption, min, max, regxAllow, regxNotAllow
	*	p_string = "type=zip5, id=zip5, isManda=yy,caption=Zip, regxAllow=[^\d$?\D+]#" 
	*			+ "type=zip4, id=zip4, isManda=nn,caption=Zip#" 
	*			+ "type=username, id=username,caption=Username isManda=yy, min=6, max=14#"
	*			+ "type=text, id=firstname,caption=First Name, isManda=yy, max=50#"
	*			+ "type=email, id=email, isManda=yy#"
	*			+ "type=phone, id=email, isManda=yy#"
	*	If you want fixed length pass the same value to 'min' and 'max'  */ 			
	// -----------------------------------------------  
	var strInput = new String(), strOneField = new String(), arraParam = new Array();
	var strValue = new String(), arraInput = new Array(), arraHash = new Array(), x, strMesg, flag;
	var regul2 = new RegExp(), regul3 = new RegExp(), mat2, mat3, matAllow, matNotAllow;
	strInput = jTrimChar(p_string, "#", "all")
	arraInput = strInput.split("#")
	arraParam = p_arraParam
	flag = ""
	strMesg = ""
	matAllow = null;
	matNotAllow = null;
	for ( x in arraInput )
	{
		strOneField = arraInput[x]
		arraHash.type = getAttribValue(strOneField, "type")
		arraHash.id = getAttribValue(strOneField, "id")
		arraHash.isManda = getAttribValue(strOneField, "isManda")
		arraHash.min = getAttribValue(strOneField, "min")
		arraHash.max = getAttribValue(strOneField, "max")
		arraHash.caption = getAttribValue(strOneField, "caption")
		arraHash.regxAllow = getAttribValue(strOneField, "regxAllow")
		arraHash.regxNotAllow = getAttribValue(strOneField, "regxNotAllow")
		strValue = jTrim(eval("document.forms['" + p_formID + "']." + arraHash.id + ".value"))
		
		if ( arraHash.isManda == "" )
		{	arraHash.isManda = "nn"	}
		
		if ( arraHash.regxAllow != "" )
		{	matAllow = strValue.match(arraHash.regxAllow)		}
		if ( arraHash.regxNotAllow != "" )
		{	matNotAllow = strValue.match(arraHash.regxNotAllow)	}
		
		if ( arraHash.isManda == "yy" && strValue == "" )
		{
			strMesg += "\nEnter the " + arraHash.caption
			flag = "bad"
			continue;
		}
		
		else if ( arraHash.isManda == "yy" || (arraHash.isManda == "nn" && strValue != "" ) )
		{
			if ( arraHash.regxAllow != "" && matAllow == null )
			{
				strMesg += "\nThe " + arraHash.caption + " has invalid characters."
				flag = "bad"
				continue;
			}
			if ( arraHash.regxNotAllow != "" && matNotAllow != null )
			{
				strMesg += "\nThe " + arraHash.caption + " has invalid characters: " + matNotAllow
				flag = "bad"
				continue;
			}
			if ( arraHash.min != "" && arraHash.max != "" && arraHash.min == arraHash.max 
							&& strValue.length != arraHash.min )
			{
				strMesg += "\nThe " + arraHash.caption + " must be " + arraHash.min + " characters length."
				flag = "bad"
				continue;
			}
			else if ( arraHash.min != "" && arraHash.max != "" && arraHash.min != arraHash.max
						&& ( strValue.length < arraHash.min	|| strValue.length > arraHash.max ) )
			{
				strMesg += "\nThe " + arraHash.caption + " must be between "
							+ arraHash.min + " and " + arraHash.max + " characters."
				flag = "bad"
				continue;
			}
			// -----------------------------------------------------------
			if ( arraHash.type == "text" )
			{
				// do nothing so far		
			}			
			else if ( arraHash.type == "username" || arraHash.type == "password" )
			{
				if ( arraHash.regxNotAllow == "" )
				{	
					regul2 = new RegExp("[^a-zA-Z0-9_]{1}")  
					mat2 = strValue.match(regul2);
					if ( mat2 != null )
					{
						strMesg += "\nThe " + arraHash.caption + " is invalid: " + mat2
						flag = "bad"
					}				
				}
			}							
			else if ( arraHash.type == "zip5" )
			{	
				regul2 = /^\d{5}$/;
				mat2 = strValue.match(regul2);				
				if ( mat2 == null || strValue == "00000" )
				{
					strMesg += "\nFirst part of zip must be 5 digits"
					flag = "bad"
				}				
			}			
			else if ( arraHash.type == "zip4" )
			{
				regul2 = /^\d{4}$/;
				mat2 = strValue.match(regul2);				
				if ( mat2 == null || strValue == "0000"   )
				{
					strMesg += "\nThe second part of zip must be 4 digits, or leave it empty"
					flag = "bad"
				}				
			}			
			else if ( arraHash.type == "email" )
			{
				regul2 = /^[a-zA-Z0-9-_]+\.?[a-zA-Z0-9-_]+@{1}[a-zA-Z0-9-_]+\.?[a-zA-Z0-9-_]+\.?[a-zA-Z0-9-_]+$/
				mat2 = strValue.match(regul2);				
				if ( mat2 == null )
				{
					strMesg += "\nThe " + arraHash.caption + " is invalid."
					flag = "bad"
				}				
			}
			else if ( arraHash.type == "phone" )
			{
				regul2 = new RegExp("[^0-9() -.]{1}")
				mat2 = strValue.match(regul2);
				if ( mat2 != null )
				{
					strMesg += "\nThe " + arraHash.caption + " has an invalid character: '" + mat2 + "'."
					flag = "bad"
				}				
				//regul3 Matthias = /^[^0-9]*(([0-9][^0-9]*){10,11}|([0-9][^0-9]*){13})[^0-9]*$/
				regul3 = /^\D*((\d\D*){10,11}|(\d\D*){13})\D*$/
				mat3 = strValue.match(regul3);				
				if ( mat3 == null ) 
				{
					strMesg += "\nThe " + arraHash.caption + " must contain either 10, 11 or 13 digits."
					flag = "bad"
				}				
			}
			else if ( arraHash.type == "memword" )
			{
				// nothing now
			}
		}
	}
	// ------------------------------------------------------	
	if ( typeof(arraParam) == "undefined"){	
		arraParam = new Array();
		arraParam.mesgIn = ""			
	}
	else if ( typeof(arraParam.mesgIn) == "undefined" )	{	
		arraParam.mesgIn = ""		
	}
	// ###############################################	
	//  now new code
	var strFinalMesg = new String();
	strFinalMesg = ""
	if ( arraParam.mesgIn != "" ){
		strFinalMesg += arraParam.mesgIn	
		flag = "bad"
	}
	// ----------------------------------------------------
	if ( strMesg != "" )
	{	
		strFinalMesg += strMesg	
	}
	// ----------------------------------------------------
	if ( flag == "bad" ){	
		if ( p_isAlert == "yy" ){
			alert("Please check the following fields: \n" + strFinalMesg)			
		}
		else {
			arraParam.mesgOut = strFinalMesg
		}
		return false
	}
	else {
		return true
	}
	// ###############################################
	// ------------------------------------------------------	
	/*
	if ( flag == "bad" || arraParam.mesgIn != "" ){
		if ( p_isAlert == "yy" ){	
			alert("Please check the following fields: \n" + strMesg + arraParam.mesgIn)
		}
		else{
			arraParam.mesgOut = strMesg
		}
		return false;
	}	
	else{	
		return true;	
	}
	*/
	
}
// ===================================================================


