function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function preloadImages() {
var BaseSite = "images/menu/";
	if (document.images) {
		index_over = newImage(BaseSite + "index-act.gif");
		overview_over = newImage(BaseSite + "overview-act.gif");
		features_over = newImage(BaseSite + "features-act.gif");
		download_over = newImage(BaseSite + "download-act.gif");
		order_over = newImage(BaseSite + "order-act.gif");
		contact_over = newImage(BaseSite + "contact-act.gif");
		forum_over = newImage(BaseSite + "forum-act.gif");
BaseSite = "images/";
		de_over = newImage(BaseSite + "de-act.gif");
		ru_over = newImage(BaseSite + "ru-act.gif");
		preloadFlag = true;
	}
}



function SetActiveMenu() {
preloadImages();	
sLocation = new String(unescape(document.location));
if (sLocation.lastIndexOf('/') < sLocation.lastIndexOf('.')) {
  sMenuName = new String(sLocation.substring(sLocation.lastIndexOf('/') + 1, sLocation.lastIndexOf('.')));
}
else
  sMenuName = new String('index');  
  for (var I=0; I<document.images.length; I++) {
    if (sMenuName == document.images[I].name) {
      document.images[I].src = 'images/menu/' + document.images[I].name + '-act.gif';
      break;
    }
  }
} 

function MouseToMenu(menuname, mouseout) {
sLocation = new String(unescape(document.location));
if (sLocation.indexOf(menuname.name + '.html') > 1) {
  return;
} 
   if (mouseout) 
     menuname.src = 'images/menu/' + menuname.name + '.gif';
   else
     menuname.src = 'images/menu/' + menuname.name + '-act.gif';
}

function MouseToLang(langname, mouseout) {
   if (mouseout) {
     langname.src = 'images/' + langname.name + '.gif';
     langname.height = 14;
   }  
   else {
     langname.src = 'images/' + langname.name + '-act.gif';
     langname.height = 19;
   }  
}

function ChangeDomain(newdomain) {
  sLocation = new String(unescape(document.location));
  if (sLocation.indexOf('://www.') == -1) {
  	sLocation = 'http://www.' + sLocation.substring(sLocation.indexOf('//') + 2, sLocation.length);
  }
  sDocument = new String(sLocation.substring(sLocation.lastIndexOf('/') + 1, sLocation.length));
  domainname = new String (sLocation.substring(sLocation.indexOf('.') + 1, sLocation.length));
  domainname = domainname.substring(0, domainname.indexOf('.'));
  /*if (newdomain =='de' )
    sLocation = '/mt/mt/mv.pl?friend=http://www.' + domainname + '.' + newdomain + '/';
  else*/
    sLocation = '/mt/mt/mv.pl?friend=http://www.' + domainname + '.' + newdomain + '/' + sDocument;
  window.location = sLocation;
}

function hideColumn (colIndex) {
  var table = document.all ? document.all.OrdersTable :
                 document.getElementById('OrdersTable');
  for (var r = 1; r < table.rows.length; r++) {
    if ((table.rows[r].cells.length > colIndex) && (table.rows[r].cells[colIndex].className == "Srv_ID")) {
      table.rows[r].cells[colIndex].style.display = 'none';
    }
  }  
}
function showColumn (colIndex) {
  var table = document.all ? document.all.OrdersTable :
              document.getElementById('OrdersTable');
  for (var r = 1; r < table.rows.length; r++)
    if ((table.rows[r].cells.length > colIndex) && (table.rows[r].cells[colIndex].className == "Srv_ID")) {
      table.rows[r].cells[colIndex].style.display = '';
    }  
}


function ModifyCartURLs(aclassName) {
  document.getElementById('ServiceID').value=aclassName;
  if (aclassName == 'Plimus') {
    hideColumn(2);
    showColumn(3);
  }
  else {
    showColumn(2);
    hideColumn(3);
  }

 }
 
 function increase(edit, step) {
   I = eval(edit.value);
   I = I + step;
   if (I < 0) I = 0;
   edit.value = I;
 }
 
 function checkout() {
   if ((document.getElementById('quantity1').value == 0) &&
     (document.getElementById('quantity2').value == 0) &&
     (document.getElementById('quantity3').value == 0) &&
     (document.getElementById('quantity4').value == 0)) {
     alert("Order quantity cannot be zero! Please enter a quantity of licenses.");
     return;
     }
   ShareItCart = "/mt/mt/mv.pl?sale=37&eventid=3&backlink=http%3A%2F%2Fwww.tsilang.com%2Forder.html";  
   PlimusCart = "/mt/mt/mv.pl?sale=38&eventid=3";
   //PlimusCart = "https://www.plimus.com/jsp/checkout.jsp?developerId=33873&submitAction=buynow";
   if (document.getElementById('ServiceID').value == "ShareIt") {
     Products = new Array("219000", "219001", "219003", "300115769");
     S = ShareItCart;
     for (I = 1; I < 5; I++)
       if (document.getElementById("quantity" + I).value != 0)
         S = S + "&PRODUCT[" + Products[I - 1] + "]=" + document.getElementById("quantity" + I).value;     
     document.location = S;
   }
   else {
     Products = new Array("1639816", "1646200", "1646215", "1671570");
     S = PlimusCart;
     K = 0;
     for (I = 1; I < 5; I++)
       if (document.getElementById('quantity' + I).value != 0) {
         K++;
         S = S + "&contractId" + K + "=" + Products[I - 1] + "&quantity" + K + "=" + document.getElementById('quantity' + I).value;     
       }  
     S = S + "&numberOfContracts=" + K;  
     document.location = S;
   }
 }


function getCoords (element) {
var coords = { x: 0, y: 0, width: element.offsetWidth, height: 
element.offsetHeight };
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop + 1;
if (!element.offsetParent) {
	coords.x -= element.scrollLeft;
	coords.y -= element.scrollTop;
}
element = element.offsetParent;
}
return coords;
}


function showSubmenu(index) {

  var coords = getCoords(document.getElementById("mi" + index));
  document.getElementById("sm" + index).style.left = coords.x + document.body.scrollLeft - 26 
  document.getElementById("sm" + index).style.top = coords.y + 10 + document.body.scrollTop 
  //document.getElementById("sm" + index).style.left = document.getElementById("mi" + index).getBoundingClientRect().left + document.body.scrollLeft - 26 
  //document.getElementById("sm" + index).style.top = document.getElementById("mi" + index).getBoundingClientRect().top + 10 + document.body.scrollTop 
  document.getElementById("sm" + index).style.visibility = "visible"
}
function hideSubmenu(index) {
  document.getElementById("sm" + index).style.visibility = "hidden"
}
