function no2str(no) {
	if (no<10) {return "0"+no;}	
		else {return no;}	
}

function getCurrentMonth(lang) {
	var currentMonth = new Date().getMonth();
	if (lang=="ro") {
		if (currentMonth==0) {return "ianuarie"} else
		if (currentMonth==1) {return "februarie"} else
		if (currentMonth==2) {return "martie"} else
		if (currentMonth==3) {return "aprilie"} else
		if (currentMonth==4) {return "mai"} else
		if (currentMonth==5) {return "iunie"} else
		if (currentMonth==6) {return "iulie"} else
		if (currentMonth==7) {return "august"} else
		if (currentMonth==8) {return "septembrie"} else
		if (currentMonth==9) {return "octombrie"} else
		if (currentMonth==10) {return "noiembrie"} else
		if (currentMonth==11) {return "decembrie"} 
	}
	else {
		if (currentMonth==0) {return "january"} else
		if (currentMonth==1) {return "february"} else
		if (currentMonth==2) {return "march"} else
		if (currentMonth==3) {return "april"} else
		if (currentMonth==4) {return "mai"} else
		if (currentMonth==5) {return "june"} else
		if (currentMonth==6) {return "july"} else
		if (currentMonth==7) {return "august"} else
		if (currentMonth==8) {return "september"} else
		if (currentMonth==9) {return "octomber"} else
		if (currentMonth==10) {return "november"} else
		if (currentMonth==11) {return "december"} 
	}
}

function getCurrentYear() {
	var an=new Date().getYear();
	var an_str=new String(an);
	if (an_str.length==3) {an_str=an_str.substring(1);
			an_str="20"+an_str;}
	return an_str;
}

function ceas(ro) {
	var ceas_div=document.getElementById("ceas");
	var currentTime=new Date();
	var ora=currentTime.getHours();
	var minut=currentTime.getMinutes();
	var secunde=currentTime.getSeconds();
	
	var zi=currentTime.getDate();
	if (ro) {var luna=getCurrentMonth("ro");}
			else {var luna=getCurrentMonth("en");}
	an_str = getCurrentYear();
	ceas_div.innerHTML=no2str(ora)+":"+no2str(minut)+":"+no2str(secunde)+"  "+zi+" "+luna+" "+an_str;
	setTimeout("ceas("+ro+")",1000);
}

var temp;
function openpopup (myfile, myname, width, height,scrolls)
{
  if((navigator.appName.indexOf("Explorer")!=-1)&&(parseInt(navigator.appVersion.substring(0,1))<4))
    {
      params = "width=" + width + ",height=" + height + ",resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=1";
      newwin = window.open( myfile , myname , params);
    }
    else
    {
      if(temp)
      {
        if(!temp.closed)
        {
          temp.close();temp="";
        }
      }
      params = "width=" + width + ",height=" + height + ",resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=1";
      newwin = window.open( myfile , "" , params);
      temp = newwin;
      temp.name = "temp";
      newwin="";
    }
}



function openPrintPopup(pageok, width, height) {
		params = "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes";
    x=window.open(pageok,"print",params);
    x.focus();
}

function openresource (myfile, myname, breite, hoehe,scrolls)
{
  if(!scrolls) { scrolls = 0 }
  if((navigator.appName.indexOf("Explorer")!=-1)&&(parseInt(navigator.appVersion.substring(0,1))<4))
    {
      params = "width=" + breite + ",height=" + hoehe + ",resizable=1,status=0,scrollbars="+scrolls+",toolbar=0,location=0,directories=0,menubar=0";
      newwin = window.open( myfile , myname , params);
    }
    else
    {
      if(temp)
      {
        if(!temp.closed)
        {
          temp.close();temp="";
        }
      }
      params = "width=" + breite + ",height=" + hoehe + ",resizable=1,status=0,scrollbars="+scrolls+",toolbar=0,location=0,directories=0,menubar=0";
      newwin = window.open( myfile , myname , params);
      temp = newwin;
      temp.name = "temp";
      newwin="";
    }
}

function showConfirmation(message, linkOK, linkCancel){
	OK = confirm(message);
  if( OK == true){
  	return linkOK;
  } else {
    return linkCancel;
  }
}


function toggleCheckboxes(fObj,chkList){

     var chkLength = chkList.length;
     if (chkLength > 0)
     {
	     for (var i=0; i<chkLength; i++){
		     if(fObj.checked == true){
		          chkList[i].checked = true;
		     }
		     else {
		          chkList[i].checked = false;
		     }
	     }
     }

}

function checkBrowser(nextURL){
  var Netscape = navigator.appName == "Netscape";
  var MSIE = navigator.appName == "Microsoft Internet Explorer";
  var Opera = navigator.userAgent.indexOf("Opera") > -1;
  var Unknown = !(Netscape || MSIE || Opera);
  var BrowserVer=0;

  if(Netscape) {
    BrowserVer = parseFloat(navigator.appVersion);
  }
  else if(MSIE) {
    var n = navigator.userAgent;
    var MSIEVer = n.substr(n.indexOf("MSIE ")+("MSIE ").length, 4);
    BrowserVer = parseFloat(MSIEVer);
    // converts it into a floatint point number

    if(Opera) {
      var OperaVer = n.substr(n.indexOf("Opera ")+("Opera ").length, 4);
      BrowserVer = parseFloat(OperaVer);
    }
  }

	if (MSIE && !Opera && BrowserVer>=6){
		window.location=nextURL;
		return true;
	} else {
	  alert("You must use Microsoft Internet Explorer 6 to insert/update articles.");
	  return false;
	}
}

var tempX = 0
var tempY = 0

var IE = document.all?true:false

var movingDiv = "";

function setToolTip(divId, str) {

	movingDiv = divId;
	document.getElementById(movingDiv).innerHTML = str;
	document.getElementById(movingDiv).style.visibility = "visible";
	
	if (!IE) document.captureEvents(Event.MOUSEMOVE)

	document.onmousemove = getMouseXY;
	
}

function clearToolTip() {
	document.getElementById(movingDiv).style.visibility = "hidden";
	movingDiv = "";
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  
  if (movingDiv!="") {
	  document.getElementById(movingDiv).style.top = tempY + 20;
	  document.getElementById(movingDiv).style.left = tempX + 20;
  }
  
  return true
}

function windowOpen(url,w,h) {
	//Wremote = window.open('', 'windowRef_CRSC');
	//Wremote.close();
	var w1 = w + 50;
	var h1 = h + 100;
    var myWindow=window.open(url,'picture','width=' + w1 + ',height=' + h1 +',scrollbars=yes,toolbar=no,location=no,resizable=no,menubar=no,left=100,top=100' );
    if (!myWindow.opener)
    	myWindow.opener = self;
	myWindow.focus();
}

