/***** INPUT FOCUS *****/

function inpFocus(obj, stdText) {
    if (obj.value == stdText) {
	obj.value = '';
    }
}

function inpBlur(obj, stdText) {
    if (obj.value == '') {
	obj.value = stdText;
    }
}

$(document).ready(function () {
    // change linkbehaviour webmail
    $('a').each(function(){
	if($(this).attr('href') == '/site/contact/webmail.html' || $(this).attr('href') == '/site/contact/digiassist_ticket.html'){
	    $(this).attr('target','_blank');
	}
    });
    
    setTimeout(function(){	
	makeScrollable("div.sc_menu_wrapper", "div.sc_menu");
    }, 500);
});

function makeScrollable(wrapper, scrollable){
    
	// Get jQuery elements
	var wrapper = $(wrapper), scrollable = $(scrollable);
    // height of area at the top at bottom, that don't respond to mousemove
    var inactiveMargin = 99;					
    // Cache for performance
    var wrapperWidth = wrapper.width();
    var wrapperHeight = wrapper.height();
    // Using outer height to include padding too
    var scrollableHeight = scrollable.outerHeight() + 2*inactiveMargin;
    // Do not cache wrapperOffset, because it can change when user resizes window
    // We could use onresize event, but it's just not worth doing that 
    // var wrapperOffset = wrapper.offset();	
    var lastTarget;
    //When user move mouse over menu			
    wrapper.mousemove(function(e){
	var wrapperOffset = wrapper.offset();
	
	// Scroll menu
	
	$('#debug').html(wrapper.height());
	
	var top = (e.pageY -  wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight - inactiveMargin;
	
	if (top < 0){
	    top = 0;
	    
	}			
	wrapper.scrollTop(top);
    });
    
    
}

function setScrollElment(reccnt, myheight) {
    var totalheight = reccnt * myheight;
	
    $('.sc_menu').height(totalheight);
}
