<!--

function targetLink(link) {
  var url = (link.getAttribute) ? link.getAttribute('href') : link.href;
  
  if (!url) return true;
  
  targetWin=open(url,"popup1","width=550,height=400,scrollbars=yes,resizable=yes");
  
  if (targetWin) {
    targetWin.resizeTo(550,400);
    targetWin.focus();
    return false;
  }
  
  return true;
}

function targetLink2(link) {
  var url = (link.getAttribute) ? link.getAttribute('href') : link.href;
  
  if (!url) return true;
  
  targetWin=open(url,"popup2","width=320,height=24,scrollbars=yes,resizable=yes");
  
  if (targetWin) {
    targetWin.resizeTo(320,240);
    targetWin.focus();
    return false;
  }
  
  return true;
}

function targetLink3(link) {
  var url = (link.getAttribute) ? link.getAttribute('href') : link.href;
  
  if (!url) return true;
  
  targetWin=open(url,"popup3","width=840,height=500,scrollbars=yes,resizable=yes");
  
  if (targetWin) {
    targetWin.resizeTo(840,500);
    targetWin.focus();
    return false;
  }
  
  return true;
}

function targetLinkPayment(link) {
  var url = (link.getAttribute) ? link.getAttribute('href') : link.href;
  if (!url) return true;
  targetWin=open(url,"popupLinkPayment","width=840,height=760,scrollbars=yes,resizable=yes");
  
  if (targetWin) {
    targetWin.resizeTo(840,760);
    targetWin.focus();
    return false;
  }
  
  return true;
}

function targetPresse(url) {
  targetWin=open(url,"popup4","width=640,height=480,scrollbars=yes,resizable=yes,menubar");
  targetWin.resizeTo(640,480);
  targetWin.focus();
}

function targetPopup(url) {
  opener.open(url,"popup1","width=550,height=400,scrollbars");
}

var global=0;
var flag=0;

/**
 * Checks or unchecks all checkboxes with the given name depending 
 * on the checked status of the triggering checkbox.
 * @param formId the id of the form that contains the checkboxes.
 * @param checkboxName the name of the checkboxes that should be checked.
 * @param checkallBox the checkbox object that triggered this method.
 */
 
function checkAll(formId, checkboxName, checkAllBox) {
  var form = $(formId);
  var checkboxes = form.getInputs('checkbox', checkboxName);
  var checked = $(checkAllBox).checked;
  
  for (i = 0, n = checkboxes.length; i < n; i++) {
    checkboxes[i].checked = checked;
  }
  
}

function uncheckCheckAllBox(checkbox, checkAllBox) {
  
  if (!checkbox.checked)
    $(checkAllBox).checked = false;
    
}

function toggle(formId, checkboxClassName) {

  if (global == 0)
    global = 1;
  else 
    global = 0;
  
  checkAll(document.getElementById(formId), checkboxClassName, global);
}

function aToggle(formId, checkboxClassName) {
  checkStatus(document.getElementById(formId), checkboxClassName);
  
   if(flag == 0) {
     document.getElementById(formId).checkall.checked=false;
     global = 0;
   }
   else {
     document.getElementById(formId).checkall.checked=true;
     global = 1;
   }

}

function checkStatus(form, cName) {

   for (i = 0, n = form.elements.length; i < n; i++) {
     
     if (form.elements[i].className.indexOf(cName) !=-1) {
       
       if(form.elements[i].checked == true) {
         flag=1;
       }
       else {
         flag=0;
         return;
       }
       
     }
   
  }  
                
}

function dynamicSelect(id1, id2) {
	// Browser and feature tests to see if there is enough W3C DOM support
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);

	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		// Obtain references to both select boxes
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		// Clone the dynamic select box
		var clone = sel2.cloneNode(true);
		// Obtain references to all cloned options 
		var clonedOptions = clone.getElementsByTagName("option");
		// Onload init: call a generic function to display the related options in the dynamic select box
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		// Onchange of the main select box: call a generic function to display the related options in the dynamic select box
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
		
	}
	
}

function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	// Delete all options of the dynamic select box
	while (sel2.options.length) {
		sel2.remove(0);
	}
	
	// Create regular expression objects for "select" and the value of the selected option of the main select box as class names
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	
	// Iterate through all cloned options
	for (var i = 0; i < clonedOptions.length; i++) {
		// If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			// Clone the option from the hidden option pool and append it to the dynamic select box
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
		
	}
	
}

function pageOverlayShow() {
    $('pageOverlayActionBox').hide();
    
    var wrapperHeight = $('wxlPageWrapper').getHeight();
    var clientHeight = document.viewport.getHeight();
    
    $('pageOverlay').setStyle({
      top: '0px',
      left: '0px',
      width: '100%',
      height: ((wrapperHeight >= clientHeight) ? wrapperHeight : clientHeight) + 'px',
      visibility:'visible'
    });
    
  }
  
  var pageOverlayActionBoxPositioned = false;
  
  function pageOverlayHide() {
    $('pageOverlay').setStyle({
      visibility:'hidden'
    });
    
    pageOverlayActionBoxPositioned = false;
  }
  
  var mainContainerName = 'wxlMasterTable';
  
  function positionPageOverlayActionBox() {
  
    if (!pageOverlayActionBoxPositioned) {
      var viewportOffset = document.viewport.getScrollOffsets();
      var viewportDimensions = document.viewport.getDimensions();
      var pageOverlayActionBoxDimensions = $('pageOverlayActionBox').getDimensions();
      var pageOverlayActionBoxTop = 0;
      
      if ($('wxlPageWrapper').getHeight() < viewportDimensions.height)
        pageOverlayActionBoxTop = $('wxlPageWrapper').getHeight() / 2 - pageOverlayActionBoxDimensions.height / 2;
      else
        pageOverlayActionBoxTop = viewportOffset.top + viewportDimensions.height / 2 - pageOverlayActionBoxDimensions.height / 2;
      
      if (pageOverlayActionBoxTop < 0)
        pageOverlayActionBoxTop = 10;
      
      var pageOverlayActionBoxLeft = 0;

      if ($(mainContainerName).getWidth() > viewportDimensions.width)
        pageOverlayActionBoxLeft = viewportOffset.left + viewportDimensions.width / 2 - pageOverlayActionBoxDimensions.width / 2;
      else
        pageOverlayActionBoxLeft = $(mainContainerName).getWidth() / 2 - pageOverlayActionBoxDimensions.width / 2;
        
      if (pageOverlayActionBoxLeft < 0)
        pageOverlayActionBoxLeft = 10;
      
      $('pageOverlayActionBox').setStyle({
        top: pageOverlayActionBoxTop + 'px',
        left: pageOverlayActionBoxLeft + 'px'
      });
    }
      
    $('pageOverlayActionBox').show();
    pageOverlayActionBoxPositioned = true;
  }
  
   

  /**
   * shows or hides the shortdescription with the given id.
   */
 
  function toggleDescription(trId, descriptionId, colorActive, colorInActive) {
    $(descriptionId).toggle();
    
    if($(descriptionId).visible()) {
      $(trId).setStyle({'background': colorActive});
    }
    else {
      $(trId).setStyle({'background': colorInActive});
    }
    
  }
  

  /**
   * set the bgcolor of the given given element
   */

  function setListRowColor(trId, color) {
      $(trId).setStyle({'background': color});
  }
  

  /**
   * reset the bgcolor of the given given element
   */

  function resetListRowColor(trId, decriptionId, color) {
	
	currentRfqId = trId.slice(3, trId.indexOf('c'));
	if(typeof(rfqIdChildrenList) != "undefined") {
		 for (var i = 0, len = rfqIdChildrenList.length; i < len; i++) {
		 	 if(rfqIdChildrenList[i] == currentRfqId){
		 	 	color="#cee2ec";
		 	 }
		 }
	}
	
    if($(decriptionId) && $(decriptionId).visible() == false) {
      $(trId).setStyle({'background': color});
    }
  }

  function resetListRowColorAccount(trId, color) {
 		$(trId).setStyle({'background': color});
  }
 
  function popupBack(url){
	  
	  	if(url == "_self"){
	  		window.opener.location.href = window.opener.location.href;
	  	}
	  	else{
	  		window.opener.location.href = url;
	  	}
		self.close();
	}

//-->