var Netscape4 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var Explorer4 = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");

var doPopUpX=(screen.width/2)-300;
var doPopUpY=(screen.height/2)-225;
var pos="left="+doPopUpX+",top="+doPopUpY;
function doPopUp(myurl)
{
  doPopUpWindow=window.open(myurl,"damlong","width=600,height=450,"+pos);
}

function doLogin(){
doPopUpWindow = window.open("login.htm","damlong","width=300,height=225,"+pos);
}



document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

//---------------------------------------------------------------------------------------
//INICIO GESTION MENU
//---------------------------------------------------------------------------------------
var global = window.document
var MENU_BORDER_COLOR = '#000000'
var MENU_CURRENTPAGE_COLOR = '#d6e7ef'
var MENU_MOUSEOVER_COLOR = '#336699'
// '#4682B4'
var MENU_MOUSEDOWN_COLOR = '#d6e7ef'
var errfound = false;

function normalized_href(href)
{
	href = href.toLowerCase();
	var slash = href.lastIndexOf("/");
	if (-1 != slash) 
	{
		var filename = href.substr(slash + 1);
		if ("default.htm" == filename || "default.asp" == filename)
			href = href.substr(0, slash + 1);
	}
	return href;
}

function event_onload(mymsg)
{
    if (mymsg!="") {
      alert(mymsg);
    }
	if (!global.all) return
	
	var items = global.all.tags("td")
	var i	
	var lhref = normalized_href(location.href)

	for (i=0; i<items.length; i++)
	{
		var item = items[i]

		if (item.className == "tdnav")
		{
			var disabled = false
			var anchors = item.all.tags("A")			

			if (anchors.length > 0)
			{
				var anchor = anchors.item(0)
				var ahref = normalized_href(anchor.href)				
//alert(ahref)
//alert(ahref.substring(ahref.length-3,ahref.length))
//alert(lhref)
//alert(lhref.substring(0,ahref.length))
				if (ahref == lhref.substring(0,ahref.length) && ahref.substring(ahref.length-3,ahref.length)=="asp")
				{
					anchor.outerHTML = anchor.innerHTML
					item.style.borderColor = MENU_BORDER_COLOR
					item.style.backgroundColor = MENU_CURRENTPAGE_COLOR
					item.style.color = "#000000"
					item.style.cursor = 'default'
					item.height="20"
					disabled = true					
				}				
			}
			item.defaultBorder = item.style.borderColor
			item.defaultBackground = item.style.backgroundColor
			item.attachEvent("onmouseover", item_onmouseover)
			item.attachEvent("onmouseout", item_onmouseout)
			if (!disabled)
			{
				item.attachEvent("onmousedown", item_onmousedown)
				item.attachEvent("onmouseup", item_onmouseup)
			}			
		}
	}	
}

function item_onmouseover()
{	

	var e = whichItem()
	if (e.contains(window.event.fromElement))
		return
	if (e.style.backgroundColor != MENU_CURRENTPAGE_COLOR)
	{		
	var items = global.all.tags("TD")

		e.style.borderColor = MENU_BORDER_COLOR
		e.style.backgroundColor = MENU_MOUSEOVER_COLOR
 	}	
	var a = e.all.tags("A")
	if (a.length > 0)
		window.status = a[0].href
}

function item_onmouseout()
{	
	var e = whichItem()
	var te = window.event.toElement
	if (te)
		if (e.contains(te))
			return
	e.style.borderColor = e.defaultBorder
	e.style.backgroundColor = e.defaultBackground
	window.status = ""
}

function whichItem()
{
	var e = event.srcElement
	while (e.tagName != "TD")
		e = e.parentElement
	return e
}

function item_onmousedown()
{	
	if ((event.button & 1) == 0)
		return;
	var e = whichItem()
	e.style.backgroundColor = MENU_MOUSEDOWN_COLOR
	e.mouseIsDown = 1
}

function item_onmouseup()
{	
	if ((event.button & 1) == 0)
		return;
	var e = whichItem()
	if (e.mouseIsDown != 1)
		return
	e.mouseIsDown = false
	e.style.backgroundColor = MENU_MOUSEOVER_COLOR
	var a = e.all.tags("A")
	if (a.length > 0)
		top.location.href = a[0].href
}
function error1(elem, text) {
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}

function error2(elem, text) {
   if (errfound) return;
   window.alert(text);
   errfound = true;
}
//---------------------------------------------------------------------------------------
//FIM GESTION MENU
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//Desabilia boptn derecho
//---------------------------------------------------------------------------------------
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}


//---------------------------------------------------------------------------------------
function buscar(aForm){

  if (aForm.Mark.value == ""){
     alert('Por favor, ingrese una marca.');
     aForm.Mark.focus();
	 return false;
   }

  url = "pidebus.asp?Mark=" + aForm.Mark.value;
  openWin(url);
}
function openWin(remoteWin) {
        remoteWin = window.open( remoteWin, "links", "width=640,height=370,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=No");
}
function openWinScroll(remoteWin) {
        remoteWin = window.open( remoteWin, "links", "width=640,height=400,toolbar=no,resizable=no,location=no,menubar=no,scrollbars=Yes");
}

//---------------------------------------------------------------------------------------
function PopUpMax(url){
windowprops = "top=0,left=0,resizable=yes,width=" + screen.width + ",height=" + screen.height;
window.open(url, "Damlong", windowprops);
}

