var dom=(document.getElementById)?true:false;
var realdom=(document.addEventListener)?true:false;

function doFormFocus(obj) {
	if(obj.value==obj.defaultValue) obj.value='';
}

function doFormBlur(obj) {
	if(obj.value=='') obj.value=obj.defaultValue;
}



/* start smooth opening/closing scripting */
var fullH = 0;var opening=false; var doingOpen;
var actObj, exObj; var nextObj = new String();

function closeSmooth() {
/*
	exH = exObj.style.height.substring(0,exObj.style.height.length-2);
	if (exH > 10) {
		exH-=10;
		exObj.style.height = exH+'px';
		setTimeout("closeSmooth()", 30);
	} else {
		exObj.style.height = '0px';
		return false;
	}
*/
		exObj.style.height = '0px';
		return false;
}

function openSmooth() {
	openArgs = openSmooth.arguments;
	if(openArgs.length) {
		if (opening) nextObj = openArgs[0];
		else actObj = document.getElementById(openArgs[0]);
	}
	actH = actObj.scrollHeight;
	if (exObj && exObj!=actObj) closeSmooth();

actObj.style.height = 'auto';//actH+'px';
exObj = actObj;
newNextObj = nextObj;
nextObj = '';


/*
	if (!exObj || exObj!=actObj) {
		if (fullH < actH) {
			if (fullH > 1500) return false;
			fullH+=10;
			actObj.style.height = fullH+'px';
			opening = true;
			doingOpen = setTimeout("openSmooth()", 10);
		} else {
			opening=false;
			exObj = actObj;
			fullH = 0;
			if(nextObj.length) {
				newNextObj = nextObj;
				nextObj = '';
				openSmooth(newNextObj);
			}
		}
	}
*/
	return false;
}
/* end smooth opening/closing scripting */

function ShowIntr() {
	var x = document.getElementById('intr');
	x.style.display = 'block';
}

function HideIntr() {
	var x = document.getElementById('intr');
	x.style.display = 'none';
}

function ShowDiv(did) {
	var x = document.getElementById(did);
	x.style.display = 'block';
}

function HideDiv(did) {
	var x = document.getElementById(did);
	x.style.display = 'none';
}

var D_Opt = new Array()

function LengthOfMonth(Y, M) { // M=1..12 // OK in NS4? Mac?
  with (new Date(Y,M,1,12)) { setDate(0) ; return getDate() } }

function MonLen(Yr, Mo, Dy) {
    var Dol, K, DiM, NsI;
    DiM = LengthOfMonth(+Yr.options[Yr.selectedIndex].text, Mo.selectedIndex + 1);
    Dol = Dy.options.length;
    if ((NsI = Dy.selectedIndex) >= DiM) {
        NsI = DiM - 1;
    }
    for (K = Dol; K > DiM; K--) {
        D_Opt[K] = Dy.options[K - 1];
        Dy.options[K - 1] = null;
    }
    for (K = Dol + 1; K <= DiM; K++) {
        Dy.options[K - 1] = D_Opt[K];
    }
    Dy.selectedIndex = NsI;
}

function DropReadYMD(Yr, Mo, Dy) {
    var Y = +Yr.options[Yr.selectedIndex].text;
    var M = Mo.selectedIndex;
    var D = Dy.selectedIndex + 1;
    return Y + "-" + Lz(M + 1) + "-" + Lz(D) + ", " + Day3[(new Date(Y, M, D)).getDay()];
}

function InitYMDselector(Yr, Mo, Dy, Anni, Base, SetObj, lng) {
    var J;
    var Mon3 = new Array();
		Mon3["ro"] = ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie",
									"Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"];
		Mon3["en"] = ["January", "February", "March", "April", "May", "June",
									"July", "August", "September", "October", "November", "December"];
		Mon3["fr"] = ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie",
									"Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"];
    if (!Base) {
        Base = (new Date()).getFullYear();
    }
    for (J = 0; J < Anni; J++) {
        Yr.options[J] = new Option(Base + J);
    }
    for (J = 0; J < 12; J++) {
        Mo.options[J] = new Option(Mon3[lng][J], J+1);
    }
    for (J = 0; J < 31; J++) {
        Dy.options[J] = new Option(J + 1);
    }
    if (SetObj) {
        with (SetObj) {
            Yr.selectedIndex = getFullYear() - Base;
            Mo.selectedIndex = getMonth();
            Dy.selectedIndex = getDate() - 1;
        }
    } else {
        Yr.selectedIndex = Mo.selectedIndex = Dy.selectedIndex = 0;
    }
    MonLen(Yr, Mo, Dy);
}

function limit(limitField) {
	if (limitField.value.length > 255) {
		limitField.value = limitField.value.substring(0, 255);		
	} 
}



