
var ns4 = (document.layers) ? true : false;  // browser sniffer
var ie4 = (document.all) ? true : false;
var ns6 = (document.getElementById&&!document.all) ? true : false;
var op7 = (window.opera) ? true : false;

function popw(loc,nam,wid,hei,othe) {
if (window.screen)
{
x = (screen.availWidth - wid) * 0.5;
y = (screen.availHeight- hei) * 0.5;
}
else
{
x = 50;
y = 50;
}
if (othe=='') {popupw=window.open(loc,nam,'width='+wid+',height='+hei)
 } else {popupw=window.open(loc,nam,'width='+wid+',height='+hei+','+othe)
}
//popupw.moveTo(x,y);
l=popupw.focus();
return popupw 
}

function popo(loc,nam,wid,hei,othe) {
if (window.screen)
{
x = (screen.availWidth - wid) * 0.5;
y = (screen.availHeight- hei) * 0.5;
}
else
{
x = 50;
y = 50;
}
if (othe=='') {popupw=window.open(loc,nam,'width='+wid+',height='+hei)
 } else {popupw=window.open(loc,nam,'width='+wid+',height='+hei+','+othe)
}}

function popw2(loc,nam,wid,hei,othe) {
if (window.screen)
{
x = (screen.availWidth - wid) * 0.5;
y = (screen.availHeight- hei) * 0.5;
}
else
{
x = 50;
y = 50;
}
if (!ie4||op7){
if (othe=='') {popupw=window.open(loc,nam,'width='+wid+',height='+hei)
 } else {popupw=window.open(loc,nam,'width='+wid+',height='+hei+','+othe)
}
popupw.moveTo(x,y);
l=popupw.focus();
return popupw
}
if (ie4){
window.showModalDialog(loc, '', 'dialogWidth:' + wid+ 'px;dialogHeight:'  + hei + 'px;edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:yes')
}


}


function popPropsEditor(CatID){
if (!(CatID>0)) CatID=-1
popw('Popup.aspx?Element=T_Manager2&TMAction=EditProperties&CatID=' + CatID ,'PropsEditor',420,500,'scrollbars=yes')
}

function popCurrencyConvertor(Curr,Suma,BankID,Lang){
var Curr2='LTL'
if (!BankID) BankID=1
if (Curr=='LTL') Curr2='EUR'
popw2('Popup.aspx?Element=Currency&CurrAction=Converter&Cur2=' + Curr2 + '&Cur1=' + Curr + '&Q=' + Suma  + '&BankID=' + BankID + '&Lang=' + Lang  ,'CurrencyConvertor',685,370,'scrollbars=yes')
}

function popCurrencyConvertor2(Curr1,Curr2,Suma,BankID,Lang){
if (!BankID) BankID=1
popw2('Popup.aspx?Element=Currency&CurrAction=Converter&Cur2=' + Curr2 + '&Cur1=' + Curr1 + '&Q=' + Suma  + '&BankID=' + BankID + '&Lang=' + Lang ,'CurrencyConvertor',685,370,'scrollbars=yes')
}



function popImage(RID,OID,URL){

if (RID!='') popw2('picture_big.asp?RID=' + RID ,'Image1',340,420,'')
if (OID!='') popw2('picture_big.asp?OID=' + OID ,'Image2',330,340,'')
if (URL!='') popw2('picture_big.asp?URL=' + URL ,'Image3',340,340,'')

}

function popEditTopic(ID,PID){
var PA='Save'
if (!(ID>0)) PA='Insert'
popw('Edit.aspx?Element=I_Manager2&TopicID=' + ID + '&ParentID=' + PID + '&PostAction=' + PA ,'EDIT',400,300,'scrollbars=yes')
}

function popEditPenkiTopic(ID,PID,EID){
var PA='Save'
if (!(ID>0)) PA='Insert'
popw('PenkiEdit.aspx?Element=Penki_ManagerMenu&TopicID=' + ID + '&EditionID=' + EID +  '&ParentID=' + PID + '&PostAction=' + PA ,'EDIT',400,300,'scrollbars=yes')
}

function popEditPenkiShopTopic(ID,PID,MID)
{
var PA='Save'
if (!(ID>0)) PA='Insert'
popw('PenkiEdit.aspx?Element=Penki_MarketMenu&CatID=' + ID + '&MarketID=' + MID +  '&ParentID=' + PID + '&PostAction=' + PA ,'EDIT',400,300,'scrollbars=yes')
}

function popMiniInfo(Show)
{
    popw('PopupArticle.aspx?Element=PopupArticle&Show=' + Show ,'ADS',750,550,'scrollbars=yes')
}


function popAnnouncedArticles(ArticleID,TopicID){
var N='Window'+ArticleID
popw('Popup.aspx?Element=I_Manager2&IMAction=ViewArticle&ArticleID=' + ArticleID ,N,400,300,'scrollbars=no')
}

function ResizeHalfWindow()
{
    var frameWidth = 0
    var frameHeight = 0

	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	else return;

	if (self.screen.width < frameWidth *2 || self.screen.height < frameHeight *2)
	{
		newWidth = self.screen.width/2;
		newHeight = self.screen.height/2;
        //newWidth=frameWidth
        //newHeight=frameHeight

		if (document.layers)
		{
			tmp1 = parent.outerWidth - parent.innerWidth;
			tmp2 = parent.outerHeight - parent.innerHeight;
			newWidth -= tmp1;
			newHeight -= tmp2;
		}
		parent.window.resizeTo(newWidth,newHeight);
		parent.window.moveTo((self.screen.width - newWidth)/2,(self.screen.height-newHeight)/2);
	}
	else
	{
		//alert('No resize necessary');
	}
}

function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return document[divID];
}

function ResizeWindow(el,x){
    var oW=400
    var oH=300
    var oH = getRefToDivMod( el ); if( !oH ) { return false; }
	var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
	x.resizeTo( oW + 200, oH + 200 );
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
	if( window.opera && !document.childNodes ) { myW += 16; myH +=32; }
	x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2));
	if( x.focus ) { x.focus(); }
	return false;
}
