// JavaScript Document
/*
Made by Viljar Salu 2010 May 
viljar.salu@elion.ee
*/
function printPage($lang)
{
	this.lang = ($lang ? $lang : 'et');
	this.page;
	this.title;
	this.printImg = (this.lang == 'et' ? 'http://tv.elion.ee/_gfx/printOutButton.png' : 'http://tv.elion.ee/_gfx/printOutButton_ru.png');// ru
}
// set method
printPage.prototype.setPage = function()
{
	// set new window
	var newWin = window.open(
				'',
				'Elion',
				/*"_blank"*/
				'width=730,height=600'
				+',menubar=0'
				+',toolbar=1'
				+',status=0'
				+',scrollbars=1'
				+',resizable=1');
	var bodyContent = '<html><head><title>Elion - Dtv</title>';
		bodyContent += '<link rel="stylesheet" type="text/css" href="http://tv.elion.ee/_gfx/_styles.css" media="all" />';
		/*bodyContent += '<link rel="stylesheet" type="text/css" href="http://tv.elion.ee/_gfx/_styles_screen.css" media="screen, projection" title="digiTV" />';*/
		bodyContent += '<link rel="stylesheet" href="http://tv.elion.ee/_sifr/sIFR-screen.css" type="text/css" media="screen" />';
		bodyContent += '<link rel="stylesheet" href="http://tv.elion.ee/_sifr/sIFR-print.css" type="text/css" media="print" />';
		bodyContent += '<link rel="stylesheet" type="text/css" href="http://tv.elion.ee/_gfx/_styles_printPreview.css" media="all" title="digiTV" />';
		bodyContent += '<link rel="stylesheet" type="text/css" href="http://tv.elion.ee/_gfx/_styles_print.css" media="print" title="digiTV" />';
		bodyContent += '</head>';
		bodyContent += '<body bgcolor=white onLoad="self.focus();">';
		bodyContent += '<div id="buttonPrint"><div><a href="javascript:window.print();" style="color:#FFF;"><img src="'+this.printImg+'" border="0"/></a></div><br style="clear:both;"/></div>';
		bodyContent += '<div id="page"><img src="http://tv.elion.ee/_gfx/logo.png" id="logo" />';
		bodyContent += ( this.title ? '<h1 style="margin:50px 0 0 0;">'+this.title+'</h1><br style=clear:both;"/>' : '');
		bodyContent += this.page;
		bodyContent += '</div></body></html>';
	newWin.document.writeln(bodyContent);
	newWin.document.close();
}
// trigger printing
printPage.prototype.printOut = function($contentId,$title)
{
	this.page = document.getElementById($contentId).innerHTML;
	this.title = $title;
	this.setPage();
}

/* event */
// sample; addEvent(window, "load", yourFunctionHere)
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} 
	else if (obj.attachEvent)
	{ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} 
	else 
	{ 
		return false; 
	} 
}

/* input trimmer */
function fixComma($input)
{
	var _r = $input.replace(/\,/gi, ".");
	return _r;
}
function removeWhitespace($input) {
	var _r = $input.split(" ").join("");
	return _r;
}

/* load content */
function loadContent($containerId, $url, $sectionId)
{
	var _url = $url + ' ' + ( $sectionId ? $sectionId : '' );
	$($containerId).load(_url);
}
/* temp */
function loadContent2($containerId, $url, $sectionId)
{
	var _url = $url + ' ' + ( $sectionId ? $sectionId : '' );
	$($containerId).load(_url, function(response,status,xhr){ $($containerId + ' .box01').hide(); } );
}
