function submitonce(theform){
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById)
	{
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			//disable em
			tempobj.disabled=true
		}
	}
}

function popup(url,w,h,sb)
{
	atr = '';
	atr = atr + 'toolbar=no,';
	if (sb)
	{
		atr = atr + 'scrollbars=no,';
	}
	else
	{
		atr = atr + 'scrollbars=yes,';
	}
	atr = atr + 'location=no,';
	atr = atr + 'statusbar=no,';
	atr = atr + 'menubar=no,';
	atr = atr + 'resizable=yes,';
	if (w) {
	atr = atr + 'width='+w+',';
	atr = atr + 'height='+h;
	}
	else{
	atr = atr + 'width=700,';
	atr = atr + 'height=500';
	}
	new_window=window.open(url,'_blank',atr);
	new_window.focus();
}

function popupimg (url)
{
	popup(url,1,1);
}

function goopener (url)
{
window.opener.focus();
window.opener.location=url;
window.close();
}
function closepopup ()
{
window.opener.focus();
window.close();
}
function goback (url) {
window.location=url;
}

function gosearch (module,url)
{
	if (document.searchform.searchword.value)
		{
			if (module == 'article')
			{
				window.location=url+'&filtr='+document.searchform.searchword.value;
			}
		}
}


function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// end images rollover efects functions

/**
 * Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to submit
 onclick="return confirmlink(this, 'DROP TABLE `tslc_oeuvre`')
 *
 * @return  boolean  whether to run the query or not
 */

function confirmlink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
alert ('test');
    var is_confirmed = confirm(theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function selectLink(formName, formField, confirmText, positions){
//Redirect browser to the link in the VALUE of the formFiled of the formName

//positions - comma separated option ids, like: 2,3,5, which will be confirmed
//in case if you have more options to delete...
	var val = document.forms[formName].elements[formField].value;
	var del = document.forms[formName].elements[formField].selectedIndex;
	
	var optionsToConfirm = positions.split(",");
	var conf=0;
	
	for(i=0; i<optionsToConfirm.length; i++)
	{
		if(del == parseInt(optionsToConfirm[i])) { conf=1; }
	}

	if(confirmText && conf )
	{
		if(confirm(confirmText)) {location.replace(val);} else { return false; }
	}
	else
	{
		location.replace(val);
	}
}

function confirmDelete(form, text)
{
    var is_confirmed = confirm(text);
	var formName=form;
    if (is_confirmed) {
        document.forms[formName].submit();
    }
} 


function convertToAlias(fieldInput,fieldResult){
	fieldInputObj = document.getElementById(fieldInput);
	fieldResultObj = document.getElementById(fieldResult);
	if(fieldResultObj.value==""){
		var ref=fieldInputObj.value;
		var i=0;
		while(ref.length > i){
			ref=ref.replace(' ','-');
			ref=ref.replace('&','-');
			i=i+1;
		}
		ref=ref.substring(0,50);
		//fieldResultObj.value=ref.toUpperCase();
		fieldResultObj.value = ref;
	}
}

var gClientIsGecko = (window.controllers) ? true : false;
var gClientIsOpera = (window.opera) ? true : false;
var gClientIsIE    = (document.all && !gClientIsOpera) ? true : false;
var gClientIsIE5   = (gClientIsIE && /MSIE 5\.0/.test(navigator.appVersion)) ? true : false;
var gClientIsMac   = (/Mac/.test(navigator.appVersion)) ? true : false;

function showDiv (el, div, alignX, alignY) {
	// (i) popups etc
	if (document.getElementById){
    	var i = document.getElementById(el);
		var c = document.getElementById(div);
        if (c.style.display != "block"){
			
			//var l=0; var t=0;
            //aTag = i;
            //do {
            //    aTag = aTag.offsetParent;
            //    l += aTag.offsetLeft;
            //    t += aTag.offsetTop;
			//} while (aTag.offsetParent && aTag.tagName != 'BODY');
	        //var left =  i.offsetLeft + l;
    	    //var top = i.offsetTop + t + i.offsetHeight + 2;
			var box = getDimensions(i);
			var left = box.x, top = box.y;
			//if (alignX == 'left' && c.style.width){
			//	left = left - parseInt(c.style.width);
			//}
			//if (alignY == 'top' && c.style.height){
			//	top = top - parseInt(c.style.height) -25;
			//}
			c.style.visibility = 'hidden'; // Needed to measure
			c.style.display = "block";     // Needed to measure
			if(alignX == 'left')
				left -= c.offsetWidth;
			else
				left += i.offsetWidth;
			if(alignY == 'top')
				top -= c.offsetHeight;
			else
				top += i.offsetHeight;
			if(top<10)
				top = 10;
			// XXX: Don't know why IE5 needs this here and not for calendar
			if(gClientIsIE5) {
				left += document.body.scrollLeft;
				top += document.body.scrollTop;
			}
        	c.style.left = left+'px';
	        c.style.top = top+'px';
			c.style.visibility = 'visible';
		} else {
			c.style.display="none";
		}
	}
}

function hideDiv (div) {
	if (document.getElementById){
		var c=document.getElementById(div);
		c.style.display="none";
	}
}

var hide  = true;

// Getting element dimensions
function getDimensions( elm ) {
	var box = { x:0, y:0, w:0, h:0 };
	if(document.getBoxObjectFor) {
		var boxRef = document.getBoxObjectFor(elm);
		box.x = boxRef.x;
		box.y = boxRef.y;
		box.w = boxRef.width;
		box.h = boxRef.height;
	}
	else if(elm.getBoundingClientRect) {
		var rxIE50 = /MSIE 5\.0/g;
		//alert(rxIE50 + '.test("' + navigator.appVersion + '" = ' + rxIE50.test(navigator.appVersion));
		var boxRef = elm.getBoundingClientRect();
		box.x = boxRef.left;
		box.y = boxRef.top;
		box.w = (boxRef.right - boxRef.left);
		box.h = (boxRef.bottom - boxRef.top);
		//var s='';for(p in boxRef) s+=p+'    '; alert(s);
		// Damn IE...
		if(document.compatMode && document.compatMode != 'BackCompat') {
			// IE6/compliance mode
			box.x += document.documentElement.scrollLeft - 2;
			box.y += document.documentElement.scrollTop - 2;
		}
		else if(!gClientIsIE5) {
			// IE5.5
			box.x += document.body.scrollLeft - 2;
			box.y += document.body.scrollTop - 2;
		}
	}
	else {
		// No known box information available, walking
		// manually through offsetParents to calculate x/y coordinates
		box.w = elm.offsetWidth;
		box.h = elm.offsetHeight;
		while(elm) {
			box.x += elm.offsetLeft;
			box.y += elm.offsetTop;
			elm = elm.offsetParent;
		}
	}
	//var bodyDiv = document.getElementById('body');
	//box.x -= bodyDiv.offsetLeft;
	return box;
}

function addbookmark(bookmarkurl,bookmarktitle)
{
	if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function bookmarksite(url,title){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
window.external.AddFavorite(url, title);
}

function AddToFavorites3(url, title)
{
	var IEstring = "<a href='javascript:window.external.addfavorite(location.href,document.title);' title='add to favorites'>favorites<\/a>" 
	//IEstring += "(location.href,document.title);' title='add to favorites'>favorites<\/a>" ; 
	var NSstring = "Click [Ctrl + D] "; 
	var OPstring = "Click [Ctrl + T]"; 
	var OTHstring = "Bookmark this page!" 
	var whichString = OTHstring ; 
	var agt = navigator.userAgent.toLowerCase(); 
	var app = navigator.appName.toLowerCase(); 
	var ieAgent = agt.indexOf('msie'); 
	var nsAgent = app.indexOf('netscape'); 
	var opAgent = app.indexOf('opera'); 
	if (ieAgent!= -1) { whichString = IEstring; } else if (nsAgent!= -1){ whichString = NSstring; } else if (opAgent!= -1){whichString = OPstring; } 
	document.write(whichString);	
}

function addToFavorites2(url, title) { 
var urlAddress = url; 
var pageName = title; 

if (window.external) { window.external.AddFavorite(urlAddress,pageName)} 
else { alert("Sorry! Your browser doesn't support this feature.");} 
} 

function AddLinkToBookmark(bookmarkurl,bookmarktitle)
{
	if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function AddLinkToBookmark(title) {
	//title = "VseVesti.com - ????? ?????? ??????";
	url = "http://vsevesti.com";
        if (window.sidebar) { // Mozilla Firefox Bookmark
                window.sidebar.addPanel(title, url,"");
        } 
	else if( window.external ) { // IE Favorite
                window.external.AddFavorite( url, title); 
	}
        else if(window.opera && window.print) { // Opera Hotlist
                alert("Sorry, your web browser does not support automatically adding Bookmarks/Favorites.  Press 'Ctrl-D' in Firefox or 'Ctrl-T' in Opera to manually bookmark VseVesti.ru");
                return true;
        }
 }

function ff(nodeId)
{

    var node = document.getElementById(nodeId);
    if (node.style.display =='none')
    {
        node.style.display = 'block';
    }else{
    	 node.style.display = 'none';
    	}
}

function showFormPart(elem,partcode){
	if(elem.options[elem.selectedIndex].value == partcode || document.getElementById(partcode).style.display =='block'){
		ff(partcode);
		return true;
	}else{
		return false;
	}
}

///FLASH inserting...

function commitFlashObject(_obj, _container){
	_output=""
	_paramoutput=""
	_src=""
	_ver=""
	for(_cO in _obj){
		_output+=_cO+"=\""+_obj[_cO]+"\" "
		_paramoutput+="<param name="+_cO+" value=\""+_obj[_cO]+"\">";
		if(_cO=="movie")_src="src=\""+_obj[_cO]+"\"";
		if(_cO=="version")_ver=_obj[_cO];
	}
	if(_ver=="")_ver="8,0,0,0"
	ihtm="<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+_ver+" "+_output+">\n"
	ihtm+=_paramoutput+"\n"
	ihtm+="<embed "+_src+" pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash "+_output+">\n";
	ihtm+="</embed>\n";
	ihtm+="</object>\n";
	document.getElementById(_container).innerHTML=ihtm	
}
function makevisible(cur,which){
strength=(which==0)? 1 : 0.2

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

     var date_selector =
    {
      frm:null,
      init:function(frm1)
      {
        this.frm=frm1;
      },
      getMonthTable:function(year, month, date)
      {
        var tableText = "";
        var months =
        [
          "January", "February", "March", "April", "May", "June", "July",
          "August", "September", "October", "November", "December"
        ];
        var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
        month = (month == null || isNaN(month) ? null : month);
        if(year == null || isNaN(year) || month == null || isNaN(month))
        {
          var dt = new Date();
          year = dt.getFullYear();
          month = dt.getMonth();
          date = dt.getDate();
        }
        date = (date == null || isNaN(date) ? null : date);
        var previousMonth = new Date(year, month-1, 1);
        var nextMonth = new Date(year, month+1, 1);
        tableText =
        (
          "<table align=\"center\" id=\"dateTable\" \
          cellpadding=\"1\" cellspacing=\"0\">\
          <tr>\
          <th style=\"cursor:pointer;text-align:left;\" \
          onclick=\"date_selector.updateDateSelectorPane("
          +previousMonth.getFullYear()+", "+previousMonth.getMonth()
          +");\">&#8592;</th>\
          <th style=\"text-align:center;\" colspan=\"4\">"+months[month]
          +", "+year+"</th>\
          <th style=\"cursor:pointer;text-align:right;\" \
          onclick=\"date_selector.updateDateSelectorPane("
          +nextMonth.getFullYear()+", "+nextMonth.getMonth()+");\">&#8594;</th>\
          <th style=\"text-align:right;cursor:pointer;\" \
          onclick=\"date_selector.updateDateElement();\">X</th>\
          </tr>"
        );
        for(var i=0; i<days.length; i++)
        {
          tableText += "<th>"+days[i]+"</th>";
        }
        tableText += "</tr>";
        var tempDate;
        for(var i=1-(new Date(year, month, 1)).getDay();; i++)
        {
          tempDate = new Date(year, month, i);
          if(tempDate.getDay() == 0)
          {
            tableText += "<tr>";
          }
          tableText +=
          (
            "<td"+(tempDate.getMonth() == month ? " \
            onclick=\"date_selector.updateDateElement("
            +tempDate.getFullYear()+", "+
            tempDate.getMonth()+", "+tempDate.getDate()+");\""+
            (tempDate.getDate() == date
            ? " style=\"border:solid 2px black;font-weight:bold;\"" : "")
            : " \
            style=\"color:silver;cursor:default;\"")+">"+
            tempDate.getDate()+
            "</td>"
          );
          if(tempDate.getDay() == 6)
          {
            tableText += "</tr>";
          }
          tempDate = new Date(year, month, i+1);
          if(tempDate.getMonth() != month && tempDate.getDay() == 0)
          {
            break;
          }
        }
        tableText += "</table>";
        return tableText;
      },
      updateDateSelectorPane:function(year, month, day)
      {
        var d = document.getElementById("dateSelectorPane");
        d.innerHTML = this.getMonthTable(year, month, day);
        d.style.display = "block";
      },
      showDateSelector:function(elementName)
      {
        if(elementName == null)
        {
          this.updateDateSelectorPane();
        }
        else
        {
          this.dateElementToUpdate = elementName;
          var e = this.frm.elements[elementName];
          e = e.value.split("/");
          try
          {
            e[0] = parseInt(e[0], 10);
            e[1] = parseInt(e[1], 10);
            e[2] = parseInt(e[2], 10);
            this.updateDateSelectorPane(e[2], e[0]-1, e[1]);
          }
          catch(e)
          {
            this.updateDateSelectorPane();
          }
        }
      },
      updateDateElement:function(year, month, day)
      {
        document.getElementById("dateSelectorPane").style.display="none";
        if(year != null && month != null && day != null)
        {
          month = (month+1)+"";
          day += "";
          month = (month.length == 1 ? "0"+month : month);
          day = (day.length == 1 ? "0"+day : day);
          this.frm.elements[this.dateElementToUpdate].value
          = (month+"/"+day+"/"+year);
                    szamol();                    
        }
        this.dateElementToUpdate = null;
      },
      dateElementToUpdate:null
    };
    function printDateRange()
    {
      var frm = date_selector.frm;
      window.alert
      (
        'This Popup summarizes the date range you entered.\n\n'
        +'Minimum Date:  '+frm.minimumDate.value
        +'\n\nMaximum Date:  '+frm.maximumDate.value
      );
    }

