function highlightText(id){
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function getCourse(course) {
	var href=window.location.href;
	course = href.match(course);
	return course;
}

function getService(service) {
	var href=window.location.href;
	service = href.match(service);
	return service;
}

function getWindowHeight() {
  var windowHeight = 0;
  
	//if (self.innerHeight){
		//windowHeight = self.innerHeight;
	if (typeof(window.innerHeight) == 'number'){
    	windowHeight = window.innerHeight;
	} else {		
		if (document.documentElement && document.documentElement.clientHeight){
      		windowHeight = document.documentElement.clientHeight;		
		} else {
      		if (document.body && document.body.clientHeight){
        		windowHeight = document.body.clientHeight;
			}
		}; 
	};
				
  return windowHeight;
}

function isMobileDevice(){
	if(self.screen.width >= 800 || self.screen.height >= 600){
		return false;	
	} else {
		return true;	
	}
}

function setHeights() {
	if(!isMobileDevice()){
		var wh = getWindowHeight();
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		var content = document.getElementById('content');
		var course_details;	
		var date = document.getElementById('date');
		var extra_links = document.getElementById('extra_links');
		var breadcrumbs = document.getElementById('breadcrumbs');	
		var test, date_h, extra_links_h, breadcrumbs_h, header_h, content_h, course_details_h;
		var header_padding = 11;
		var content_padding;
		var course_details_padding = 52;
		
		test = Math.max(test1, test2);
		
		date_h = Math.max(date.scrollHeight, date.offsetHeight);
		extra_links_h = Math.max(extra_links.scrollHeight, extra_links.offsetHeight);
		breadcrumbs_h = Math.max(breadcrumbs.scrollHeight, breadcrumbs.offsetHeight);
		header_h = (date_h+extra_links_h+breadcrumbs_h+header_padding);
		
		if(is_ie){
			content_padding = 52;
		} else {
			content_padding = (52 + 1 + 25);	
		}
	
		content.style.height = (Math.max(wh, test)-header_h-content_padding) + 'px';
		
		if(document.getElementById('course_details')){
			course_details = document.getElementById('course_details');
			course_details_h = Math.max(course_details.scrollHeight, course_details.offsetHeight);
			course_details.style.height = (Math.max(wh, test)-header_h-content_padding-course_details_padding) + 'px';
		}
	
		//alert(Math.max(wh, test) + ' - ' + header_h + ' - 52 - 1 - 25 = ' + (Math.max(wh, test)-header_h-52-1-25));
	}
}

function setContactInformationMarginTop() {
	if(!isMobileDevice()){
		var wh = getWindowHeight();
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		var side_navigation = document.getElementById('side_navigation');
		var contact_information = document.getElementById('contact_information');
		var test, side_navigation_h;
		
		test = Math.max(test1, test2);
		side_navigation_h = Math.max(side_navigation.scrollHeight, side_navigation.offsetHeight);
		if (Math.max(wh, test) > side_navigation_h){
			contact_information.style.marginTop = (Math.max(wh, test)-side_navigation_h) + 'px';
		}
		//alert(Math.max(wh, test) + ' - ' + side_navigation_h + ' = ' + (Math.max(wh, test)-side_navigation_h));
	}
}

function setImageMarginTop() {
	if(!isMobileDevice()){
		var wh = getWindowHeight();
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;	
		var content = document.getElementById('content');
		var test, content_h;
	
		test = Math.max(test1, test2);
		content_h = Math.max(content.scrollHeight, content.offsetHeight);
		content.style.marginTop = ((Math.max(wh, test)-content_h)/2) + 'px';
		//alert("( " + Math.max(wh, test) + ' - ' + content_h + ' = ' + (Math.max(wh, test)-content_h) + ' ) / 2 = ' + ((Math.max(wh, test)-content_h)/2));
	}
}

function setImageWidth() {
	if(!isMobileDevice()){
		var content = document.getElementById('content');
		
		content.style.width = 700 + 'px';		
	}
}