function swap_arrow(obj){
    kep=obj.getElementsByTagName('IMG').item(0);
    if(kep.src.search(/_white\.png/)!=-1){
        kep.src="data/pics/down_arrow.png";
    }else{
        kep.src="data/pics/down_arrow_white.png";
    }
}

function hide_popupdiv(id){
    document.getElementById(id).style.display='none';
    if(id=='popup0'){
        document.getElementById('popup1').style.display='block';
    }else{
        document.getElementById('popup0').style.display='block';
    }
}

function show_popupdiv(id){
    document.getElementById(id).style.display='block';
    if(id=='popup0'){
        document.getElementById('popup1').style.display='none';
    }else{
        document.getElementById('popup0').style.display='none';
    }
    timer = setTimeout("",500);
}

function PopupMouseOver(sender,event){
    if(event!=0){
        var relTarg =  event.toElement || event.relatedTarget || null;
        if(relTarg!=null){
                    while(relTarg.parentNode!=undefined && relTarg!=document && relTarg.nodeName!="BODY" && relTarg.nodeName != 'HTML' && relTarg.id!=sender.id){
                        relTarg = relTarg.parentNode;
                    }
            }
            
            if(relTarg==null || relTarg==document || relTarg.nodeName=="BODY" || relTarg.nodeName == 'HTML'){
                document.getElementById(sender.id).style.display='none';
            }
            
    }
}

function init_jq_mevent(sender,popup){
	$("#" + sender).mouseover(function(){
		$("#" + popup).clearQueue();
		$("#" + popup).css('display','block');
		$("select").css('display','none');
	});
	
	$("#" + sender).mouseleave(function(){
		$("#" + popup).delay(500).hide(1);
		$("select").css('display','inline');
	});
}

function SwitchInputClass(obj){
    if(obj.className.search(/_focus/)!=-1){
        obj.className=obj.className.replace("_focus", "");
    }else{
        obj.className=obj.className + "_focus";
    }
}

function isForbear(child_id,forbear_id){
    var temp= document.getElementById(child_id);
    while(temp.tagName!="BODY"){
        if(temp.id==forbear_id) return true;
        temp = temp.parentNode;
    }
    return false;
}

function RepairAgeForm(){
    
    //hide selects

    var selects=document.getElementsByTagName("SELECT");
    for(i=0;i<selects.length;i++){
        if(!isForbear(selects[i].id,'ageform')){
            selects[i].style.display="none";
        }
    }

    var arr = getPageSize();
    document.getElementById('odiv').style.height=arr[1] + "px";

    document.getElementById('dialog_div_container').style.height=arr[1] + "px";
}

function ShowRKDiv(){
    
    //hide selects

    var selects=document.getElementsByTagName("SELECT");
    for(i=0;i<selects.length;i++){
        selects[i].style.display="none";
    }

    var arr = getPageSize();
    document.getElementById('odiv_rk').style.display="block";
    document.getElementById('odiv_rk').style.height=arr[1] + "px";

    document.getElementById('dialog_div_container_rk').style.display="block";
    document.getElementById('dialog_div_container_rk').style.height=arr[1] + "px";
}

function HideRkDiv(){
    var selects=document.getElementsByTagName("SELECT");
    for(i=0;i<selects.length;i++){
        selects[i].style.display="inline";
    }
    
    document.getElementById('odiv_rk').style.display="none";
    document.getElementById('dialog_div_container_rk').style.display="none";
    
}

function ToggleProductOverlay(id){
    if(document.getElementById(id).style.display=='block'){
        document.getElementById(id).style.display='none';
    }else{
        document.getElementById(id).style.display='block';
    }
}


function AddLink(mit,mihez){
    if(mit==mihez){
        alert('Terméket nem lehet saját magához kötni');
    }else{
       var xmlHttp = createRequestObject();
           if(xmlHttp)
           {
              xmlHttp.onreadystatechange=function()
              {
                 if(xmlHttp.readyState==4)
                 {
                    document.getElementById('link_container').innerHTML=xmlHttp.responseText;
                 }
              }
              xmlHttp.open("GET","product_link_ajax.php?action=add&product_code_id1=" + mit + "&product_code_id2=" + mihez 
                                ,true);
              xmlHttp.send(null);
            }
    }
}


function RemLink(mit,mihez){
    var xmlHttp = createRequestObject();
    if(xmlHttp)
    {
       xmlHttp.onreadystatechange=function()
       {
          if(xmlHttp.readyState==4)
          {
             document.getElementById('link_container').innerHTML=xmlHttp.responseText;
          }
       }
       xmlHttp.open("GET","product_link_ajax.php?action=remove&product_code_id1=" + mit + "&product_code_id2=" + mihez 
                         ,true);
       xmlHttp.send(null);
     }
}

