
var screenW = 800, screenH = 600;

if (parseInt(navigator.appVersion)>3) {
 screenW = screen.width;
 screenH = screen.height;
}else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ){
 screenW = screen.availWidth;
 screenH = screen.availHeight;
}else{
 screenW = screen.width;
 screenH = screen.height;
}


var lastClicked = "proc.php";
var marked_row = new Array;

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 



function swapClass(obj, cls) {
		obj.className = cls
}

function swapClassTab(obj, cls) {
	if(obj.className != "treeOn")
		obj.className = cls
}

function swapClassClick(obj, cls) {
	var tds = menu.document.getElementsByTagName('td');
	if(obj.className != "treeOn"){
		for (var i=0;i<tds.length;i++){
			if (tds[i].id.indexOf("treeOption") == 0)
				tds[i].className="treeOff";
		}
		obj.className = cls
	}
}
	
	function ToggleVisible(obj){
    	if(document.getElementById){
    	var el = document.getElementById(obj);
    	var x = document.getElementsByTagName('div');
    		if(el.style.display != "block"){
    			el.style.display = "block";
    		}else{
    			el.style.display = "none";
    		}
    	}
    }

    function ToggleVisibleAll(obj,visible){
    	if(document.getElementById){
			var x = document.getElementsByTagName('div');
			for (var i=0;i<x.length;i++){
				if (x[i].id.indexOf(obj) == 0){
//		    		if(x[i].style.display != "block"){
			   			x[i].style.display = visible;
//					}else{
//		    			x[i].style.display = "none";
//		    		}
	    		}
	    	}
		}
    }


function changeToLoc(loc,target,save){
//		alert(loc);
		if(save==true)
			lastClicked = loc;
		parent[target].document.location.replace(loc)
//		parent.document.getElementById('contentsMain').innerHTML=loc;
		return false;
}

function loadXML(xmlFile) 
{ 
 xmlDoc.async="false"; 
 xmlDoc.onreadystatechange=verify; 
 xmlDoc.load(xmlFile); 
INFO=xmlDoc.documentElement; 
}

function verify() 
{ 
 // 0 Object is not initialized 
 // 1 Loading object is loading data 
 // 2 Loaded object has loaded data 
 // 3 Data from object can be worked with 
 // 4 Object completely initialized 
 if (xmlDoc.readyState != 4) 
 { 
   return false; 
 } 
}

function setInfo() { 
var login = parent.parent.document.getElementById("login");
var countRFQs = parent.parent.document.getElementById("countRFQs");
var countOffers = parent.parent.document.getElementById("countOffers");
var countPOs = parent.parent.document.getElementById("countPOs");
var countBIDs = parent.parent.document.getElementById("countBIDs");
var vendorname = parent.parent.document.getElementById("vendorname");
var active = parent.parent.document.getElementById("active");
	countRFQs.innerHTML = INFO.childNodes(0).firstChild.text;
	countOffers.innerHTML = INFO.childNodes(1).firstChild.text;
	countPOs.innerHTML = INFO.childNodes(2).firstChild.text;
	countBIDs.innerHTML = INFO.childNodes(3).firstChild.text;
	if(INFO.childNodes(0).firstChild.text > 0){
		countRFQs.className="bOutNEW";
	}else{
		countRFQs.className="bOut";
	}
	if(INFO.childNodes(1).firstChild.text > 0){
		countOffers.className="bOutNEW";
	}else{
		countOffers.className="bOut";
	}
	if(INFO.childNodes(2).firstChild.text > 0){
		countPOs.className="bOutNEW";
	}else{
		countPOs.className="bOut";
	}
	if(INFO.childNodes(3).firstChild.text > 0){
		countBIDs.className="bOutNEW";
	}else{
		countBIDs.className="bOut";
	}
	if(INFO.childNodes(4).hasChildNodes()){
		vendorname.innerHTML = "<span class=\"companyNameMenu\">&nbsp;&nbsp;"+INFO.childNodes(4).firstChild.text+"&nbsp;&nbsp;</span>";
	}
	login.innerHTML = INFO.childNodes(5).firstChild.text;
	active.innerHTML  = INFO.childNodes(6).firstChild.text;
} 

function displayInfo(){
	loadXML('/xml.php?action=display_info_menu'); 
	setInfo();
	setTimeout("displayInfo()",5000); 
}

function clearInfo(){

document.all.vendorname.innerHTML='';
document.all.countRFQs.innerHTML='0';
document.all.countOffers.innerHTML='0';
document.all.countPOs.innerHTML='0';
document.all.countBIDs.innerHTML='0';
countRFQs.className="bOut";
countOffers.className="bOut";
countPOs.className="bOut";
countBIDs.className="bOut";
this.innerHTML='Login';

}


function changeSelectOption(theForm,Obj,Opt,Msg){
	//formObject, Name of the select box, Option to change to, Alert message
	var els = theForm.elements; 
	for (var i=0, j=els.length; i<j; i++) {
		myName = els[i].name;
		if (myName.indexOf(Obj) == 0){
			theForm[myName].options[Opt].selected = true;
		}
	}
	alert(Msg);
}



function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor,CheckBoxName,theForm)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }


    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    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;
        }
    }
    // 4.1.3 Current color is the marker one
    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;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5
	if(typeof(theForm[CheckBoxName]) != "undefined"){
		if(theForm[CheckBoxName].checked == true)
			theForm[CheckBoxName].checked = false;
		else
			theForm[CheckBoxName].checked = true;
	}

    return true;
} // end of the 'setPointer()' function
