function newWind(url){

	window.open(url,"","width=510,height=550,status=1");
	return false;
}

function maxImage(img,LangId){
	if(LangId=="34")	LangId="lt";
	if(LangId=="5")		LangId="en";

	var Close=new Array()
		Close["lt"]="Uždaryti";
		Close["en"]="Close";

	var title = document.title;
	var dir = "http://www.kupiskis.lt/EasyAdmin/sys/photos/originals/";

	var html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	html+="<html>\n";
	html+="<head>\n";
	html+="<title>" + title + "</title>\n";
	html+="<meta http-equiv='imagetoolbar' content='no'>\n";
//	html+="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n";
	html+="</head>\n";
	html+="<body bgcolor='#eff6fe' topmargin=15 leftmargin=15 marginheight=15 marginwidth=15>";
	html+="<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'>";
	html+="<a onClick='window.close()'>Close[LangId]<img src='"+dir+img+"' border='0' alt='"+Close[LangId]+"'></a>";
	html+="</td></tr></table>";
	html+="</body>\n";
	html+="</html>\n";

	var Window2=open("","",",scrollbars=yes, resizable=yes, location=no, menubar=no, status=no,");
	Window2.document.open();
	Window2.document.write(html);
	Window2.document.close();
}


function DoAlert(msg){
	var title = document.title;

	var html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	html+="<html>\n";
	html+="<head>\n";
	html+="<title>" + title + "</title>\n";
	html+="<meta http-equiv='imagetoolbar' content='no'>\n";
//	html+="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n";
	html+="</head>\n";
	html+="<body bgcolor='#eff6fe' topmargin=15 leftmargin=15 marginheight=15 marginwidth=15>";
	html+="<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'>";
	html+="<a onClick='window.close()'>" + msg + "</a>";
	html+="</td></tr></table>";
	html+="</body>\n";
	html+="</html>\n";

	var Window2=open("","","height=300,width=300,left=300,top=300,scrollbars=yes, resizable=yes, location=no, menubar=no, status=no,");
	Window2.document.open();
	Window2.document.write(html);
	Window2.document.close();
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
		}
	}
} 

function ChangeAction(ItemId, lang) {
	var form = document.getElementById("faqBook");
	if(ItemId != 0) form.action = mainWebPath + "index.php/" + lang + "/" + ItemId + "/";
	else form.action = mainWebPath + "index.php/" + lang + "/";

	form.submit();
}

function ChangeMonths(year, classId, branchId) {
	
	XMLDom = LoadDOM(mainWebPath + "EasyAdmin/sys/configs/months_xml.php?year=" + year + "&classId=" + classId + "&branchId=" + branchId);
	var results = XMLDom.selectNodes("/months/month");
	
	var months = document.getElementById("Month");
	var listLength = months.length;
	
	for (var i=0; i<listLength; i++) {
		if (months.options[1])
			months.remove(1);
	}
	
	for (var item = results.nextNode(); item; item = results.nextNode()) {
		var code = item.selectSingleNode("mcode").text;
		var value = item.selectSingleNode("mname").text;
		months.add(new Option(value, code,true));
	}
}

// Loads file
// string file name
function LoadDOM(file) {
	var dom;
	try {
		dom = MakeDOM(null);
		dom.load(file);
	}
	catch (e) {
		alert(e.description);
	}
	return dom;
}

// Gets MSXML Document Object Model
function MakeDOM(progID) {
	if (progID == null) {
		progID = "msxml2.DOMDocument.3.0";
	}
	var dom;
	try {
		dom = new ActiveXObject(progID);
		dom.async = false;
		dom.validateOnParse = false;
		dom.resolveExternals = false;
		dom.preserveWhiteSpace = true;
	}
	catch (e) {
		alert(e.description);
	}
	return dom;
}

function popitup(url)
{
	newwindow=window.open(url,'name','width=450 height=510');
	if (window.focus) {newwindow.focus()}
	return false;
}

/*BEGANTI EILUTE (validatoriui itikti)*/

/*var tWidth='470px';                  // width (in pixels)
var tHeight='23px';                  // height (in pixels)
var tcolour='#ffffff';               // background colour:
var moStop=true;                     // pause on mouseover (true or false)
var fontfamily = 'tahoma, arial,sans-serif'; // font for content
var tSpeed=3;                        // scroll speed (1 = slow, 5 = fast)

// enter your ticker content here (use \/ and \' in place of / and ' respectively)
var content='Bėganti eilutė <a href="http:\/\/kupiskis.lt\/">Bėganti eilutė<\/a>Bėganti eilutė';

// Simple Marquee / Ticker Script
// copyright 3rd January 2006, Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the below code in this script (including this
// comment) is used without any alteration
var cps=tSpeed; 
var aw, mq; 
//var fsz = parseInt(tHeight) - 4; 
var fsz = '10px';
function startticker(){
	if (document.getElementById('ticker')) {
		var tick = '<div style="position:relative;z-index:-1;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"';
		if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; tick +='><div id="mq" style="position:absolute;left:0px;top:5px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;"><\/div><\/div>'; document.getElementById('ticker').innerHTML = tick; mq = document.getElementById("mq"); mq.style.left=(parseInt(tWidth)+10)+"px"; mq.innerHTML='<span id="tx">'+content+'<\/span>'; aw = document.getElementById("tx").offsetWidth; lefttime=setInterval("scrollticker()",50);
	}
} 

function scrollticker() {
	mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";
} window.onload=startticker;

*/


function startticker(){
 if (!document.getElementById('ticker')) {
			return;
		}
 if(document.getElementById('ticker')) {
   var tick = '<div style="position:relative;z-index:-1;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"';
   if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; tick +='><div id="mq" style="position:absolute;left:0px;top:5px;font-family:'+fontfamily+';font-size:'+fsz+';white-space:nowrap;"></div></div>';
    document.getElementById('ticker').innerHTML = tick;
    mq = document.getElementById("mq");
    mq.style.left=(parseInt(tWidth)+10)+"px"; 
    mq.innerHTML='<span id="tx">'+content+'</span>'; 
    aw = document.getElementById("tx").offsetWidth;
    lefttime=setInterval("scrollticker()",50);
  }
} 
function scrollticker() {
  mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";
}

var oPopup = window.createPopup();
function HelpTable(TipText){
	
	alert(event.clientY + " ..." + event.screenY );
	ww = 170;
	hh = 80;
	oPopup.document.body.innerHTML='<table cellpadding="0" cellspacing="5" border="0" style="border:1px solid #000000" bgcolor="#ffffff" width="'+ww+'" height="'+hh+'"><tr><td style="font-family: Tahoma, Verdana, Arial; font-size:11px; color: #000000; text-decoration:none;" valign=top>'+TipText+'</td></tr></table>';

	if (event) {
		ev=event;
		bd=document.body;
	}


	coorX=ev.x;
	coorY=ev.y +event.clientY;
	
	oPopup.show(coorX,coorY,ww,hh,document.body);
	
}

function HelpTableOut(){
	oPopup.hide();
}

function ShowNames() {
	var names = document.getElementById('namesDiv');
	if(names) names.style.display = "block";
	else return;
}