function isShortcut(event){
	if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD))) {
		alert('Ctrl-Enter');
	} 
}
function getSelText(){
    var txt = '';
     if (window.getSelection){
        txt = window.getSelection();
      }else if (document.getSelection){
        txt = document.getSelection();
      }else if (document.selection){
        txt = document.selection.createRange().text;
       } else return;
	   
	return  txt;
}
function showNavigationTip(){
	var nt = document.getElementById('naviTip');
	nt.className = 'onn';
}
function hideNavigationTip(){
	var nt = document.getElementById('naviTip');
	nt.className = 'off';
}
function showRestOfPages(){
	var d = document.getElementById("restofpages");
	d.className = "onn";
}
function submitSearch(){
	document.forms.searchForm.action = '/Search/'+encodeURIComponent(document.forms.searchForm.searchText.value);
	document.forms.searchForm.submit();
}
function setHome(){
if (document.all){
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage('http://zakarpattya.net.ua/');
}
else if (window.sidebar){
	if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch(e){
			alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
		}
	}
	var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
	prefs.setCharPref('browser.startup.homepage','http://zakarpattya.net.ua/');
}
}
function bookmarksite(){
	url=location.href;
	title=document.title;
	if (navigator.appName === "Microsoft Internet Explorer")
		window.external.AddFavorite(url, title);
	else if(window.opera && window.print) { // Opera Browser
		var elem = document.createElement("a");
		elem.setAttribute("href",url);
		elem.setAttribute("title",title);
		elem.setAttribute("rel","sidebar");
		elem.click();
	}
	else { // Other Browsers
	window.sidebar.addPanel(title, url, "");
	}
} 

/* NEWS Line Scrolling */

var newsScroller = new vScroller();
var scrolledNewsTop = 0;
var scrolledNewsDiv = null;
var scrolledNewsCount = 6;
var newsScrollActive = false;
var newsScrollTimer = null;
var scrolledNewsHeight = 20;
var scrolledNewsShift = 0;

function startNewsScrolling(){
	newsScrollActive = true;
	scrolledNewsDiv = document.getElementById('slidingContent');
	newsScrollTimer = setInterval(newsScrolling,3000);
}
function newsScrolling(){
	if (newsScrollActive){

		if (scrolledNewsShift == scrolledNewsCount){
			scrolledNewsTop = 0;
			scrolledNewsShift = 0;
		}
		scrolledNewsTop = newsScroller.scrollUp(scrolledNewsDiv, scrolledNewsTop , scrolledNewsHeight, 30);
		scrolledNewsShift++;

	}

}
// future development
function pauseNews(){newsScrollActive = false;}
function unpauseNews(){newsScrollActive = true;}
function unfoldNews(){
	document.getElementById('news_slider').style.height = "100px";
}
function foldNews(){
	document.getElementById('news_slider').style.height = "20px";
}

/*

OGOLOSHENNYA Scrolling -----------------------------------------------------

*/

var ogoScroller = new hScroller();
var scrolledOgoLeft = 0; // initial offset
var scrolledOgoDiv = null; // remember div, do not call getElementById everytime
var scrolledOgoCount = 4; // Number of Ogoloshennya entry
var ogoScrollActive = false;
var ogoScrollTimer = null;
var scrolledOgoWidth = 215; // Width of ogol div
var scrolledOgoShift = 0; // Number of currently displayed element

function startOgoScrolling(){
	ogoScrollActive = true;
	scrolledOgoDiv = document.getElementById('ogoContent');
	ogoScrollTimer = setInterval(ogoScrolling, 5000);	
}

function ogoScrolling(){
	if (ogoScrollActive){

		if (scrolledOgoShift == scrolledOgoCount){
			scrolledOgoLeft = 0;
			scrolledOgoShift = 0;
		}
		scrolledOgoLeft = ogoScroller.scrollLeft(scrolledOgoDiv, scrolledOgoLeft , scrolledOgoWidth, 10);
		scrolledOgoShift++;
	}

}

/* SCROLLER object */
function vScroller(){

	this.iter = 0; // used for offset calculation
	this.timer = null;

	this.stepUp = function(_myThis){
			if (_myThis.iter >= _myThis.distance){clearInterval(_myThis.timer);}
			else {_myThis.movingElement.style.top = _myThis.start - ++_myThis.iter + "px";}
	};

	this.scrollUp = function(_movingElement, _start, _distance, _speed){
		this.movingElement = _movingElement;
		this.start = _start;
		this.distance = _distance;
		this.iter = 0;
		var myVThis = this;

		this.timer = setInterval( function(){myVThis.stepUp(myVThis);}, _speed);

		return _start - _distance;
	}
}

function hScroller(){

	this.iter = 0; // used for offset calculation
	this.timer = null;
	this.step = 5;

	this.stepLeft = function(_myThis){
			if (_myThis.iter >= _myThis.distance){clearInterval(_myThis.timer);}
			else {
			    _myThis.iter += 5;
			    _myThis.movingElement.style.left = _myThis.start - _myThis.iter + "px";
			}
	};

	this.scrollLeft = function(_movingElement, _start, _distance, _speed){
		this.movingElement = _movingElement;
		this.start = _start;
		this.distance = _distance;
		this.iter = 0;
		var myHThis = this;

		this.timer = setInterval( function(){myHThis.stepLeft(myHThis);}, _speed);

		return _start - _distance;
	}

}

