	function clearInnerHTML(obj) {
		/*
		 *  Empties a DIV of all children
		 */
		try{
            if(obj==null || obj==undefined)return;
            while(obj.firstChild!=null && obj.firstChild!=undefined) {
			obj.removeChild(obj.firstChild);
			}
			obj.innerHTML="";
			//  obj.style.display='none';
	        }catch(e){  }
	}
	

function getURLParam(url){
//this is used to extract param from the url
//they are only separated by commas
    var urlquery=((url==null||url==undefined)?location.href.split("?"):url.split("?"));
    if(urlquery.length<2)return null;
    var rnurlterms= urlquery[1].split("&") ;
    return rnurlterms;
}
function getParamFromURL(url,param){
 
    var paramArray=[];
    paramArray=getURLParam(url);
    for(var i=0;i<paramArray.length;i++){
    if(paramArray[i].indexOf(param)!=-1){
        var ret=paramArray[i].substr(paramArray[i].indexOf('=')+1);
		//remove # from url content
		ret=ret.replace('#','');
		return ret;
    }
    }
    return null;
}

//------------------------- locale utility ---------------------------------------------------
		
		
function getLocale(id){
try {
	initLocale();//init if necessary
	var ret = null;
	    
		try{
		 	
		if (bundle == null || bundle== undefined) {
			bundle = dojo.i18n.getLocalization("my.app", "resBundle");
		}
 		var ret=eval("bundle."+id) ;
		if(ret==undefined)console.debug("locale : "+id+" not found " );
		return ret;
         } catch (e) { }
        }catch(e){
               console.debug("Unable to retrive locale data - msg:"+e.message);
               return null;
     }
}
	
    function getLocaleStr(id,defaultValue){
		var ret=getLocale(id);
		if(ret==null || ret==undefined || ret==""){
		return defaultValue;
		}
		return ret;
    }
    
     function initLocale(){
	 	//localInitialised is set to false when there is a need for a locale refresh
	 	try{ 
		 if(!(getCookie("localInitialised")=="true")){

		 	setCookie("localInitialised","true",null,null,null,null);
			
			var currentLocale=getCookie('currentLocale');
     		currentLocale=currentLocale==null?"en":currentLocale;
      		djConfig.locale=currentLocale;
			bundle = dojo.i18n.getLocalization("my.app", "resBundle");
			//refresh page after local storage update
			//setTimeout(refreshPage,10000);
		}
		}catch(e){}
	 }
	 function refreshPage(){
	 	/* if((getCookie("isNotFirstLocalInitialisation")=="true")){
	 	//location.reload(true);
		location.href=location.href+"?&refresh=true";
		}
		setCookie("isNotFirstLocalInitialisation","true",null,null,null,null);
		*/
	 }
	 
//--------------------------------------------------------------------------------------------	     

                

 function setCookie(name, value, expires, path, domain, secure) {
		  var curCookie = name + "=" + escape(value) +
		      ((expires) ? "; expires=" + expires.toGMTString() : "") +
		      ((path) ? "; path=" + path : "") +
		      ((domain) ? "; domain=" + domain : "") +
		      ((secure) ? "; secure" : "");
		  document.cookie = curCookie;
		}
		   
  function getCookie(name) {
		  var dc = document.cookie;
		  var prefix = name + "=";
		  var begin = dc.indexOf("; " + prefix);
		  if (begin == -1) {
		    begin = dc.indexOf(prefix);
		    if (begin != 0) return null;
		  } else
		    begin += 2;
		  var end = document.cookie.indexOf(";", begin);
		  if (end == -1)
		    end = dc.length;
		  return unescape(dc.substring(begin + prefix.length, end));
		}
		
                
 function getMousePos(e){
   var pos=[];
   var docX, docY;
   if( e )
   {
      if( typeof( e.pageX ) == 'number' )
      {
         docX = e.pageX;
         docY = e.pageY;
      }
      else
      {
         docX = e.clientX;
         docY = e.clientY;
      }
   }
   else
   {
      e = window.event;
      docX = e.clientX;
      docY = e.clientY;
      if( document.documentElement
        && ( document.documentElement.scrollTop
            || document.documentElement.scrollLeft ) )
      {
         docX += document.documentElement.scrollLeft;
         docY += document.documentElement.scrollTop;
      } 
      else if( document.body
         && ( document.body.scrollTop
             || document.body.scrollLeft ) )
      {
         docX += document.body.scrollLeft;
         docY += document.body.scrollTop;
      }
   }

  pos[0]=docX;
  pos[1]=docY;
  
  return pos;
   }              
                
/// --------------------------------------------------------------------------

function signin(){
	
        var compId=getCookie('CompId');
if(compId!=null && compId != undefined ) return;
        //store current page in session variable so as to able to return to the page
		
                try{
		 dojo.xhrGet(  { url:'service?action=notification&notificationType=initSession&NextPageUrl='+location.href, handleAs: 'xml', load: function(data, evt){
                 		//after success
                 		alert(getLocaleStr("signin_msg","Please sign in"));
		 				location.href="showSignin.jsp";
                  }} );
        }catch(e){}
		 

}
