/* for pulldown (level 2) */
var current = '';
var menu_timer = null;
var menu_hide_timeout = 500;
var menu_show_timeout = 105;
var sdk_array = ['Elecard Codec SDK G4', 'Elecard Codec .NET SDK G4', 'Elecard Video Transform SDK']
var sdk_id_array = ['codec-sdk', 'codec-.net-sdk', 'video-transform-sdk']

if(!Array.in_array){
	Array.prototype.in_array = function(p_val) {
		for(var i = 0, l = this.length; i < l; i++) {
			if(this[i] == p_val) {
				return true;
			}
		}
		return false;
	}
}
if(!Array.indexOf){
    Array.prototype.indexOf = function(obj){
        for(var i=0; i<this.length; i++){
            if(this[i]==obj){
                return i;
            }
        }
        return -1;
    }
}

function pulldown_level2(id, show){
 if(menu_timer){ window.clearTimeout(menu_timer); }
 if(current.length>0 && show){
  tmp = document.getElementById(current);
  if(tmp){
   if(current == id){
    tmp.style.visibility = 'visible';
   }else{
    tmp.style.visibility = 'hidden';
    current = '';
   }
  }
 }
 if(!document.getElementById(id)){ return; }
 current = id;
 menu_timer = show?
  window.setTimeout("set_visibility('"+id+"', true)", menu_show_timeout):
  window.setTimeout("set_visibility('"+id+"', false)", menu_hide_timeout);
}

function set_visibility(id, show){
 document.getElementById(id).style.visibility = show?'visible':'hidden'; 
 if(!show && current==id){ current = ''; }  
}

/* for pulldown (level 3) */
var current_sub = '';
var menu_timer_sub = null;
var menu_hide_timeout_sub = 500;
var menu_show_timeout_sub = 105;

function pulldown_level3(id_sub, show_sub){
 if(menu_timer_sub){ window.clearTimeout(menu_timer_sub); }
 if(current_sub.length>0 && show_sub){
  tmp_sub = document.getElementById(current_sub);
  if (obj_sub = document.getElementById('level3_'+current_sub))
  {
  }
  else ;//alert('level3_'+current_sub);
  if(tmp_sub){
   if(current_sub == id_sub){
    tmp_sub.style.visibility = 'visible';
    obj_sub.className='active';
   }else{
    tmp_sub.style.visibility = 'hidden';
    obj_sub.className='';
    current_sub = '';
   }
  }
 }
 if(!document.getElementById(id_sub)){ return; }
 current_sub = id_sub;
 menu_timer_sub = show_sub?
  window.setTimeout("set_visibility_sub('"+id_sub+"', true)", menu_show_timeout_sub):
  window.setTimeout("set_visibility_sub('"+id_sub+"', false)", menu_hide_timeout_sub);
}

function set_visibility_sub(id_sub, show_sub){
 document.getElementById(id_sub).style.visibility = show_sub?'visible':'hidden'; 
 obj_sub = document.getElementById('level3_'+current_sub);
 if(!show_sub && current_sub==id_sub){ obj_sub.className=''; current_sub = ''; }  
}
// for roll-up menu
function turn_dir(id,pref){
 var subobj = document.getElementById(id);
 var prefobj = document.getElementById(pref);
 if(subobj.style.display=='none'){
   subobj.style.display = '';
   prefobj.className='dir_open';
 } else {
   subobj.style.display = 'none';  
   prefobj.className='dir_close';
 }
}
/* for popup windows */
function create_popup(locat){ 
  var win = window.open(locat,"popup","width=300, height=165, toolbar=no, location=no, scrollbars=no, menubar=no, status=no, resizable=no"); 
  win.focus();
}

function TempDownloadLink(type) {
	if (type == 'SDK')
	{
	  popupWin = window.open("/products/products-pc/sdk/temp_info.php", 'decoder_capabilities', 'scrollbars,width=400,height=250,top=0'); 
	  popupWin.focus(); 
  	}
	if (type == 'consumer')
	{
	  popupWin = window.open("/products/products-pc/consumer/temp_info.php", 'decoder_capabilities', 'scrollbars,width=400,height=250,top=0'); 
	  popupWin.focus(); 
	}
}

/* for masking e-mail */
function amg(n,s1,s2,s3)
{
		
        if(n == 0){
	  if (s3!=''){
	    s4='?subject='+s3
	  }
	  else{
	    s4='' 
	  }
	  document.location = 'mailto:'+s1+'@'+s2+s4;
	}
}

/* for cart */
function checkCartSize(v, min, max, name) {
	var try_agre = 0;
	var dialog_txt = new Array(2);
	dialog_txt['eng'] = new Array();
	dialog_txt['rus'] = new Array();
	vv = parseInt(v);
	if (isNaN(vv) || vv < min || vv > max) {
		alert('No more than 99 999 licenses of ' + name + ' can be purchased at a time.');
		return false;
	}
	return true;
}
function onlyNumbers(e)
{
var keynum
var keychar
var numcheck

if(window.event) // IE
{
	keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
	keynum = e.which
}
if (!keynum || keynum == 8) {
	return true;
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return numcheck.test(keychar)
}	

var doChangeImage = true;

function ChangeImage(id,MouseStatus) {
if (doChangeImage){
  if (MouseStatus == 'Out') 
    id.src = "/img/shop/add1.gif"
  if (MouseStatus == 'Over') 
    id.src = "/img/shop/add2.gif"
  if (MouseStatus == ' ') 
    id.src = "/img/shop/add3.gif"
}
}

