/// --- dreamweaver codes --- /////////////////////////////////////////////////////////////////
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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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 popup(a,msg,look,x,y){ //v1.0.4
  var d=document; if (!a){var ln='pLayer';dx="";dy="";b=(d.layers)?1:0;
    nn=(b||d.getElementById &&!d.all)?1:0;l = new Object();
    l.s=b?d.layers[ln]:MM_findObj(ln).style;l.r=b?d.layers[ln].document:MM_findObj(ln);
    l.w=function (t) {if(b){l.r.write(t);l.r.close()}else l.r.innerHTML=t}
  if(b) d.captureEvents(Event.MOUSEMOVE);d.onmousemove=function(e)
  {dx=(nn)?e.pageX:event.x;dy=(nn)?e.pageY:event.y;}}if (a=='1') {l.s.visibility='hidden'}
  if (a=='2') {l.w('<span class="'+look+'">'+unescape(msg)+'</span>')
  if(d.all) dy=dy+d.body.scrollTop;x=(!x)?50:Number(x);
  y=(!y)?-20:Number(y);l.s.left=dx+x; l.s.top=dy+y;l.s.visibility='visible'}
}
/// --- web page functions --- ////////////////////////////////////////////////////////////////
function setValuesAndSubmit()
{  
  var arg=0;
  formName = setValuesAndSubmit.arguments[arg++]; 
  for(var i=arg; i<setValuesAndSubmit.arguments.length; i+=2) {
//    alert('document.' + formName + '.' + setValuesAndSubmit.arguments[i] + '.value="' + setValuesAndSubmit.arguments[i+1] + '"');
    eval('document.' + formName + '.' + setValuesAndSubmit.arguments[i] + '.value="' + setValuesAndSubmit.arguments[i+1] + '"');
  }
  eval('document.' + formName + '.submit()');
}

function setValues()
{  
  var arg=0;
  formName = setValues.arguments[arg++]; 
  for(var i=arg; i<setValues.arguments.length; i+=2) {
//    alert('document.' + formName + '.' + setValuesAndSubmit.arguments[i] + '.value="' + setValuesAndSubmit.arguments[i+1] + '"');
    eval('document.' + formName + '.' + setValues.arguments[i] + '.value="' + setValues.arguments[i+1] + '"');
  }
//  eval('document.' + formName + '.submit()');
}

function deletes(text, form, variab, value)
{
  if( confirm(text) ) {
  	setValuesAndSubmit(form, variab, value);
  }
}

/// --- email functions --- ///////////////////////////////////////////////////////////////////
function checkall(allbox)
// in the emails form makes checkboxex checked or unchecked. depends on allbox checkbox
{
  var checkstatus;
  if(allbox.checked)
    checkstatus = true;
  else
    checkstatus = false;
  for(var i=0; i<emailerform.elements.length; i++) {  
    var elem = emailerform.elements[i];
    if((elem.name!='allbox') && (elem.type=='checkbox')) {
      elem.checked = checkstatus;
    }
  }
}

function checkit()
// in the emails form checks all checkboxes. than change status on allbox checkbox
{
  var countall=0;
  var countchecked=0;
  for(var i=0; i<emailerform.elements.length; i++) {  
    var elem = emailerform.elements[i];
    if((elem.name!='allbox') && (elem.type=='checkbox') && (elem.value)){
      countall++;
      if(elem.checked)
        countchecked++;
    }
  }
  if(countall==countchecked)
    emailerform.allbox.checked=true;
  else
    emailerform.allbox.checked=false;
}

function countrec()
// counts selected checkboxes or hidden fields (all together are indexes of email recipients)
{
  var count=0;
  for(var i=0; i<emailerform.elements.length; i++) {  
    var elem = emailerform.elements[i];
    if((elem.name!='allbox') && (elem.type=='checkbox') && (elem.value) && (elem.checked))
      count++;
    if((elem.type=='hidden') && (elem.name=='sendmailArr[]'))
      count++;
  }
  return count;
}
function showrec()
{
    window.open("emails_show_rec.php","emails",'status, toolbar=0,location=0,scrollbars=1,width=500,height=200,resizable=0,top=100,left=100');
    window.parent.name="dev";
}
function showrechistory(id)
{
    window.open("emails_rec_history.php?idem="+id,"emailer",'status=0, toolbar=0,location=0,scrollbars=1,width=500,height=200,resizable=0,top=100,left=100');
    window.parent.name="dev";
}



/// --- file upload functions --- ///////////////////////////////////////////////////////////////////
function fileupload(file) {
  url="upload_file.php?type="+file;
  window.open(url,"newfile",'status=0, toolbar=0,location=0,scrollbars=0,width=400,height=200,resizable=1,top=10,left=10');
  window.parent.name="files";
}

function choosevideo() {
  url = "choose_video.php";
  window.open(url,"newfile",'status=0, toolbar=0,location=0,scrollbars=0,width=400,height=200,resizable=1,top=10,left=10');
  window.parent.name="files";
}

/// --- popup window (web) --- /////////////////////////////////////////////////////////////////////////////
function popupwin(file, type, lang)
{
  switch(type) {
    case'video':
      window.open("popup.php?idph=" + file + "&lang=" + lang, "newfile",'status=0, screenX=10, screenY=10, toolbar=0, location=0, scrollbars=1, width=400, height=200, resizable=0');
      break;    
    case'image':
      window.open("image_products2.php?image=" + file, "newfile",'status=0, screenX=10, screenY=10, toolbar=0, location=0, scrollbars=0, width=300, height=300, resizable=0');
      break;    
    case'optipen':
      window.open("popup_optipen.php?image=" + file, "newfile",'status=0, screenX=10, screenY=10, toolbar=0, location=0, scrollbars=0, width=500, height=370, resizable=0');
      break;    
  }
}

function openW(urlW, width_w, height_w, scroll_bar, name){
  center_x = Math.round((window.screen.availWidth - width_w) / 2);
  center_y = Math.round((window.screen.availHeight - height_w) / 2);
  
  window.open(urlW,name,'top=' + center_y + ',left=' + center_x + ',width=' + width_w + ',height=' + height_w + ',status=no,titlebar=no,toolbar=no,menubar=no,location=no,resizable=no,directories=no,scrollbars=' + scroll_bar);
} 
function popupImage(urlW, width_w, height_w, scroll_bar, name){
  center_x = Math.round((window.screen.availWidth - width_w) / 2);
  center_y = Math.round((window.screen.availHeight - height_w) / 2);
  
  window.open('popup_image.php?file='+urlW,name,'top=' + center_y + ',left=' + center_x + ',width=' + width_w + ',height=' + height_w + ',status=no,titlebar=no,toolbar=no,menubar=no,location=no,resizable=no,directories=no,scrollbars=' + scroll_bar);
} 

function open_map(id) 
{ 
  mapWindow = window.open("http://www.supernavigator.sk/clients/mapa.php?firmID=" + id + "&ref=http://dev.soyamedia.com","mapa","toolbar=0,location=0,scrollbars=0,width=492,height=416,resizable=no").focus(); 
  return false; 
}
function writeFlash(bannerfile, width, height, hlink, imagetop, hspace, vspace) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width +'" height="' + height +'" id="wus_pictures" align="right">');
  document.write('<param name="allowScriptAccess" value="sameDomain" />');
  document.write('<param name="movie" value="' + bannerfile + '?' + hlink + '" />');
  document.write('<param name="menu" value="false" />');
  document.write('<param name="quality" value="high" />');
  document.write('<param name="bgcolor" value="#ffffff" />');
  document.write('<param name="wmode" value="transparent">');
  document.write('<embed src="' + bannerfile + '?' + hlink +'" menu="false" quality="high" bgcolor="#ffffff" width="' + width +'" height="' + height +'" name="wus_pictures" align="right" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />');
  //document.write('<img src="' + imagetop + '" hspace="' + vspace + '" vspace="' + vspace + '" style="z-index:-100px;"/>');
  document.write('</object>');
}
