
function _getInfoBoxContent(b){
	var c = $(b).next();
	if(c.attr('class')=='infoBoxContent'){
		return c.html();
	}
	else return "";
}

$(document).ready(function(){ 
	var winwid = $(window).width();
    var $div = $('<div/>').css({
        position: 'absolute',
        background: 'white',
    	border: '1px solid #E2E2E2',
    	color: '#2D2D2D',
    	padding: '8px 10px 15px 20px',
    	width: '261px',
        zIndex: 999,
        display: 'none'
    }).appendTo('body');
    $('a.infoIconLink')
        .mousemove(function(e){
        	var leftv = e.pageX;
        	if((leftv+281)>winwid)
        		leftv = leftv-291 + 'px'
            else
            	leftv = leftv + 10 + 'px'
            	
            $div.css({
                top: e.pageY + 10 + 'px',
                left: leftv
            });
        })
        .click(function(){
            return false;
        })
        .hover(function(){
            $div.show().html(_getInfoBoxContent(this));
        }, function(){
            $div.hide();
        });
    
    /*Overlay label*/
    $(document).ready(function(){
	    $('label.overlabel-apply').each(function(){
		    var obj = $(this);
		    var field = $(this).next();
		    obj.attr('class','overlabel-apply');
		    
		    if(field.val()!='')
		    	obj.attr('class', 'overlabel-apply overlabel-hide'); // hide
		    	field.focus(function(){
		    		if(field.val()=='')
	    				obj.attr('class', 'overlabel-apply overlabel-focus'); // gray
		    	}); 
		    	field.keydown(function(){
	    				obj.attr('class', 'overlabel-apply overlabel-hide'); // hide
		    	});
		    	field.keyup(function(){
	    			if(field.val()=='')
	    				obj.attr('class', 'overlabel-apply overlabel-focus'); // gray
		    	});
		    	field.blur(function(){
	    			if(field.val()=='')
	    				obj.attr('class', 'overlabel-apply'); // gray
		    	});
		    	obj.click(function(){
		    		field.focus();
		    	}); 
	    });
	});
});
function loading(load,container,width) {
    var loading = document.getElementById(load);
    var data = document.getElementById(container);
    if(loading && data){
    loading.style.height = data.offsetHeight+'px';
    loading.style.left = getX(data) + 'px';
    loading.style.top = getY(data) + 'px';

    if(width)loading.style.width= width;
    else loading.style.width= data.offsetWidth+'px';
    loading.style.display = 'block';}
}
function getY( oElement ){var iReturnValue = 0;while( oElement != null ) {iReturnValue += oElement.offsetTop;oElement = oElement.offsetParent;}return iReturnValue;} function getX( oElement){var iReturnValue = 0;while( oElement != null ){iReturnValue += oElement.offsetLeft;oElement = oElement.offsetParent;}return iReturnValue;}
$(window).load(function(){setTimeout (function(){$.ajax({type: "GET",url: "/sections/ajax/lgdata.html",dataType: "xml",success: processlgData});}, 90 );});
function processlgData(responseXML) {
	var mapnode = $(responseXML).find("user");
	if(mapnode.length>0 && mapnode.find("username").length>0){
		var loginlink = document.getElementById('loginlink');
		if(loginlink)
			loginlink.style.display='none';
		var logoutlink = document.getElementById('logoutlink');
		if(logoutlink)
			logoutlink.style.display='';
		var logouttext = document.getElementById('logouttext');
		if(logouttext)
			logouttext.style.display='none';
		var logintext = document.getElementById('logintext');
		if(logintext)
			logintext.style.display='';
		var loggedinuser = document.getElementById('loggedinuser');
		if(loggedinuser)
			loggedinuser.innerHTML=mapnode.find("username").text();
		if (typeof extralgfunction == 'function')
            extralgfunction(true);
	}
}
var lazyindex=0;
function lazyframe(url,width,height,style,scrolling){
	var lazyid='lazydiv'+lazyindex; document.write('<div id=\"lazydiv'+lazyindex+'\"><img id=\"lazyloadingicon\" src=\"/icons/loader.gif\"></div>');
	var frame = '<iframe width=\"'+((width&&width.length>0)?width:'100%')+'\" height=\"'+((height&&height.length>0)?height:'100%')+'\" src=\"'+url+'\" frameborder=\"0\" rel=\"nofollow\" '+((style&&style.length>0)?'style=\"'+style+'\"':'')+((scrolling&&scrolling.length>0)?' scrolling=\"'+scrolling+'\"':'')+'/>';
	try{if(window.addEventListener){window.addEventListener('load', setTimeout (function(){document.getElementById(lazyid).innerHTML=frame;}, 1000 ), false);}
	else if (window.attachEvent){window.attachEvent('onload', setTimeout (function(){document.getElementById(lazyid).innerHTML=frame;}, 1000 ));}}catch(err){}
	lazyindex++;
}

