
function writeFlash(path,width,height){
document.write('<object type="application/x-shockwave-flash"  data="'+path+'" height="'+height+'" width="'+width+'" >'+
              '<param name="autoStart" value="-1" />'+
              '<param name="movie" value="'+path+'" />' +
              '<param name="play" value="true" />' +
              '<param name="loop" value="true" />' +
              '<param name="quality" value="high" />' +
              '<param name="scale" value="noborder" />' +
              '<param name="devicefont" value="true" />' +
              '<param name="bgcolor" value="#FFFFFF" />' +
              '</object>');
}

var err=false;
var msngr=null;
window.onload = function(){
    var msngr=new messanger();
    msngr.init();
    
  if(err){
    alert(err);
    
  }
  //alertX('test');
  // test();
}
function ativaOptionsDisabled(){
    var sels = document.getElementsByTagName('select');
    for(var i=0; i < sels.length; i++){
        sels[i].onchange= function(){ //pra se mudar pro desabilitado
            if(this.options[this.selectedIndex].disabled){
                if(this.options.length<=1){
                    this.selectedIndex = -1;
                }else if(this.selectedIndex < this.options.length - 1){
                    this.selectedIndex++;
                }else{
                    this.selectedIndex--;
                }
            }
        }
        if(sels[i].options[sels[i].selectedIndex].disabled){
            //se o selecionado atual é desabilitado chamo o onchange
            sels[i].onchange();
        }    
        for(var j=0; j < sels[i].options.length; j++){ //colocando o estilo
            if(sels[i].options[j].disabled){
                sels[i].options[j].style.color = '#CCC';
            }
        }
    }
}
//window.attachEvent("onload", ativaOptionsDisabled);

function message_box(id){
    ajaxx = new ajax();
    param=[['tid',id]];
      ajaxx = new ajax();
      ajaxx.send("/ajax.get_text.php",param,function(){
   if (xmlHttp.readyState==4){
      msngr.setWidth(600);
      msngr.setText("<div style='height:600px;overflow:auto;width:600px;'>"+xmlHttp.responseText+"</div>");
      msngr.setCloseOnClick(false);
      msngr.show();
  }
  });
   /* */
}

function alertX(text){
    
    msngr.setWidth(400);
    msngr.setText("<b>Správa:</b><br /><br />"+text.replace(/\n/g, '<br />')+"<br />&nbsp;");
    msngr.setCloseOnClick(false);
    msngr.show();
}
var s='',k='';

function changeOffer(node){
  if(node.className=='chb'){
    node.className='chbs';
    parameters=[['add',node.id]];
  }else{
    node.className='chb';
    parameters=[['remove',node.id]];
  }
  addRemoveOffer(parameters);
}

function changeOfferAll(select){
  input=document.getElementsByTagName('INPUT');
  for(i=0;i<input.length;i++){
    if(input[i].className=='offer_i'){
       input[i].checked=select;
    }//
  }
  if(select){
    parameters=[['all','add']];
  }else{
    parameters=[['all','remove']];
  }
  addRemoveOffer(parameters);
}

function addRemoveOffer(parameters){
  ajaxx = new ajax();
  parameters.push(['s',s]);
  parameters.push(['k',k]);
  ajaxx.send("/ajax.offers.php",parameters,function(){
   if (xmlHttp.readyState==4){//
      //alert(xmlHttp.responseText);
      var xmlDoc=xmlHttp.responseXML.documentElement;
        offerCount=document.getElementById("offer_count");
        
        count=xmlDoc.getElementsByTagName("count")[0].childNodes[0];//.nodeValue;
        all=xmlDoc.getElementsByTagName("all")[0].childNodes[0];//.nodeValue;
        
        /*idallx=document.getElementById("idall");
        if(all&&all.nodeValue=='yes'){
          idallx.checked=true;
        }else{
          idallx.checked=false;
        }*/
        if(count)offerCount.value=count.nodeValue;//
        //alert(count.nodeValue);
   
   }
  });
}
function fCalendar(kam,prefix) 
{
var int_windowLeft = (screen.width - 250) / 2;
var int_windowTop = (screen.height - 250) / 2;
window.open( 'kalendar.php?place='+kam+'&prefix='+prefix, 'kalendar', 'top='+int_windowTop+', left='+int_windowLeft+', width=250,height=250,resizable=yes,scrollbars=1')
//window.open(,'calendar','location=0, scrollbars=1, width=250, height=250, top='+int_windowTop+', left='+int_windowLeft+'');
}
function setDate(id,value){
  kam = document.getElementById(id);
	kam.value=value;
}
function check_offers(){
count=document.getElementById('offer_count').value;
if(count==0){
alert('Nie je vybratá ani jedna firma!');
return false
}
if(count>5){
alert('Môžete osloviť maximálne 5 zvolených firiem!');
return false
}
/*else if(count<5){
return !confirm('POZOR - Oslovujete málo firiem !\nNie všetky oslovené firmy zareagujú na Váš dopyt.\nAby ste si získali očakávané ponuky, doporučujeme Vám označiť min. 5 firiem !\n\nPrajete si označiť viac firiem?');
}*/
return true;
}

function get_images_list(sc,d){
  ajaxx = new ajax();
  if(d){
    if(!confirm('Naozaj si prajete odstrániť obrázok'))return false;
    param=[['sc',sc],['d',d]];
  }else{
    param=[['sc',sc]];
  }
  
  //alert(sc);
  ajaxx.send("/ajax.references_images.php",param,function(){
   if (xmlHttp.readyState==4){
      //alert(xmlHttp.responseText);
      document.getElementById('images_list').innerHTML=xmlHttp.responseText;
   }
  });
}
/*
function imageX(link,width,height){
    msngr.setWidth(width);
   // complete
    left=Math.round(width/2-20);
   // alert(height);
    topx=Math.round(height/2-20);
    
    msngr.setText('<div id="cover" style="position:absolute;width:'+width+'px;height:'+height+'px;background:white;z-index:200;display:none" ></div><div style="width:'+width+'px;height:'+height+'px;"><img id="mload" style="position:relative;left:'+left+'px;top:'+topx+'px" src="/images/loading.gif" /><img id="mimg" style="cursor:pointer;display:none"  src="'+link+'" width="'+width+'" height="'+height+'" /></div>');
    msngr.setCloseOnClick(true);
    //alert(mimg);
    msngr.show();
    var mload=document.getElementById("mload");
    var mimg=document.getElementById("mimg");

    mimg.onload=function(){
    
      mload.style.display='none';
      mimg.style.display='block';
      SetOpacity(50);
    }
    mimg.src=link;
}*/
var imgGaleryX=false;
function imageX(link,width,height,listx,position){
    if(!msngr)return false;
    if(listx){
      eval("list="+listx+";");
    }else{
      list=[[link,width,height]];
      position=0;
    }
      if(!imgGaleryX)imgGaleryX=new imageGalery();
      
      imgGaleryX.setinit(list,position,true);
      imgGaleryX.init();
      msngr.show();
  /* }else{
    msngr.setWidth(width);
    left=Math.round(width/2-20);
    topx=Math.round(height/2-20);
    msngr.setText('<div id="cover" style="position:absolute;width:'+width+'px;height:'+height+'px;background:white;z-index:200;display:none" ></div><div style="width:'+width+'px;height:'+height+'px;"><img id="mload" style="position:relative;left:'+left+'px;top:'+topx+'px" src="/images/loading.gif" /><img id="mimg" onclick="msngr.close()" style="cursor:pointer;display:none"  src="'+link+'" width="'+width+'" height="'+height+'" /></div>');
    msngr.setCloseOnClick(!listx);
    msngr.show();
    var mload=document.getElementById("mload");
    var mimg=document.getElementById("mimg");

    mimg.onload=function(){
    
      mload.style.display='none';
      mimg.style.display='block';
      SetOpacity(50);
    }
    mimg.src=link;
    }*/
}

function SetOpacity(opacity){
       node=document.getElementById("cover");
       if(node){ 
       node.style.opacity = opacity/100;
	     node.style.filter = 'alpha(opacity=' + opacity + ')';
	     node.style.display='block';
       if(opacity>0) setTimeout("SetOpacity("+(opacity-3)+")",5)
       else node.style.display='none';
       }

}

function send_page_ajax(){
  from=document.getElementById('from_send_page').value;
  to=document.getElementById('to_send_page').value;
  tel=document.getElementById('tel_send_page').value;
  subject=document.getElementById('subjekt_send_page').value;
  mail=document.getElementById('mail_send_page').value;
  
  ajaxx = new ajax();
  param=[['from',from],['tel',tel],['to',to],['subject',subject],['mail',mail]];
  ajaxx.send("/ajax.send_mail.php",param,function(){
   if (xmlHttp.readyState==4){
   // alert(xmlHttp.responseText);
      var xmlDoc=xmlHttp.responseXML.documentElement;
      type=xmlDoc.getElementsByTagName("type")[0].childNodes[0];//.nodeValue;
      if(type&&type.nodeValue==0){
        message=xmlDoc.getElementsByTagName("message")[0].childNodes[0];//.nodeValue;
        if(message)alert(message.nodeValue);
      }else{
        message=xmlDoc.getElementsByTagName("message")[0].childNodes[0];//.nodeValue;
        if(message)alert(message.nodeValue);
        document.getElementById('from_send_page').value="";
        document.getElementById('tel_send_page').value="";
        document.getElementById('subjekt_send_page').value="";
        document.getElementById('mail_send_page').value="";      
      }
      
  }
  });
}

function send_order(type,user,mail){
  from=mail;
  to=mail;
  tel='';
  switch(type){
    case 1:
      subject='Žiadosť o rošírený profil';
      mail='Bola poddaná žiadosť o rozšírený profil uživateľom:'+user;
      confirmx='rošírený profil';
      break;
    case 2:
      subject='Žiadosť o baner';
      mail='Bola poddaná žiadosť o baner 150*90 pixelov uživateľom:'+user;
      confirmx='baner 150*90 pixelov';
      break;
    case 3:
      subject='Žiadosť o baner';
      mail='Bola poddaná žiadosť o baner 150*150 pixelov uživateľom:'+user;
      confirmx='baner 150*150 pixelov';
      break;
    case 4:
      subject='Žiadosť o baner';
      mail='Bola poddaná žiadosť o baner 150*180 pixelov uživateľom:'+user;
      confirmx='baner 150*180 pixelov';
      break;
    default: return false;
  }
  
  if(confirm('Objednaním tejto služby potvrdzujete že ste sa oboznámil s Všeobecnými obchodnými podmienkami spoločnosti PROJEKTANTI.SK, s.r.o. a v plnom rozsahu ku nim pristupujete.\n\nNaozaj si prajete objednať '+confirmx+'?\n')){
  ajaxx = new ajax();
  param=[['from',from],['tel',tel],['to',to],['subject',subject],['mail',mail]];
  ajaxx.send("/ajax.send_mail.php",param,function(){
   if (xmlHttp.readyState==4){
   // alert(xmlHttp.responseText);
      var xmlDoc=xmlHttp.responseXML.documentElement;
      type=xmlDoc.getElementsByTagName("type")[0].childNodes[0];//.nodeValue;
      if(type&&type.nodeValue==2){
        alert('Ďakujeme za Vašu objednávku. Do 24 hodín Vám budú na Váš e-mail uvedený v profile zaslané fakturačné údaje.');
      }else{
        alert('Nastala chyba pri odosielaní objednávky! Môžete nás kontaktovať na adrese:info@projektanti.sk');
      }
      
  }
  });
 }
}
/*
function send_page_ajax(){
  from=document.getElementById('from_send_page').value;
  to=document.getElementById('to_send_page').value;
  subject=document.getElementById('subjekt_send_page').value;
  mail=document.getElementById('mail_send_page').value;
  
  ajaxx = new ajax();
  param=[['from',from],['to',to],['subject',subject],['mail',mail]];
  ajaxx.send("/ajax.send_mail.php",param,function(){
   if (xmlHttp.readyState==4){
      var xmlDoc=xmlHttp.responseXML.documentElement;
      type=xmlDoc.getElementsByTagName("type")[0].childNodes[0];//.nodeValue;
      if(type&&type.nodeValue==0){
        message=xmlDoc.getElementsByTagName("message")[0].childNodes[0];//.nodeValue;
        if(message)alert(message.nodeValue);
      }else{
        message=xmlDoc.getElementsByTagName("message")[0].childNodes[0];//.nodeValue;
        if(message)alertX(message.nodeValue);      
      }
      
  }
  });
}*/