
//disable text selection
/*window.onload = function() 
{
	document.onselectstart = function() {return false;} // ie
	document.onmousedown = function() {return false;} // mozilla
}*/


/* FORM */

/*
*/
function getValue(id)
{
	var element = document.getElementById(id);
	
	if(element != null)
		return element.value;
	else
		return null;
}

/*
*/
function setValue(id, value)
{
	var element = document.getElementById(id);
	
	if(element != null)
		element.value = value;
}

/*
*/
function submitForm(id)
{
	var element = document.getElementById(id);
	
	if(element != null)
		element.submit();
}


/* NAV */

/*
*/
function goTo(url)
{
	document.location.href = url;
}


/* POPUP */

/*
*/
function popup(url, width, height, center, scrollbars, toolbar, location)
{
	//center
	if(center != false)
		center = true;
	
	//scrollbars
	if(scrollbars != false)
		scrollbars = "yes";
	else
		scrollbars = "no";
	
	//toolbar
	if(toolbar != true)
		toolbar = "no";
	else
		toolbar = "yes";
	
	//address bar
	if(location != true)
		location = "no";
	else
		location = "yes";
		
	var left_pos = ((screen.width - width)   / 2); //px
	var top_pos  = ((screen.height - height) / 2); //px
	
	return window.open(url, "popup", "height=" + height + ", left=" + left_pos + ", location=" + location + ", scrollbars=" + scrollbars + ", toolbar=" + toolbar + ", top=" + top_pos + ", width=" + width);
}


/* SLIDER */

var current_image = 1;
var nr_of_images  = 0;
var slide_delay   = 4000; //ms
var slide_time    = 1000; //ms
var timeout       = null;

/**
 *
 */
function initSlider()
{
	nr_of_images = $("#slider").children().length;
	
	$("#slider").css("width", nr_of_images * 700);
	
	current_image = 1;
	
	//slider buttons
	for(var b = 1; b <= nr_of_images; b++)
		$("#buttons").append("<a class=\"\" href=\"javascript:showSlide(" + b + ");\" id=\"button_" + b + "\">&nbsp;</a>");
	
	if(nr_of_images > 0)
		$("#viewport").css("display", "block");
	
	$("#button_" + current_image).attr("class", "on");
	
	nextSlide();
}

/**
 *
 */
function nextSlide()
{
	current_image++;
	
	if(current_image > nr_of_images)
		resetSlider();
	else
	{
		/*$("#buttons > a").delay(slide_delay).attr("class", "");
		
		$("#button_" + current_image).delay(slide_delay).attr("class", "on");
	
		$("#slider").delay(slide_delay).animate({ left: '-=620px' }, slide_time, function(){ nextSlide(); });*/
		
		timeout = setTimeout("showSlide(" + current_image + ")", slide_delay);
	}
}

/**
 *
 */
function resetSlider()
{
	current_image = 1;
	
	/*$("#slider").delay(slide_delay).animate({ left: '+=' + (620 * (nr_of_images - 1)) + 'px' }, slide_time, function(){ nextSlide(); });
	
	$("#buttons > a").delay(slide_delay).attr("class", "");
	
	$("#button_" + nr_of_images).delay(slide_delay).attr("class", "on");*/
	
	timeout = setTimeout("showSlide(" + current_image + ")", slide_delay);
}

/**
 *
 */
function showSlide(nr)
{
	clearTimeout(timeout);
	
	$("#slider").stop(true, true);
	$("#buttons > a").stop(true, true);
	$("#button_" + current_image).stop(true, true);
	$("#button_" + nr_of_images).stop(true, true);
	
	current_image = nr;
	
	$("#buttons > a").delay(slide_time).attr("class", "");
	
	$("#button_" + nr).delay(slide_time).attr("class", "on");
	
	$("#slider").animate({ left: '-' + ((nr - 1) * 700) + 'px' }, slide_time, function(){ nextSlide(); });
}