var Popup = new Class({
   initialize: function(id,style,parent,controller_selector,ihtml){
       if(!parent || !$(parent)){
           par = document.body;
       }else{
           par = $(parent);
       }       
       this.id = "pu_"+id;          
       pop_div = new Element("div",{
          "id" : this.id,
          "class" : style,
          "styles" : {"display":"none",
                      "position":"absolute",
                      "left":"50%",
                      "margin-left":"-232px"}                   
       });              
       pop_div.appendChild(new Element("div",{"id":this.id+"_content"}));
       pop_div.appendChild(new Element("div",{
           "id":this.id+"_close", 
           "class": style+"_close",
           "styles":{"cursor":"pointer"}
       }));   
           
       par.appendChild(pop_div);
       $(this.id+"_close").setProperty("alt",id+".close();");
       $(this.id+"_close").addEvent('click',function(){
                eval(this.getProperty('alt'));
            });
       
       if(!document.all){
            $(this.id).set("opacity","0");
            $(this.id).style.display="block";
       }else{
            $(this.id).style.display="none";
       }
       
       $(this.id+"_content").load(ihtml);
       
       if(controller_selector){
           z = $$(controller_selector);
           for(i=0;i<z.length;i++){
                z[i].setProperty("alt",id+".toggle();");
                z[i].addEvent('click',function(){
                    eval(this.getProperty('alt'));
                });
           }
       }      
   },   
   show: function(){     
       var top__ = 0;
       try{
            top__ = document.body.getScroll().y+50;
       }catch(e){
            iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
            top__ = iebody.scrollTop+50;
       }
       $(this.id).style.top = top__+"px";      
       if(!document.all){
            $(this.id).fade(1.0);
       }else{
            $(this.id).style.display="block";
       }       
   },
   close: function(){        
       if(!document.all){
            $(this.id).fade(0.0);
       }else{
            $(this.id).style.display="none";
       }
   },
   toggle: function(){
       if(!document.all){
           op = $(this.id).get("opacity");
           if(op==0){
                this.show();
           }else if(op==1){
                this.close();
           }       
       }else{
           op = $(this.id).style.display;
           if(op=="none"){
                this.show();
           }else{
                this.close();
           }
       }
   }
});

function popUp(frmId){
    z = $$('fieldset.error, fieldset.success');
    for(i=0;i<z.length;i++){
        z[i].setStyle('display','none');
    }
    if(checkForm(frmId)){
        frm = $(frmId);
        act = frm.getProperty('action');
        contract_popup.show();
        /*    
    	eval("pagepopup_confirm = window.open('about:blank', 'popup_confirm', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=500,left = 100,top = 100');");
        */
        frm.setProperty('action',doc_root+'jelentkezes_elfogadas');
        frm.setProperty('target','popup_confirm');                
        frm.submit();
        frm.setProperty('action',act);
        frm.setProperty('target','');
     }
     return false;
}

function canceling(){
    window.close();
}

function confirming1(){        
    $('jelentkezes_kuldes').value="Küldés Folyamatban...";
    $('jelentkezes_kuldes').style.backgroundColor = '#39629d';    
    $('jelentkezes_kuldes').disabled=true;
    $('reg_1').submit();    
    contract_popup.close();
}

var contract_popup = false;

window.addEvent('domready',function(){    
    $$('input, select').addEvent('keypress',function(e){       
       if(e.key=='enter'){
        e.stop();       
       } 
    });
    contract_popup = new Popup('contract_popup','countarct_pu','',false,doc_root+"templates/template/js/confirmIframe.html");
});

