
var bIsIE   = (document.all) ? true : false;
var bIsDOM  = (document.getElementById) ? true : false;

 function check_enter()
         {
          if(self.event.keyCode==13)
             {
               submit();
             }
          }

function move(d,box_id,h,v)
{
        //document.edit_banner_form.+d+.value="yes";
        if (d=="left")document.edit_box_form.left.value="yes";
        if (d=="down")document.edit_box_form.down.value="yes";
        if (d=="right")document.edit_box_form.right.value="yes";
        if (d=="up")document.edit_box_form.up.value="yes";
        document.edit_box_form.pos_h.value=h;
        document.edit_box_form.pos_v.value=v;
        document.edit_box_form.box_id.value=box_id;
        document.edit_box_form.submit();
}

function move_t(d,topic_id,h,v)
{
        //document.edit_banner_form.+d+.value="yes";
        if (d=="left")document.edit_topic_form.left.value="yes";
        if (d=="down")document.edit_topic_form.down.value="yes";
        if (d=="right")document.edit_topic_form.right.value="yes";
        if (d=="up")document.edit_topic_form.up.value="yes";
        document.edit_topic_form.pos_h.value=h;
        document.edit_topic_form.pos_v.value=v;
        document.edit_topic_form.topicid.value=topic_id;
        document.edit_topic_form.submit();
}

function move_link(d,id,p)
{
        //document.edit_banner_form.+d+.value="yes";
        if (d=="down")document.list_link_form.down.value="yes";
        if (d=="up")document.list_link_form.up.value="yes";
        document.list_link_form.pos.value=p;
        document.list_link_form.link_id.value=id;
        document.list_link_form.submit();
}


function fill_box_name(box_id,box_name)
{
        document.edit_box_form.mod_name.disabled=false;
        document.edit_box_form.mod_cont.disabled=false;
        document.edit_box_form.delete_box_button.disabled=false;
        document.edit_box_form.box_id.value=box_id;
        document.edit_box_form.box_name_field.value=box_name;


}

function checkDate(formname)
{
                var x = document.forms[formname].date.value;
                var filter  = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
                if (filter.test(x)) return true;
                else
                {
                        document.forms[formname].date.value=x;
                        alert('Incorrect date ');
                        document.forms[formname].date.focus();
                }

}

function checkMail(formname)
{
                var x = document.forms[formname].email.value;
                var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                if (filter.test(x)) return true;
                else
                {
                        document.forms[formname].email.value=x;
                        alert('Invalid email address');
                        document.forms[formname].email.focus();
                }

}


function findPosX(obj)
{
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else
                if (obj.x)
                        curleft += obj.x;

        return curleft;
}

function findPosY(obj)
{
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else
                if (obj.y)
                        curtop += obj.y;

        return curtop;
}


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) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
                if ((obj=MM_findObj(args[i]))!=null)
                {   v=args[i+2];
                        if (obj.style)
                        {
                                obj=obj.style;
                                v=(v=='show')?'visible':(v=='hide')?'hidden':v;
                        }
                        if (obj.visibility!=v)
                                obj.visibility=v;
                }
}

function setImgSrc( ImgObj, Filename ){
        if( !ImgObj ) return false;
        ImgObj.src = Filename;
}


function collapseBox( BoxName ){
        if( !(Box=MM_findObj(BoxName)) )
                return false;

        if(Box.style.display == "" || Box.style.display == "block"){
                Box.style.display = "none";
                setImgSrc( MM_findObj(BoxName+"img"), "./_main_page/images/box_open.gif" );
        }
        else{
                Box.style.display = "block";
                setImgSrc( MM_findObj(BoxName+"img"), "./_main_page/images/box_close.gif" );
        }

}

function popupWindow( Page, Width, Height ){
        popWindow = window.open( Page,"popWindow","width="+Width+",height="+Height+",scrollbars=0,left="+((screen.width-Width)/2)+",top="+((screen.height-Height)/2)).focus();
}

function displayCurrentDate(){

        var now=new Date();
        var month_names = new Array ( "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie");

        document.write( now.getDate()+" "+month_names[now.getMonth()]+" "+ now.getFullYear());
}
/*
function test_pop(county) {
    //alert(county);
    result = window.open(".\/"+county+"\/");
    if (result != null) html = "is not blocking";
    else html = "is blocking";
    document.location='county_selector.php?counties='+county;


}
*/
function test_pop(county) {
    //alert(county);
    result = window.open("http:\/\/"+county+".iaca.ro");
    if (!(result==null || typeof(result)=="undefined") )
        {
           //alert(typeof(result.closed));
           if ((typeof(result.closed)=="undefined")||(typeof(result.closed)=="boolean"))
                {
                        document.location='county_selector.php?counties='+county;
                        return;
                }
        }
    else
        {
         document.location='county_selector.php?counties='+county;
        }
}
function isEmail(string)
         {
          if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
           return true;
           else
             return false;
         }

function validation() {
       if(!isEmail(document.proposeform.email.value))
        {
         alert("Adresa de email incorecta");
         document.proposeform.email.focus();
        }
        else
        if(document.proposeform.name.value=='')
        {
         alert("Introduceti numele");
         document.proposeform.name.focus();
        }
        else
        if(!document.proposeform.url.value.match(/^(http:)|(www\.)[A-Z0-9_./-]*\.[A-Z]{2,4}$/i))
        {
         alert("Url incorect");
         document.proposeform.url.focus();
        }
        else
        if(document.proposeform.description.value=="")
        {
         alert("Introduceti descriere linkului");
         document.proposeform.description.focus();
        }
       else
        {
         document.proposeform.submit();
        }
 }
function validation1() {
       if(!isEmail(document.proposeform1.email.value))
        {
         alert("Adresa de email incorecta");
         document.proposeform1.email.focus();
        }
        else
        if(!document.proposeform1.url.value.match(/^(http:)|(www\.)[A-Z0-9_./-]*\.[A-Z]{2,4}$/i))
        {
         alert("Url este incorect");
         document.proposeform1.url.focus();
        }
        else
        if(document.proposeform1.pagina.value=="")
        {
         alert("Introduceti pagina");
         document.proposeform1.pagina.focus();
        }
       else 
       if(document.proposeform1.comentariu.value=="")
        {
         alert("Introduceti comentariul");
         document.proposeform1.comentariu.focus();
        }
       else
        {
         document.proposeform1.submit();
        }
}

