function showmain(id) {
	hidecontent('main_title0');hidecontent('main_image0');hidecontent('main_summary0');
	hidecontent('main_title1');hidecontent('main_image1');hidecontent('main_summary1');
	hidecontent('main_title2');hidecontent('main_image2');hidecontent('main_summary2');
	hidecontent('main_title3');hidecontent('main_image3');hidecontent('main_summary3');
	hidecontent('main_title4');hidecontent('main_image4');hidecontent('main_summary4');
	hidecontent('main_title5');hidecontent('main_image5');hidecontent('main_summary5');
	hidecontent('main_title6');hidecontent('main_image6');hidecontent('main_summary6');
	hidecontent('main_title7');hidecontent('main_image7');hidecontent('main_summary7');
	hidecontent('main_title8');hidecontent('main_image8');hidecontent('main_summary8');
	hidecontent('main_title9');hidecontent('main_image9');hidecontent('main_summary9');
	hidecontent('main_title10');hidecontent('main_image10');hidecontent('main_summary10');
	hidecontent('main_title11');hidecontent('main_image11');hidecontent('main_summary11');

	document.getElementById('main_title'+id).style.display = 'block';
	document.getElementById('main_image'+id).style.display = 'block';
	document.getElementById('main_summary'+id).style.display = 'block';
}

function hidecontent(id) {
	document.getElementById(''+id).style.display = 'none';
}

function showsendform() {
	if(document.getElementById('comment_form').style.display == 'block') {
	document.getElementById('comment_form').style.display = 'none';
	} 
	if(document.getElementById('send_form').style.display == 'block') {
	document.getElementById('send_form').style.display = 'none';
	} 
	else {
	document.getElementById('send_form').style.display = 'block';
	}
}

function showcommentform() {
	if(document.getElementById('send_form').style.display == 'block') {
	document.getElementById('send_form').style.display = 'none';
	} 
	if(document.getElementById('comment_form').style.display == 'block') {
	document.getElementById('comment_form').style.display = 'none';
	} 
	else {
	document.getElementById('comment_form').style.display = 'block';
	}
}

function load(id) {
var id;
var load = window.open('print.php?type=column&c='+id,'','scrollbars=yes,menubar=no,height=600,width=600,resizable=yes,toolbar=no,location=no,status=no');
}

function load_news(id) {
var id;
var load = window.open('print.php?type=news&p='+id,'','scrollbars=yes,menubar=no,height=600,width=600,resizable=yes,toolbar=no,location=no,status=no');
}

function printnews()
{
	document.getElementById('hide_on').style.display = "none";
	window.print();
	document.getElementById('hide_on').style.display = "block";
	return false;
}

function trafik(url) {
var url;
var url = window.open(url,'','scrollbars=yes,menubar=no,height=300,width=375,resizable=yes,toolbar=no,location=no,status=no');
}

// GG Ticker
var theCharacterTimeout = 50;
var theStoryTimeout     = 5000;
var theWidgetOne        = "_";
var theWidgetTwo        = "+";
var theWidgetNone       = "";
var titles		 			= new Array();
var links 					= new Array();
var theItemCount 			= 5;

function startTicker()
{
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
		    theAnchorObject     = document.getElementById("tickerAnchor");
			runTheTicker();   	
		 }
	else {
            document.write("<style>#ticker{display:none;}.ticko{border:0px; padding:0px;}</style>");
            return true;
	}
}
// Ticker main run loop
function runTheTicker()
{
	var myTimeout;  
	// Go for the next story data block
	if(theCurrentLength == 0)
	{
		theCurrentStory++;
		theCurrentStory      = theCurrentStory % theItemCount;
		theStorySummary      = titles[theCurrentStory].replace(/&quot;/g,'"');		
		theTargetLink        = links[theCurrentStory];
		theAnchorObject.href = theTargetLink;
		thePrefix 	     = "<span class=\"tickls\">" + "</span>";
	}
	// Stuff the current ticker text into the anchor
	theAnchorObject.innerHTML = thePrefix + 
	theStorySummary.substring(0,theCurrentLength) + whatWidget();
	// Modify the length for the substring and define the timer
	if(theCurrentLength != theStorySummary.length)
	{
		theCurrentLength++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		theCurrentLength = 0;
		myTimeout = theStoryTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}
// Widget generator
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
		return theWidgetTwo;
	}
}
$(function() {
	$('#send_comment').simpleformsubmit('#comment_form');
	$('a#allcomments').click(function() {
		var post = $(this).attr('rel');
		$('#comments').overlay();
		if($(this).hasClass('column')) {
			var type = 2;
		} else {
			var type = 1;
		}
		$('#comments').load('tasks.php?task=comments_get_all&post='+post+'&type='+type);
		$('.overlay').remove();
		$(this).hide();
		return false;
	});
});

$.fn.simpleformsubmit = function(p) {
	return this.submit(function() {
		var form = $(this);
		var id = form.attr('id');
		$(p).overlay();
		var url	= form.attr('action');
		var inputs = [];
		$(':input', this).each(function() {	inputs.push(this.name + '=' + unescape(this.value));});
		$.ajax({
			type : "POST",		
			data : inputs.join('&'),
			url : url,
			success : function(msg) { 
				$('.overlay').remove();
				$('.messages').remove();
				$(p).prepend(msg);
				if($(msg).hasClass('done')) {
					$('#'+id).reset()
					form.remove();
				}				
				}
			});
		return false;
	});
}

$.fn.overlay = function(options) {
	return this.each(function(e) {
		$('.overlay').remove();
		var offset = $(this).offset();
		var $this = $(this),
		defaults =  {width: $this.outerWidth(),height: $this.outerHeight(),top: offset.top,left: offset.left},
		settings = $.extend({}, defaults, options);
		$('<div class="overlay" />').appendTo('body').css({'position' : 'absolute', 'top' : settings.top, 'left' : settings.left, 'width': settings.width, 'height' : settings.height});
	});
}
$.fn.reset = function () {$(this).each (function() { this.reset(); });}
