function updateLabel(elementId){
	var value = document.getElementById(elementId).value;
	var label = document.getElementById('label_'+elementId);
	label.innerHTML=value;
}
/////////////////////////////////////////////////////////////
function showSuggestion(element){
	var successDiv=document.getElementById('success_'+element.id);
	
	
	var suggestionDiv = document.getElementById('suggestion_'+element.id);
	if(suggestionDiv!=undefined&&suggestionDiv!=null){
		if(successDiv==undefined){
			showDiv(suggestionDiv.id);
		}
		else if(successDiv!=undefined&&successDiv.style.visibility=='hidden'){
			showDiv(suggestionDiv.id);
		}
	}
}
/////////////////////////////////////////////////////////////
function hideSuggestion(element){
	var suggestionDiv = document.getElementById('suggestion_'+element.id);
	if(suggestionDiv!=undefined&&suggestionDiv!=null){
		hideDiv(suggestionDiv.id);
	}
}
/////////////////////////////////////////////////////////////
function showNotification(flag,element){
	var inputArea = document.getElementById('area_'+element.id);
	var docroot=getContext()+getDocRoot();
	if(flag==true){
		inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/done.gif" alt="done" width="18" height="17" />';
		//inputArea.innerHTML='<img src="/kw/xflow/kw-pack/docroot/zain/themes/default_en/images/done.gif" alt="done" width="18" height="17" />';
		//showInformation();
	}
	else{
		inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/feild_error.gif" alt="done" width="18" height="17" />';
		var errorText = document.getElementById('errorText_'+element.id);
		if(errorText!=null&&errorText!=undefined){
			showError(errorText.value);
		}
	}
}
/////////////////////////////////////////////////////////////
function showServerSideNotification(flag,element){
	var inputArea = document.getElementById('area_'+element.id);
	var docroot=getContext()+getDocRoot();
	if(flag==true){
		inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/done.gif" alt="done" width="18" height="17" />';
		return;
		//inputArea.innerHTML='<img src="/kw/xflow/kw-pack/docroot/zain/themes/default_en/images/done.gif" alt="done" width="18" height="17" />';
		//showInformation();
	}
	else{
		inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/feild_error.gif" alt="done" width="18" height="17" />';
		var errorText = document.getElementById('errorText_'+element.id);
		if(errorText!=null&&errorText!=undefined){
			showError(errorText.value);
		}
	}
}
/////////////////////////////////////////////////////////////
function showValue(value,divId){
	var divLabel = document.getElementById(divId);
	if(divLabel!=null&&divLabel!=undefined){
		divLabel.innerHTML=value;
	}
}
///////////////////////////////////////////////////////////////////
function showError(errorText){
	hideDiv('informationArea');
	var errorLabel = document.getElementById('errorAreaLabel');
	if(errorLabel!=undefined&&errorLabel!=null){
		errorLabel.innerHTML=errorText;
	}
	showDiv('errorArea');
}
/////////////////////////////////////////////////////////////
function showInformation(){
	showDiv('informationArea');
	hideDiv('errorArea');
}
/////////////////////////////////////////////////////////////
function showLoadingBar(element){
	var inputArea = document.getElementById('area_'+element.id);
	if(inputArea==undefined){
		alert("Define TD/DIV with id = area_inputId");
	}
	else
	{
		var docroot=getContext()+getDocRoot();
		inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/loadingss.gif" alt="loading" width="63" height="15" />';
	}
}
/////////////////////////////////////////////////////////////
function hideLoadingBar(element){
	var inputArea = document.getElementById('area_'+element.id);
	if(inputArea==undefined){
		alert("Define TD/DIV with id = area_inputId");
	}
	else
	{
		var docroot=getContext()+getDocRoot();
		inputArea.innerHTML='';
	}
}
/////////////////////////////////////////////////////////////
function showSimpleError(element,message){
	var inputArea = document.getElementById('area_'+element.id);
	if(inputArea==undefined){
		alert("Define TD/DIV with id = area_inputId");
	}
	else
	{
		inputArea.innerHTML=message;
	}
}
/////////////////////////////////////////////////////////////
function showErroMessage(element,message){
	var docroot=getContext()+getDocRoot();
	var inputArea = document.getElementById('area_'+element.id);
	inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/feild_error.gif" alt="erro" width="18" height="17" />';
	inputArea.innerHTML+=' '+message;
}
/////////////////////////////////////////////////////////////
function disableArea(divId){
   var area = document.getElementById(divId);
   if(area!=undefined){
   	area.className="diableArea";
   	document.body.style.cursor = 'wait'; 
   }
   else
   {
   	alert("Area to be disable not defined");
   }
}
function enableArea(divId){
   var area = document.getElementById(divId);
   if(area!=undefined){
   	area.className="enableArea";
   	document.body.style.cursor = ''; 
   }
   else
   {
   	alert("Area to be enable not defined");
   }
}

function showInformationText(text){
	document.getElementById('info').value=text;
	showDiv('informationArea');

	hideDiv('errorArea');
}

function showLoadingBarForElement(element){
	var inputArea = document.getElementById(element.id);
	var docroot=getContext()+getDocRoot();
	inputArea.innerHTML='<img src="'+docroot+'/zain/themes/default_en/images/loadingss.gif" alt="loading" width="63" height="15" />';
}
///////////////////////////////////////////////////////
function showFieldError(divId,error){
	var	area =document.getElementById(divId);
	if(area!=undefined&&area!=null)
	{
		showDiv(divId);
		area.innerHTML = error;
	}
	else{
		alert(divId+' not defined in form');
	}
}
//////////////////////////////////////////////////////
function showErrorMessageWithFieldClass(element,message){
	try
	{
		if(element!=null&&element!=undefined){
			if(element.id!=undefined&&element.id!=null&element.id.trim()!=''){
				var errorCellId='errorCell_'+element.id;
				var errorDivId='error_'+element.id;
				var successDivId='success_'+element.id;
				if(document.getElementById(errorCellId)!=undefined&&document.getElementById(errorDivId)!=undefined){
					changeClass(errorCellId,'error_new');
					hideDiv(successDivId);
		    		addErrorClassToField(element);
		  			showFieldError(errorDivId,message);
				}
				else
				{
					alert('Error in showErrorMessageWithClass '+ errorCellId +' or '+errorDivId+' undefined');
				}
				
			}
			else
			{
				alert('Error in showErrorMessageWithClass element Id not specifed');
			}
		}
		else
		{
			alert('Error in showErrorMessageWithClass element not defined');
		}
	}
	catch(e){
		alert('Error in showErrorMessageWithClass: '+e.message);
	}
}
//////////////////////////////////////////////////////
function showErrorDivAndCell(errorDivId){
		showDiv("error_"+errorDivId);
    	changeClass("errorCell_"+errorDivId,"error_new");
}
//////////////////////////////////////////////////////
function hideErrorDivAndCell(errorDivId){
		hideDiv("error_"+errorDivId);
    	changeClass("errorCell_"+errorDivId,"");
}
//////////////////////////////////////////////////////
function showSuccessMessageWithFieldClass(element){
	try
	{
		if(element!=null&&element!=undefined){
			if(element.id!=undefined&&element.id!=null&element.id.trim()!=''){
				var errorCellId='errorCell_'+element.id;
				var errorDivId='error_'+element.id;
				var successDivId='success_'+element.id;
				if(document.getElementById(errorCellId)!=undefined&&document.getElementById(errorDivId)!=undefined){
					changeClass(errorCellId,'');
					hideDiv(errorDivId);
					showDiv(successDivId);
					addSuccessClassToField(element);
				}
				else
				{
					alert('Error in showSuccessMessageWithFieldClass '+ errorCellId +' or '+errorDivId+' undefined');
				}
				
			}
			else
			{
				alert('Error in showSuccessMessageWithFieldClass element Id not specifed');
			}
		}
		else
		{
			alert('Error in showSuccessMessageWithFieldClass element not defined');
		}
	}
	catch(e){
		alert('Error in showErrorMessageWithClass: '+e.message);
	}
}
//////////////////////////////////////////////////////
function addErrorClassToField(element){
	try
	{
		validFieldClass='LV_valid_field';
		inValidFieldClass='LV_invalid_field';
		removeFieldClass(element,validFieldClass);
		removeFieldClass(element,inValidFieldClass);
		addFieldClas(element,inValidFieldClass);
	}
	catch(e){
		alert(e.message);
	}
}
function addSuccessClassToField(element){
	try
	{
		validFieldClass='LV_valid_field';
		inValidFieldClass='LV_invalid_field';
		removeFieldClass(element,validFieldClass);
		removeFieldClass(element,inValidFieldClass);
		addFieldClas(element,validFieldClass);
	}
	catch(e){
		alert(e.message);
	}	
}
////////////////////////////////////////////////////
function addFieldClas(element,className){
   try
   {
	    if(element!=null&&element!=undefined){
	        	 if(element.className.indexOf(className) == -1) element.className += ' ' + className;
	    }
   }
   catch(e){
   	alert(e.message);
   }
}
//////////////////////////////////////////////////////
function  removeFieldClass(element,classToRemove){
      try
      {
	      if(element!=null&&element!=undefined){
		 	 if(element.className.indexOf(classToRemove) != -1) element.className = element.className.split(classToRemove).join('');
		  }
	  }
	  catch(e){
	  	alert(e.message);
	  }
}   
/////////////////////////////////////////////////////
function setError(divId,error){
	var element = document.getElementById(divId);
	if(element!=undefined&&element!=null){
		element.innerHTML=error;
	}
}
////////////////////////////////////////////////////
function updateArea(divId,htmlData){
	var	area =document.getElementById(divId);
	if(area!=undefined&&area!=null)
	{
		showDiv(divId);
		area.innerHTML = htmlData;
	}
}
////////////////////////////////////////////////////
function changeClass(elementId,cssClass){
	var element = document.getElementById(elementId);
	if(element!=null&&element!=undefined){
		element.className=cssClass;
	}
}
////////////////////////////////////////////////////
function activateTab(tabContainerId,tabLinkId)
{
 var tabs = document.getElementsByTagName("a");
 for(i=0; i<= tabs.length; i++ )
 {

   if(tabs[i]!=undefined&&tabs[i].id!=undefined&&isChildOf(tabs[i].id, tabContainerId)){
   		if(tabs[i].id==tabLinkId){
   			tabs[i].className='active';
   		}
   		else
   		{
   			tabs[i].className='';
   		}
   }
 }
}
////////////////////////////////////////////////////
function activateWizard(tabContainerId,tabLinkId)
{
 var tabs = document.getElementsByTagName("td");
 for(i=0; i<= tabs.length; i++ )
 {

   if(tabs[i]!=undefined&&tabs[i].id!=undefined&&isChildOf(tabs[i].id, tabContainerId)){
   		if(tabs[i].id==tabLinkId){
   			tabs[i].className='step_table_td_active';
   		}
   		else
   		{
   			tabs[i].className='step_table_td';
   		}
   }
 }
}
////////////////////////////////////////////////////
function disablePage(){
	var bodyDiv = document.getElementById("bodyArea");
	if(bodyDiv!=undefined&&bodyDiv!=null){
		bodyDiv.className="loading_div";
		scroll(0,0);
	}
}
////////////////////////////////////////////////////
function enablePage(){
	var bodyDiv = document.getElementById("bodyArea");
	if(bodyDiv!=undefined&&bodyDiv!=null){
		bodyDiv.className="";
	}
}
////////////////////////////////////////////////////
function showNewInformationArea(){

	showDiv('InformationArea');
	hideDiv('ErrorArea');
	hideDiv('StatusArea');
}

////////////////////////////////////////////////////
function showNewErrorArea(text){

    document.getElementById("errorTextArea").innerHTML=text;
	showDiv('ErrorArea');
	hideDiv('InformationArea');
	hideDiv('StatusArea');
	}
////////////////////////////////////////////////////
function removeSuccessDivAndCSS(elementId){
	try
	{
		var element=document.getElementById(elementId);
		if(element!=null&&element!=undefined){
			removeFieldClass(element,'LV_valid_field');
			hideDiv('success_'+element.id);
		}
	}
	catch(e){
		alert('Error in removeSuccessDivAndCSS: '+e.message);
	}
}
////////////////////////////////////////////////////
function showNewStatusArea(text){

     
    document.getElementById("statusTextArea").innerHTML=text;    
	showDiv('StatusArea');    
	hideDiv('InformationArea');
	hideDiv('ErrorArea');
	}