﻿var rootPath='StackFree';

// ############   Jake Functions      #######################################

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 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 doMapSS(othis)
{   
    var sSocialSecurity=new String;
    sSocialSecurity=othis.value;
    var nLenDate=sSocialSecurity.length;
    var sLastChar=sSocialSecurity.substr(nLenDate-1,1);
    var sFirstChar=sSocialSecurity.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=sSocialSecurity.substr(0, nLenDate-1);
        return;
    }

    var bConvert=false;
	switch(nLenDate){
		case 3:
			bConvert=true;
			break;
		case 6:
			bConvert=true;
			break;
		case 10:
			//alert(sSocialSecurity);
			break;
	}
	if(bConvert){
		if(nKeyCode==8){
			othis.value=sSocialSecurity.substr(0,nLenDate-1);
		}
		else{
			othis.value=sSocialSecurity+'-';
		}
	}
}



//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);
}

//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 showhide(ele_id)
{
	var oEle=document.getElementById(ele_id);
	oEle.style.display=(oEle.style.display=='none')?'block':'none';
}

function getCookieValue(name){
	var oCookies = document.cookie.split(';');
	var namevalue='';
	
	for(i=0;oCookies[i];i++){
		namevalue=jTrim(oCookies[i]);
		if(namevalue.indexOf(name+'=')==0){
			return namevalue.substring((name+'=').length, namevalue.length);
		}
	}
}

//------------AJAX START-------------
function createXMLHttp(){
	var oXmlHttp=null;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		oXmlHttp=new XMLHttpRequest();
		if (oXmlHttp.overrideMimeType){oXmlHttp.overrideMimeType('text/xml');}
	} else if (window.ActiveXObject) { // IE
		try {
			oXmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			try {
				oXmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				oXmlHttp=null
			}
		}
	}
	return oXmlHttp
}
//------------AJAX END-------------
function AddEvent(oEle,EventName,FunctionCall){
	EventName=EventName.toLowerCase();
	if(window.addEventListener){
		//alert('addEventListener');
		oEle.addEventListener(EventName,FunctionCall,true);
	}
	else if(window.attachEvent){
		//alert('attachEvent');
		oEle.attachEvent('on'+EventName,FunctionCall);
	}
}
//******************
// ##################################################################
// ##################################################################
// ##################################################################


// ############    Ali Start Here           #######################



// ##########     Test for browsers  ##################################################

// ######################################################################

/*
alert("Navigator: "			
			+ "\n  navigator.userAgent: " + navigator.userAgent
			+ "\n  navigator.appName: " + navigator.appName
			+ "\n  navigator.vendor: " + navigator.appName			
)
*/

var gloBrowser;
if ( navigator.appName.indexOf("Microsoft") > -1 )
{
	gloBrowser = "IE"
}
else if  ( navigator.appName.indexOf("Netscape") > -1 )
{
	gloBrowser = "FF"
}


// ================================================================



// #######################################################################################################

var nKeyCode;
var sKeyCode;
document.onkeydown = runKeyDown;
document.onkeyup = runKeyUp;
//document.onkeydown = cancelCopyPaste;
//document.oncontextmenu = cancelRightClick;


function cancelRightClick(e)
{    
    //alert("cancelRightClick.")
    //return false; 
    // ---------------------------------------------------- 
    var strTagName = new String();
    strTagName = document.activeElement.getAttribute("tagName");

    if ( strTagName.toUpperCase() == "TEXTAREA" )
    {
        alert("Action not allowed here")
        return false;
    }
}


function runKeyUp(e){
	getKeyCode(e)
}
function runKeyDown(e)
{
	getKeyCode(e);
	//cancelEnterKey();
	//cancelCopyPaste();
	//nKeyCode=window.event.keyCode;
}
function cancelEnterKey()
{
    //alert("cancel Enter Key now")
    var activeItem = document.activeElement
    //var activeItemID = document.activeElement.getAttribute("id");
    var activeItemID = document.activeElement.id;
    if ( window.event.keyCode == 13 )
    {
        //alert("Helo tagName: " + document.getElementById(activeItemID).tagName.toLowerCase() )
        if ( activeItemID != "auctLogin_UserName" && activeItemID != "auctLogin_PassWd" 
                && activeItemID != "auctLogin_UID" && activeItemID != "auctLogin_passwd"
                && activeItem.tagName.toLowerCase() != "textarea"   )
        { 
            window.event.returnValue = false;
        }
    }     
}

function cancelCopyPaste(){
	//alert("Copy paste now")
	//return false;
	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 getKeyCode(e){
	if (!e) 
	{	e = window.event;	}
	nKeyCode = e.keyCode;
	sKeyCode =  String.fromCharCode(e.keyCode);
	return false;
}


// ####################################################


function limitTextArea(p_oThis, p_limit)
{   
	//alert("Now fire") 
	var x = 0  
	var theString = new String() 
	while ( p_oThis == null && x < 1000 )
	{
		x++
	}
	
	
	if (p_oThis != null )
	{
		if (p_oThis.value.length > p_limit)  
		{        
			theString = p_oThis.value     
			p_oThis.value = theString.substr(0, p_limit)
			alert("Maximum limit reached:\n - truncated to " + p_limit + " characters.");
		}
	}
}



//*******************


function selectAll_old(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
		}
	}
	/*	
	for(x=0; x < document.forms[0].length; x++)
	{
		obj_checkBox = document.forms[0].item(x)
		
		strElemID = obj_checkBox.getAttribute("id", 0)
		if (strElemID.indexOf(p_partOfID) > -1)
		{
			obj_checkBox.checked = isChecked
		}
		
	}
	*/
}


function selectAll(p_this, p_partOfID)
{
	//it will check/uncheck all checkboxes whose ID includes the parameter p_partOfID
	selectDeselectAll(p_partOfID, p_this.checked)	
}

// ####################################################################################
function selectDeselectAll(p_partOfID, p_bool)
{
	var x, obj_checkBox = new Object(), arrChBoxes = new Array(), theID = new String()
	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 = p_bool
		}
	}
}

// ---------------------------------------------------------
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 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, 
	//					eg. he cannot delete all the list
	var arrayTagNames = new Array();
	var x;
	var elem = new Object();
	var bolReturn;
	var bolChecking;
	bolReturn = false;	
	//alert("Helo isCheckedUnCheckedOne 1")
	//return false;
	
	if ( p_checked_unchecked == "one_unchecked" )
	{	bolChecking = false;   }
	else if ( p_checked_unchecked == "one_checked" )
	{	bolChecking = 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 == bolChecking )
		{
			bolReturn = true
			break;
		}
	}
	// ===========================================
	if ( bolReturn == false && p_mesg != "" )
	{	
		//alert(p_mesg)		
	}
	return bolReturn;
}
// ====================================================
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 && getInnerText(elem).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)
{
	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 colorRadioButton(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 )
{
	/* Return boolean    -----------------------------------------------
	*  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' 		
	* -- p_arraParam.mesgIn, mesgOut
	*/			
	// -----------------------------------------------  
	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 += "\n" + 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 == "zip_UK" )
			{
				//regul2 = /^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]{0,1}\s[0-9]{1}[a-zA-Z]{2}$/;
				// from British Standards:  BS7666 schema
				// [A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][A-Z-[CIKMOV]]{2}
				regul2 = /^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]{0,1}\s[0-9]{1}[a-zA-Z]{2}$/;
				mat2 = strValue.match(regul2);				
				if ( mat2 == null  )
				{
					strMesg += "\nThe post code is invalid"
					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 == "worldPhone" )
			{
				regul2 = new RegExp("[^0-9 ().-]{1}")
				mat2 = strValue.match(regul2);
				if ( mat2 != null )
				{
					strMesg += "\nThe " + arraHash.caption + " has an invalid character: '" + mat2 + "'."
					flag = "bad"
				}
			}
			else if ( arraHash.type == "memword" )
			{
				// nothing now
			}
			else if ( arraHash.type == "selectBox" )
			{
				if ( strValue == "" )
				{
					strMesg += "\n" + arraHash.caption
				}
			}
		}
	}
	// ------------------------------------------------------	
	if ( typeof(arraParam) == "undefined"){	
		arraParam = new Array();
		arraParam.mesgIn = ""
		arraParam.mesgOut = ""			
	}
	else 
	{
		if ( typeof(arraParam.mesgIn) == "undefined" )	{	
			arraParam.mesgIn = ""
		}
		if ( typeof(arraParam.mesgOut) == "undefined" )	{	
			arraParam.mesgOut = ""
		}
	}
	// ###############################################	
	//  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;	
	}
	*/
	
}
// ===================================================================

function showMore(p_allString, p_divID)
{	
	//alert("Navigator is userAgent: " + window.navigator.userAgent)
	// CALLED WHEN CLICKED 'More'
	//alert("Here show more");
	var objDiv_1 = new Object();
	objDiv_1 = document.getElementById(p_divID);
	//alert("Here 2")
	objDiv_1.style.display = "block";
	//alert("Here 3")
	// ============================================
	var oLblDivString = new Object();
	oLblDivString = document.getElementById("lblDivString");
	
	//alert("document.all is: " + document.all
	//			+ "\n document.layers is: " + document.layers
	//			)
	
	setInnerText(oLblDivString, p_allString)
	
	//if ( gloBrowser == "IE" )
	//{
	//	oLblDivString.innerText = p_allString
	//}
	//else
	//{
		//oLblDivString.textContent() = p_allString
	//	document.getElementById("lblDivString").textContent = p_allString;

	//}
	//document.getElementById("lblDivString").textContent = p_allString;
	//alert("Here textContent: " + oLblDivString.textContent)
	//alert("Here 5")
	//alert("showMore")
	
}

// #####################################################################################

function closeDiv(p_divID)
{	
	// CALLED WHEN CLICKED 'Close'
	//alert("Here closeDiv: " + p_divID)
	var objDiv = new Object();	
	objDiv = document.getElementById(p_divID);
	objDiv.style.display = "none";	
}


// #####################################################################################

function getInnerText(p_elem)
{	
	var retValue = new String()
	if ( gloBrowser == "IE" )
	{	retValue = p_elem.innerText	}
	else
	{	retValue = p_elem.textContent	}
	// ---------------------------------------
	retValue = (retValue == null)    ?    "" : retValue
	return retValue;
}
// #####################################################################################
function setInnerText(p_elem, p_value)
{	
	var retValue = new String()
	if ( gloBrowser == "IE" )
	{	p_elem.innerText = p_value	}
	else
	{	p_elem.textContent = p_value}
}

// #####################################################################################
function getSelectedText(p_selBoxID)
{
	var oSelBox, theIndex, retValue
	oSelBox = document.getElementById(p_selBoxID)
	theIndex = oSelBox.selectedIndex
	retValue = oSelBox.options[theIndex].text
	return retValue	
}

// #####################################################################################

function jTrim_old(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 jTrim(p_bigString)
{
	var regul = new RegExp();
	var largeString = new String();
	//alert("typeof(p_bigString): " + (typeof(p_bigString)).toString()  )
	if ( (typeof(p_bigString)).toString().toLowerCase() != "string"
			|| p_bigString == undefined || p_bigString == null  )
	{
		//alert("Catch now")
		return "";
	}
	largeString = p_bigString.toString()
	if ( largeString.indexOf(" ") == -1 )
	{
		return largeString;
	}
	//alert("Inside jTrim 1: " + largeString)
	
	regul = /^\s+|\s+$/g
	//alert("Inside jTrim 2")	
	
	try
	{
		largeString = largeString.replace(regul, "");
	}
	catch (ex)
	{
		alert("Inside jTrim Exception: " + ex.value )	
	}
	
	
	//alert("Inside jTrim 3")	
	//alert("bigString is: '" + bigString + "'" 
	//			+ "\nLength: " + bigString.length )
	//alert("Inside jTrim, largeString: " + largeString)
	return largeString;
}



// ==============================================
function isInt(p_value)
{ 
	//alert("Inside isInt function")
	//alert("Inside isInt jTrim(p_value): " + jTrim(p_value))
	if ( jTrim(p_value) == "") return false; 
	//alert("Inside isInt 1")
	var x = parseInt(p_value); 
	//alert("Inside isInt 2")
	if (isNaN(x)) return false; 
	//alert("Inside isInt 3")
	return p_value == x && p_value.toString() == x.toString()
	//alert("Inside end of isInt function")
}


function isFloat(p_value)
{
	
	if ( jTrim(p_value) == "") return false; 
	var x = parseFloat(p_value)
	if (isNaN(x)) return false; 
	return p_value == x && p_value.toString() == x.toString()
}


function isNum(p_value)
{
	if ( jTrim(p_value) == "") return false; 
	var x = p_value
	if (isNaN(x)) return false; 
	return p_value == x && p_value.toString() == x.toString()
}


// #####################################################################################

function endWith(p_parent, p_child) 
{ 
	var x, parLen, childLen
	p_parent = jTrim(p_parent)
	p_child = jTrim(p_child)
	parLen = p_parent.length
	childLen = p_child.length
	//alert("endWith func, substring: " + p_parent.substring( parLen - childLen, parLen - 1 ))
	if ( p_parent.substring( parLen - childLen ) == p_child )
	{	return true;
		
	}
	else
	{		return false;
		
	
	}
} 
// #####################################################################################

function startWith(p_parent, p_child) 
{ 
	var x, parLen, childLen
	p_parent = jTrim(p_parent)
	p_child = jTrim(p_child)
	parLen = p_parent.length
	childLen = p_child.length	
	if ( p_parent.substring( 0, parLen - childLen ) == p_child )
	{		return true;	}
	else
	{		return false;	}
}
// #####################################################################################
function getPrefix(p_allString, p_rightPart)
{
	var thePrefix, bigLen, smallLen
	bigLen = p_allString.length
	smallLen = p_rightPart.length
	thePrefix = p_allString.substr(0, bigLen - smallLen)
	return thePrefix
}





function getRadioText(p_this)
{
	// works only for .Net
	return  getInnerText(p_this.nextSibling)
}


function getRadioByPartOfName(p_partName)
{
	var arrAllInputs, x, oReturn
	arrAllInputs = document.getElementsByTagName("input", 0)
	for ( x=0; x < arrAllInputs.length; x++ )
	{
		if ( arrAllInputs[x].name.indexOf(p_partName) > -1 && arrAllInputs[x].type.toLowerCase() == "radio" )
		{
			oReturn = arrAllInputs[x]
			return oReturn
		}
	}
}

// _____________________________________________________________________________________

function isArrayDuplicate(p_array, p_objRefDuplicate)
{
	var x, y, retValue
	var arrToFind = new Array()
	arrToFind = p_array
	
	//alert("arrToFind length: " + arrToFind.length)
	//alert("p_array length: " + p_array.length)
	
	for ( x=0; x < (arrToFind.length - 1); x++ )
	{
		for ( y=(x+1); y < arrToFind.length; y++ )
		{
			if ( arrToFind[x] == arrToFind[y] )
			{
				p_objRefDuplicate.value = arrToFind[x]
				//alert("jsFunctions, p_duplValue: " + p_duplValue)
				return true;
			}
		}
	}
	return false;
}


function leftPad(p_value, p_size, p_pad)
{
	var newValue;
	newValue = new String(p_value)
	while (newValue.length < p_size)
	{
		newValue = p_pad + newValue;
	}
	return newValue
}
// ##################################################################
function rightPad(p_value, p_size, p_pad)
{
	var newValue;
	newValue = new String(p_value)
	while (newValue.length < p_size)
	{
		newValue = newValue + p_pad;
	}
	return newValue
}






















function OpenImgWindow(ImgScr){
	var ImgWin = window.open("","ImgWin","width=1024,height=800,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,copyhistory=no");
	if (ImgWin) {
		ImgWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
	var ImgHTML='<img src="'+ImgScr+'"/>';
	var ImgPopUpHtml;
	ImgPopUpHtml=gImgPopUpHtml.replace('IMG_HERE',ImgHTML);
	ImgWin.document.body.innerHTML = '';
	ImgWin.document.open();
	ImgWin.document.write(ImgPopUpHtml);
	ImgWin.document.close();
}
var gImgPopUpHtml = new String("\
<html>\
<head>\
<title>Image</title>\
</head>\
<body>\
<div style='margin-bottom:3px;font-size:x-small;'><a href='#' onclick='window.close();return false;'>CLOSE</a></div>\
IMG_HERE\
<div style='margin-top:3px;font-size:x-small;'><a href='#' onclick='window.close();return false;'>CLOSE</a></div>\
</body>\
</html>");


function bindEvent(oEle,EventName,FunctionCall){
	EventName=EventName.toLowerCase();
	if(window.addEventListener){
		//alert('addEventListener');
		oEle.addEventListener(EventName,FunctionCall,true);
	}
	else if(window.attachEvent){
		//alert('attachEvent');
		oEle.attachEvent('on'+EventName,FunctionCall);
	}
}
function unbindEvent(oEle,EventName,FunctionCall){
	EventName=EventName.toLowerCase();
	if(window.removeEventListener){
		oEle.removeEventListener(EventName,FunctionCall,true);
	}
	else if(window.detachEvent){
		oEle.detachEvent('on'+EventName,FunctionCall);
	}
}











