
function getElement(aID)
{
    return (document.getElementById) ? document.getElementById(aID)
                                     : document.all[aID];
}


//ediy v2
function flash_fix()
{
n=navigator.userAgent;
w=n.indexOf("MSIE");
o=n.indexOf("Opera");
if( ( (w>0)&&(parseInt(n.charAt(w+5)) >5 ) ) || (o>=0) )
{
        T=["object","embed","applet"];
        for(j=0;j<3;j++)
        {
                E=document.getElementsByTagName(T[j]);
                for(i=0;i<E.length;i++)
                {
                        P=E[i].parentNode;
                        H=P.innerHTML;
                        P.removeChild(E[i]);
                        P.innerHTML=H;
                }
        }
}

}

/*PNG IE SUPPORT*/
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "" + img.style.cssText
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}
/* browser */

function bwcheck()
{
        this.ver    = navigator.appVersion;
        this.agent  = navigator.userAgent;

        this.dom    = document.getElementById ? 1 : 0;

        this.opera5 = (navigator.userAgent.indexOf("Opera") > -1 && document.getElementById) ? 1 : 0;

        this.ie5    = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera5) ? 1 : 0;
        this.ie6    = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera5) ? 1 : 0;
        this.ie4    = (document.all && !this.dom && !this.opera5) ? 1 : 0;
        this.ie     = this.ie4 || this.ie5 || this.ie6;

        this.mac    = this.agent.indexOf("Mac") > -1;

        this.ns6    = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
        this.ns4    = (document.layers && !this.dom) ? 1 : 0;

        return this;
}



/* submit once

<form .... onSubmit="submit_once();">

*/

var submit_count = 0;

function submit_once()
{
        if (submit_count == 0)
        {
                for (var j = 0; j < document.forms.length; j++)
                {
                        for (var i = 0; i < document.forms[j].elements.length; i++)
                        {
                                var e = document.forms[j].elements[i];
                                if ((e.type == "submit") || (e.type == "image") || (e.type == "button"))
                                {
                                        e.style.visibility = 'hidden';
                                }
                        }
                }

                submit_count++;
                return true;
        }
        else
        {
                alert("Acest formular a fost deja trimis.\nVa rugam asteptati pana cand serverul proceseaza datele.\nVa multumim!");
                return false;
        }
}



/* image over

<a href="url.php" onMouseOver="swapImage('img_name', '', './images/img_src_over.gif', 1);" onMouseOut="swapImgRestore();"><img name="img_name" src="./images/img_src.gif" width="15" height="9" border="0" /></a>

*/

function swapImage()
{
        var i,
            j = 0,
            x,
            a = swapImage.arguments;

        document.sr = new Array;

        for (i = 0; i < (a.length - 2); i += 3)
        {
                if ((x = findObj(a[i])) != null)
                {
                        document.sr[j++] = x;
                }

                if(!x.oSrc)
                {
                        x.oSrc = x.src;
                }

                x.src = a[i + 2];
        }
}

function swapImgRestore()
{
        var i,
            x,
            a = document.sr;

        for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
        {
                x.src = x.oSrc;
        }
}

function preloadImages()
{
        var d = document;

        if (d.images)
        {
                if (!d.p)
                {
                        d.p = new Array();
                }

                var i,
                    j = d.p.length,
                    a = preloadImages.arguments;

                for (i = 0; i < a.length; i++)
                {
                        if (a[i].indexOf("#") != 0)
                        {
                                d.p[j] = new Image;
                                d.p[j++].src = a[i];
                        }
                }
        }
}

function findObj(n, d)
{
        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 = findObj(n, d.layers[i].document);
        }

        if (!x && d.getElementById)
        {
                x = d.getElementById(n);
        }

        return x;
}



/* open new window */

function open_new(win_url, win_name, w, h)
{
        var newWindow = null;

        LeftPosition = (screen.width)  ? ((screen.width  - w) / 2) : 100;
        TopPosition  = (screen.height) ? ((screen.height - h) / 2) : 100;

        settings = 'width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';
        newWindow = window.open('', win_name, settings);

        newWindow.location = win_url;
        newWindow.title = win_name;
        newWindow.focus();
}



/* link over */

function mouse_out(tr, color)
{
        tr.style.backgroundColor = color;
        return;
}

function mouse_over(tr, color)
{
        tr.style.backgroundColor = color;
        return;
}



/* checkboxes */

function check_showed(check, input)
{
        if (check.checked == false)
        {
                input.disabled = true;
                input.value    = '';
        }
        else
        {
                input.disabled = false;
        }
}



/*  */

function to_number(input)
{
        count = 0;
        for (i = 0; i <= (input.value.length - 1); i++)
        {
                if (input.value.charAt(i) == '.')
                {
                        count++;
                }
        }

        if (((count == 1) && (input.value.charAt(input.value.length - 1) == '.')) || (input.value.length == 0))
        {
                return false;
        }

        number = parseFloat(input.value);
        input.value = number;

        return number;
}

//if (document.all)
//        window.attachEvent("onload", correctPNG);
document.onload=preloadImages;

