var m_id=[0];
var m_ind=[0];
var timer_id=null;
var MenuTimeOut=500;

var font_color = "#000000";
var background_color = "#B75429";
var hover_font_color = "#FFFFFF";
var hover_background_color = "#B75429";

function load()
   {
   	;
   }

function trim(str)
{ var start_pos=0;
  var end_pos=str.length;
  
  for(start_pos=0;start_pos<end_pos;start_pos++)
    if(str.charAt(start_pos)!=' ') break;
 
 
  for(end_pos=end_pos-1;end_pos>0;end_pos--)
    if(str.charAt(end_pos)!=' ') break;
  
  if((start_pos==str.length)&&(end_pos==0)) return "";
  
  return str.substring(start_pos, end_pos+1);
}   

function validate_email(email)
{ var reg = new RegExp("[0-9a-z_]+@[0-9a-z_^.]+\\.[a-z]", 'i');
  if (!reg.test(email)) return false;
  return true;
}
   
function validate_form(form)
{ var mess="";
  if(!trim(form.name.value)) mess+="The Name is empty.\n";
  if(!validate_email(trim(form.email.value))) mess+="The E-Mail is not valid.\n";
  if(!trim(form.comments.value)) mess+="The Inquiry is empty.\n";
  if(mess=='') return true;
  alert(mess);
  return false;
} 
   
function viewImg(imgId, imgWidth, imgHeight){
	  imgHeight=imgHeight+100;
	  imgWidth=imgWidth+100;
      var xstr = 'scrollbars=no,toolbar=no,status=no,menubar=no,directories=no,location=no,resizable=yes,width='+imgWidth+',height='+imgHeight;
      pageName = 'view_img.php?id='+imgId;
      var prodWindow = window.open(pageName, 'window'+Math.round(Math.random()*1000), xstr);
      if (prodWindow) prodWindow.focus();
}

function backToSite(){
	var prodWindow = window.opener;
	if (prodWindow){
		prodWindow.focus();
		window.close();
	}
}
   
function set_underline_light(elem)
{ document.getElementById('subm_'+elem).style.borderColor="#B4D39B";
}

function reset_underline_light(elem)
{ //alert("reset"); 
  document.getElementById('subm_'+elem).style.borderColor="#4a4a4a";
}
   
function cc(w, h)
   {
      var ktop=(screen.availHeight-h)/2;
      var kleft=(screen.availWidth-w)/2;
      return 'top='+ktop+',left='+kleft+',width='+w+',height='+h;
   }
   
function strDelete(str, i0, i1, s)
   {
      return str.substring(0, i0)+s+str.substring(i1+1);
   }

   
function implodeParam(str, param)
   {
      var i=0;
      var val;
      while (i>=0 && i<param.length)
      {
         var e=param.indexOf('=', i);
         if (e==-1) break;
         name=param.substr(i, e-i);
         i=e+1;
         e=param.indexOf(',', i);
         if (e==-1) val=param.substr(i); else val=param.substr(i, e-i);
         var dpi=0;
         do 
         {
            dpi=str.indexOf(name+'=', dpi);
            if ((dpi==0) || ((dpi>0) && (str.substr(dpi-1,1)==','))) break;
            if (dpi>0) dpi++;
         } while (dpi!=-1);
         if (dpi==-1) str = str + ','+name+'='+val;
         else
         {
            dpi+=name.length+1;
            dpe=str.indexOf(',', dpi);
            if (dpe==-1) dpe=str.length;
            str=strDelete(str, dpi, dpe-1, val);
         }
         i=e;
         if (i==-1) break;
         i++;
      }
      return str;
   }

function newWindowA(pageName, p)
   { 
      var str = implodeParam('scrollbars=yes,toolbar=no,status=no,menubar=no,directories=no,location=no,resizable=yes,width=600,height=420', p);
      var prodWindow = window.open(pageName, 'window'+Math.round(Math.random()*1000), str);
      if (prodWindow) prodWindow.focus();
   }

function set_over(id) {
 
}

function setImgOffExceptingOne(id) {
  
}

function reset_over(id) { 
 if (document.getElementById('h'+id).src){
   document.getElementById('h'+id).src = help_image;
 }
 else{
  
 }
}

function set_img(id, img){
  var imgObj = document.getElementById(id);
  if (imgObj != null) {
    imgObj.src = img;
  }
  
}

function m_over(m_id1,m_id2)
{
    m_rtimer();
	 
    if (m_ind[m_id1]!=null)
        hide_ms(m_ind[m_id1]+1);

    if (m_id2!=0) {
      m_visibility(m_id2,'visible');
      m_ind[m_id2]=m_id.length;
      m_id[m_id.length]=m_id2;
    }
    
}

function m_out() {
 
    if (timer_id!=null) {
      return;
    }
    if (m_id.length==1) {
      return;
    }

    timer_id=setTimeout('m_hide()',MenuTimeOut);        
}

function m_in()
{
    m_rtimer();
}

function m_hide() {
  
  if (m_id.length>2) {
    hide_ms(m_id.length-1);
    timer_id=setTimeout('m_hide()',MenuTimeOut);
  }
  else {
    hide_ms(1);
    timer_id=null;
  }
}

function hide_ms(i) {
  var j;
  
  for(j=m_id.length-1;j>=i;j--) {
    m_ind[m_id[j]]=null;
    m_visibility(m_id[j],'hidden');
    reset_over(m_id[j]);
  }    
  m_id.length=i;
}

function m_visibility(id,visibility)
{
    if (document.getElementById)
	document.getElementById('menu'+id).style.visibility=visibility;
    else
        document.all['dropmenu'+id].style.visibility=visibility;
}

function m_rtimer()
{
    if (timer_id!=null)
    {
	clearTimeout(timer_id);
	timer_id=null;
    }
}

function m_do_hide()
{
    m_rtimer();
    m_hide();
}

function set_position(obj,submenu_id)
{ var o=obj; 
  var x=0, y=0; 
  while(o)
  { x+=o.offsetLeft; 
    y+=o.offsetTop; 
    o=o.offsetParent; 
  }
  
  submenuWidth=document.getElementById(submenu_id).offsetWidth;
  menuWidth=obj.offsetWidth;
  widthDiv=menuWidth-submenuWidth;
  
  document.getElementById(submenu_id).style.left=(x+widthDiv/2)+"px";
  document.getElementById(submenu_id).style.top=(y+34)+"px";
}

document.onclick=m_do_hide;
