function OpenFaq(obj,ile)
{
	
	var el = document.getElementById('sub'+obj);
	//var el2 = document.getElementById('head'+obj);
   
  for (var i=0; i<ile; i++)
  {
   var el3 = document.getElementById('sub'+i);
  // var el4 = document.getElementById('head'+i);
	 el3.style.display = "none";
	 //el4.style.fontWeight= "normal";
	}
	
  if(el.style.display != "block")
  {
   el.style.display = "block";
  // el2.style.fontWeight= "bold";
  }
  else
  {
		el.style.display = "none";
	}
  

	
}

function alertit(){
alert("You moved your mouse over me!")
}

function alertalert()
{

if (document.forms.form1['reg'].value=='n')
{
document.forms.form1['reg'].value='y';
}
else
{
document.forms.form1['reg'].value='n';
}
}

function setCheckboxColumn(theCheckbox){
    if (document.getElementById(theCheckbox)) {
        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
        }
    } else {
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
            if (document.getElementById(theCheckbox)) {
                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
            }
        }
    }
} 


  function setCheckboxes(the_form, do_check)
  {
      var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                    ? document.forms[the_form].elements['selected_db[]']
                    : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
            ? document.forms[the_form].elements['selected_tbl[]']
            : document.forms[the_form].elements['selected_fld[]'];
      var elts_cnt  = (typeof(elts.length) != 'undefined')
                    ? elts.length
                    : 0;
  
      if (elts_cnt) {
          for (var i = 0; i < elts_cnt; i++) {
              elts[i].checked = do_check;
          } 
      } else {
          elts.checked        = do_check;
      } 
  
      return true;
  } 
  

 
var marked_row = new Array;
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }

    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;

        }
    }

    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            
        }
    }

    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } 

    if (newColor) {
        var c = null;

        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } 
        }

        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } 

    return true;
}
function validateSearch(formu,msg) 
{ 
   if (!formu.search.value) { 
        alert(msg); 
        document.formu.elements['search'].focus();
        return false; 
    } 
      else 
   { 
        return true; 
        } 
}


function confirmDel(msg)
{
input_box=confirm(msg);
if (input_box==true)
{
return true;
}
else
{
return false;
}
}

function validateLogin(form_login,msg) 
{ 
   if (!form_login.login.value) { 
        alert(msg); 
        document.form_login.elements['login'].focus();
        return false; 
    } 
    else if (!form_login.pass.value)
    {
            alert(msg); 
        document.form_login.elements['pass'].focus();
        return false; 
    }
      else 
   { 
        return true; 
        } 
}

function t(v,e,t) 
{ 
  if(!v.title||!document.createElement)return 
  t=document.createElement("div") 
  t.move=function(e) 
  { 
    e=e||event 
    t.style.left=e.clientX+10+(document.documentElement.scrollLeft||document.body.scrollLeft)+"px" 
    t.style.top=e.clientY+0+(document.documentElement.scrollTop||document.body.scrollTop)+"px" 
  } 
  t.hide=function(x) 
  { 
    v.title=t.innerHTML 
    if(x=document.getElementById("tooltip")) document.body.removeChild(x) 
  } 
  t.move(e); 
  t.id="tooltip" 
  t.innerHTML=v.title;v.title="" 
  document.body.appendChild(t) 
  v.onmouseout=t.hide 
  v.onmousemove=t.move 
}


function disableIt(obj)
{
	obj.disabled = true;

}

function enableIt(obj)
{
	obj.disabled = false;
}


	function ShowDiv($d)
	{
	document.getElementById($d).style.display = document.getElementById($d).style.display=='none' ? "block" : "none";
	}
	

	
	
	function selecturl(s)
{
	var gourl = s.options[s.selectedIndex].value;	
	window.gal.location.href = gourl;
}


var tax_rates = new Array();
tax_rates["0"] = 0;
tax_rates["22"] = 22;
tax_rates["7"] = 7;
tax_rates["3"] = 3;


function getTaxRate(id) {

var x='products_tax_class_id__'+id;

  var selected_value = document.forms.product[x].selectedIndex;
  var parameterVal = document.forms.product[x][selected_value].value;

  if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
    return tax_rates[parameterVal];
  } else {
    return 0;
  }
}

function updateGross(id) {
  var taxRate = getTaxRate(id);
  var grossValue = document.forms.product["products_price__"+id].value;

  if (taxRate > 0) {
    grossValue = grossValue * ((taxRate / 100) + 1);
  }

  document.forms.product["products_price_gross__"+id].value = grossValue;
}

function updateNet(id) {
  var taxRate = getTaxRate(id);
  var netValue = document.forms.product["products_price_gross__"+id].value;

  if (taxRate > 0) {
    netValue = netValue / ((taxRate / 100) + 1);
  }

  document.forms.product["products_price__"+id].value = netValue;
}

