
/*==================================================
  $Id: tabber.js,v 1.9 2006/04/27 20:51:51 pat Exp $
  /*================================================== */
  

function tabberObj(argsObj)
{
  var arg; /* name of an argument to override */

  /* Element for the main tabber div. If you supply this in argsObj,
     then the init() method will be called.
  */
  this.div = null;

  /* Class of the main tabber div */
  this.classMain = "tabber";

  /* Rename classMain to classMainLive after tabifying
     (so a different style can be applied)
  */
  this.classMainLive = "tabberlive";

  /* Class of each DIV that contains a tab */
  this.classTab = "tabbertab";

  /* Class to indicate which tab should be active on startup */
  this.classTabDefault = "tabbertabdefault";

  /* Class for the navigation UL */
  this.classNav = "tabbernav";

  /* When a tab is to be hidden, instead of setting display='none', we
     set the class of the div to classTabHide. In your screen
     stylesheet you should set classTabHide to display:none.  In your
     print stylesheet you should set display:block to ensure that all
     the information is printed.
  */
  this.classTabHide = "tabbertabhide";

  /* Class to set the navigation LI when the tab is active, so you can
     use a different style on the active tab.
  */
  this.classNavActive = "tabberactive";

  /* Elements that might contain the title for the tab, only used if a
     title is not specified in the TITLE attribute of DIV classTab.
  */
  this.titleElements = ['h2','h3','h4','h5','h6'];

  /* Should we strip out the HTML from the innerHTML of the title elements?
     This should usually be true.
  */
  this.titleElementsStripHTML = true;

  /* If the user specified the tab names using a TITLE attribute on
     the DIV, then the browser will display a tooltip whenever the
     mouse is over the DIV. To prevent this tooltip, we can remove the
     TITLE attribute after getting the tab name.
  */
  this.removeTitle = true;

  /* If you want to add an id to each link set this to true */
  this.addLinkId = false;

  /* If addIds==true, then you can set a format for the ids.
     <tabberid> will be replaced with the id of the main tabber div.
     <tabnumberzero> will be replaced with the tab number
       (tab numbers starting at zero)
     <tabnumberone> will be replaced with the tab number
       (tab numbers starting at one)
     <tabtitle> will be replaced by the tab title
       (with all non-alphanumeric characters removed)
   */
  this.linkIdFormat = '<tabberid>nav<tabnumberone>';

  /* You can override the defaults listed above by passing in an object:
     var mytab = new tabber({property:value,property:value});
  */
  for (arg in argsObj) { this[arg] = argsObj[arg]; }

  /* Create regular expressions for the class names; Note: if you
     change the class names after a new object is created you must
     also change these regular expressions.
  */
  this.REclassMain = new RegExp('\\b' + this.classMain + '\\b', 'gi');
  this.REclassMainLive = new RegExp('\\b' + this.classMainLive + '\\b', 'gi');
  this.REclassTab = new RegExp('\\b' + this.classTab + '\\b', 'gi');
  this.REclassTabDefault = new RegExp('\\b' + this.classTabDefault + '\\b', 'gi');
  this.REclassTabHide = new RegExp('\\b' + this.classTabHide + '\\b', 'gi');

  /* Array of objects holding info about each tab */
  this.tabs = new Array();

  /* If the main tabber div was specified, call init() now */
  if (this.div) {

    this.init(this.div);

    /* We don't need the main div anymore, and to prevent a memory leak
       in IE, we must remove the circular reference between the div
       and the tabber object. */
    this.div = null;
  }
}


/*--------------------------------------------------
  Methods for tabberObj
  --------------------------------------------------*/


tabberObj.prototype.init = function(e)
{
  /* Set up the tabber interface.

     e = element (the main containing div)

     Example:
     init(document.getElementById('mytabberdiv'))
   */

  var
  childNodes, /* child nodes of the tabber div */
  i, i2, /* loop indices */
  t, /* object to store info about a single tab */
  defaultTab=0, /* which tab to select by default */
  DOM_ul, /* tabbernav list */
  DOM_li, /* tabbernav list item */
  DOM_a, /* tabbernav link */
  aId, /* A unique id for DOM_a */
  headingElement; /* searching for text to use in the tab */

  /* Verify that the browser supports DOM scripting */
  if (!document.getElementsByTagName) { return false; }

  /* If the main DIV has an ID then save it. */
  if (e.id) {
    this.id = e.id;
  }

  /* Clear the tabs array (but it should normally be empty) */
  this.tabs.length = 0;

  /* Loop through an array of all the child nodes within our tabber element. */
  childNodes = e.childNodes;
  for(i=0; i < childNodes.length; i++) {

    /* Find the nodes where class="tabbertab" */
    if(childNodes[i].className &&
       childNodes[i].className.match(this.REclassTab)) {
      
      /* Create a new object to save info about this tab */
      t = new Object();
      
      /* Save a pointer to the div for this tab */
      t.div = childNodes[i];
      
      /* Add the new object to the array of tabs */
      this.tabs[this.tabs.length] = t;

      /* If the class name contains classTabDefault,
	 then select this tab by default.
      */
      if (childNodes[i].className.match(this.REclassTabDefault)) {
	defaultTab = this.tabs.length-1;
      }
    }
  }

  /* Create a new UL list to hold the tab headings */
  DOM_ul = document.createElement("ul");
  DOM_ul.className = this.classNav;
  
  /* Loop through each tab we found */
  for (i=0; i < this.tabs.length; i++) {

    t = this.tabs[i];

    /* Get the label to use for this tab:
       From the title attribute on the DIV,
       Or from one of the this.titleElements[] elements,
       Or use an automatically generated number.
     */
    t.headingText = t.div.title;

    /* Remove the title attribute to prevent a tooltip from appearing */
    if (this.removeTitle) { t.div.title = ''; }

    if (!t.headingText) {

      /* Title was not defined in the title of the DIV,
	 So try to get the title from an element within the DIV.
	 Go through the list of elements in this.titleElements
	 (typically heading elements ['h2','h3','h4'])
      */
      for (i2=0; i2<this.titleElements.length; i2++) {
	headingElement = t.div.getElementsByTagName(this.titleElements[i2])[0];
	if (headingElement) {
	  t.headingText = headingElement.innerHTML;
	  if (this.titleElementsStripHTML) {
	    t.headingText.replace(/<br>/gi," ");
	    t.headingText = t.headingText.replace(/<[^>]+>/g,"");
	  }
	  break;
	}
      }
    }

    if (!t.headingText) {
      /* Title was not found (or is blank) so automatically generate a
         number for the tab.
      */
      t.headingText = i + 1;
    }

    /* Create a list element for the tab */
    DOM_li = document.createElement("li");

    /* Save a reference to this list item so we can later change it to
       the "active" class */
    t.li = DOM_li;

    /* Create a link to activate the tab */
    DOM_a = document.createElement("a");
    DOM_a.appendChild(document.createTextNode(t.headingText));
    DOM_a.href = "javascript:void(null);";
    DOM_a.title = t.headingText;
    DOM_a.onclick = this.navClick;

    /* Add some properties to the link so we can identify which tab
       was clicked. Later the navClick method will need this.
    */
    DOM_a.tabber = this;
    DOM_a.tabberIndex = i;

    /* Do we need to add an id to DOM_a? */
    if (this.addLinkId && this.linkIdFormat) {

      /* Determine the id name */
      aId = this.linkIdFormat;
      aId = aId.replace(/<tabberid>/gi, this.id);
      aId = aId.replace(/<tabnumberzero>/gi, i);
      aId = aId.replace(/<tabnumberone>/gi, i+1);
      aId = aId.replace(/<tabtitle>/gi, t.headingText.replace(/[^a-zA-Z0-9\-]/gi, ''));

      DOM_a.id = aId;
    }

    /* Add the link to the list element */
    DOM_li.appendChild(DOM_a);

    /* Add the list element to the list */
    DOM_ul.appendChild(DOM_li);
  }

  /* Add the UL list to the beginning of the tabber div */
  e.insertBefore(DOM_ul, e.firstChild);

  /* Make the tabber div "live" so different CSS can be applied */
  e.className = e.className.replace(this.REclassMain, this.classMainLive);

  /* Activate the default tab, and do not call the onclick handler */
  this.tabShow(defaultTab);

  /* If the user specified an onLoad function, call it now. */
  if (typeof this.onLoad == 'function') {
    this.onLoad({tabber:this});
  }

  return this;
};


tabberObj.prototype.navClick = function(event)
{
  /* This method should only be called by the onClick event of an <A>
     element, in which case we will determine which tab was clicked by
     examining a property that we previously attached to the <A>
     element.

     Since this was triggered from an onClick event, the variable
     "this" refers to the <A> element that triggered the onClick
     event (and not to the tabberObj).

     When tabberObj was initialized, we added some extra properties
     to the <A> element, for the purpose of retrieving them now. Get
     the tabberObj object, plus the tab number that was clicked.
  */

  var
  rVal, /* Return value from the user onclick function */
  a, /* element that triggered the onclick event */
  self, /* the tabber object */
  tabberIndex, /* index of the tab that triggered the event */
  onClickArgs; /* args to send the onclick function */

  a = this;
  if (!a.tabber) { return false; }

  self = a.tabber;
  tabberIndex = a.tabberIndex;

  /* Remove focus from the link because it looks ugly.
     I don't know if this is a good idea...
  */
  a.blur();

  /* If the user specified an onClick function, call it now.
     If the function returns false then do not continue.
  */
  if (typeof self.onClick == 'function') {

    onClickArgs = {'tabber':self, 'index':tabberIndex, 'event':event};

    /* IE uses a different way to access the event object */
    if (!event) { onClickArgs.event = window.event; }

    rVal = self.onClick(onClickArgs);
    if (rVal === false) { return false; }
  }

  self.tabShow(tabberIndex);

  return false;
};


tabberObj.prototype.tabHideAll = function()
{
  var i; /* counter */

  /* Hide all tabs and make all navigation links inactive */
  for (i = 0; i < this.tabs.length; i++) {
    this.tabHide(i);
  }
};


tabberObj.prototype.tabHide = function(tabberIndex)
{
  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  /* Hide a single tab and make its navigation link inactive */
  div = this.tabs[tabberIndex].div;

  /* Hide the tab contents by adding classTabHide to the div */
  if (!div.className.match(this.REclassTabHide)) {
    div.className += ' ' + this.classTabHide;
  }
  this.navClearActive(tabberIndex);

  return this;
};


tabberObj.prototype.tabShow = function(tabberIndex)
{
  /* Show the tabberIndex tab and hide all the other tabs */

  var div;

  if (!this.tabs[tabberIndex]) { return false; }

  /* Hide all the tabs first */
  this.tabHideAll();

  /* Get the div that holds this tab */
  div = this.tabs[tabberIndex].div;

  /* Remove classTabHide from the div */
  div.className = div.className.replace(this.REclassTabHide, '');

  /* Mark this tab navigation link as "active" */
  this.navSetActive(tabberIndex);

  /* If the user specified an onTabDisplay function, call it now. */
  if (typeof this.onTabDisplay == 'function') {
    this.onTabDisplay({'tabber':this, 'index':tabberIndex});
  }

  return this;
};

tabberObj.prototype.navSetActive = function(tabberIndex)
{
  /* Note: this method does *not* enforce the rule
     that only one nav item can be active at a time.
  */

  /* Set classNavActive for the navigation list item */
  this.tabs[tabberIndex].li.className = this.classNavActive;

  return this;
};


tabberObj.prototype.navClearActive = function(tabberIndex)
{
  /* Note: this method does *not* enforce the rule
     that one nav should always be active.
  */

  /* Remove classNavActive from the navigation list item */
  this.tabs[tabberIndex].li.className = '';

  return this;
};


/*==================================================*/


function tabberAutomatic(tabberArgs)
{
  /* This function finds all DIV elements in the document where
     class=tabber.classMain, then converts them to use the tabber
     interface.

     tabberArgs = an object to send to "new tabber()"
  */
  var
    tempObj, /* Temporary tabber object */
    divs, /* Array of all divs on the page */
    i; /* Loop index */

  if (!tabberArgs) { tabberArgs = {}; }

  /* Create a tabber object so we can get the value of classMain */
  tempObj = new tabberObj(tabberArgs);

  /* Find all DIV elements in the document that have class=tabber */

  /* First get an array of all DIV elements and loop through them */
  divs = document.getElementsByTagName("div");
  for (i=0; i < divs.length; i++) {
    
    /* Is this DIV the correct class? */
    if (divs[i].className &&
	divs[i].className.match(tempObj.REclassMain)) {
      
      /* Now tabify the DIV */
      tabberArgs.div = divs[i];
      divs[i].tabber = new tabberObj(tabberArgs);
    }
  }
  
  return this;
}


/*==================================================*/


function tabberAutomaticOnLoad(tabberArgs)
{
  /* This function adds tabberAutomatic to the window.onload event,
     so it will run after the document has finished loading.
  */
  var oldOnLoad;

  if (!tabberArgs) { tabberArgs = {}; }

  /* Taken from: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */

  oldOnLoad = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = function() {
      tabberAutomatic(tabberArgs);
    };
  } else {
    window.onload = function() {
      oldOnLoad();
      tabberAutomatic(tabberArgs);
    };
  }
}


/*==================================================*/


/* Run tabberAutomaticOnload() unless the "manualStartup" option was specified */

if (typeof tabberOptions == 'undefined') {

    tabberAutomaticOnLoad();

} else {

  if (!tabberOptions['manualStartup']) {
    tabberAutomaticOnLoad(tabberOptions);
  }

}


//// TAB 2

	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Updated:
		
		March, 14th, 2006 - Create new tabs dynamically
		March, 15th, 2006 - Dynamically delete a tab
		
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/		
	var textPadding = 10; // Padding at the left of tab text - bigger value gives you wider tabs
	var strictDocType = true; 
	var tabView_maxNumberOfTabs = 6;	// Maximum number of tabs
	
	/* Don't change anything below here */
	var dhtmlgoodies_tabObj = new Array();
	var activeTabIndex = new Array();
	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	
	var regExp = new RegExp(".*MSIE ([0-9]\.[0-9]).*","g");
	var navigatorVersion = navigator.userAgent.replace(regExp,'$1');
	
	var ajaxObjects = new Array();
	var tabView_countTabs = new Array();
	var tabViewHeight = new Array();
	var tabDivCounter = 0;
	var closeImageHeight = 8;	// Pixel height of close buttons
	var closeImageWidth = 8;	// Pixel height of close buttons
	
	
	function setPadding(obj,padding){
		var span = obj.getElementsByTagName('SPAN')[0];
		span.style.paddingLeft = padding + 'px';	
		span.style.paddingRight = padding + 'px';	
	}
	function showTab(parentId,tabIndex)
	{
		var parentId_div = parentId + "_";
		if(!document.getElementById('tabView' + parentId_div + tabIndex)){
			return;
		}
		if(activeTabIndex[parentId]>=0){
			if(activeTabIndex[parentId]==tabIndex){
				return;
			}
	
			var obj = document.getElementById('tabTab'+parentId_div + activeTabIndex[parentId]);
			
			obj.className='tabInactive';
			var img = obj.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')==-1)img = obj.getElementsByTagName('IMG')[1];
			img.src = 'images/tab_right_inactive.gif';
			document.getElementById('tabView' + parentId_div + activeTabIndex[parentId]).style.display='none';
		}
		
		var thisObj = document.getElementById('tabTab'+ parentId_div +tabIndex);	
			
		thisObj.className='tabActive';
		var img = thisObj.getElementsByTagName('IMG')[0];
		if(img.src.indexOf('tab_')==-1)img = thisObj.getElementsByTagName('IMG')[1];
		img.src = 'images/tab_right_active.gif';
		
		document.getElementById('tabView' + parentId_div + tabIndex).style.display='block';
		activeTabIndex[parentId] = tabIndex;
		

		var parentObj = thisObj.parentNode;
		var aTab = parentObj.getElementsByTagName('DIV')[0];
		countObjects = 0;
		var startPos = 2;
		var previousObjectActive = false;
		while(aTab){
			if(aTab.tagName=='DIV'){
				if(previousObjectActive){
					previousObjectActive = false;
					startPos-=2;
				}
				if(aTab==thisObj){
					startPos-=2;
					previousObjectActive=true;
					setPadding(aTab,textPadding+1);
				}else{
					setPadding(aTab,textPadding);
				}
				
				aTab.style.left = startPos + 'px';
				countObjects++;
				startPos+=2;
			}			
			aTab = aTab.nextSibling;
		}
		
		return;
	}
	
	function tabClick()
	{
		var idArray = this.id.split('_');		
		showTab(this.parentNode.parentNode.id,idArray[idArray.length-1].replace(/[^0-9]/gi,''));
		
	}
	
	function rolloverTab()
	{
		if(this.className.indexOf('tabInactive')>=0){
			this.className='inactiveTabOver';
			var img = this.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
			img.src = 'images/tab_right_over.gif';
		}
		
	}
	function rolloutTab()
	{
		if(this.className ==  'inactiveTabOver'){
			this.className='tabInactive';
			var img = this.getElementsByTagName('IMG')[0];
			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
			img.src = 'images/tab_right_inactive.gif';
		}
		
	}
	
	function hoverTabViewCloseButton()
	{
		this.src = this.src.replace('close.gif','close_over.gif');
	}
	
	function stopHoverTabViewCloseButton()
	{
		this.src = this.src.replace('close_over.gif','close.gif');
	}
	
	function initTabs(mainContainerID,tabTitles,activeTab,width,height,closeButtonArray,additionalTab)
	{
		if(!closeButtonArray)closeButtonArray = new Array();
		
		if(!additionalTab || additionalTab=='undefined'){			
			dhtmlgoodies_tabObj[mainContainerID] = document.getElementById(mainContainerID);
			width = width + '';
			if(width.indexOf('%')<0)width= width + 'px';
			dhtmlgoodies_tabObj[mainContainerID].style.width = width;
						
			height = height + '';
			if(height.length>0){
				if(height.indexOf('%')<0)height= height + 'px';
				dhtmlgoodies_tabObj[mainContainerID].style.height = height;
			}
			

			tabViewHeight[mainContainerID] = height;
			
			var tabDiv = document.createElement('DIV');		
			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];	
			
			dhtmlgoodies_tabObj[mainContainerID].insertBefore(tabDiv,firstDiv);	
			tabDiv.className = 'dhtmlgoodies_tabPane';			
			tabView_countTabs[mainContainerID] = 0;

		}else{
			var tabDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];
			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[1];
			height = tabViewHeight[mainContainerID];
			activeTab = tabView_countTabs[mainContainerID];		
	
			
		}
		
		
		
		for(var no=0;no<tabTitles.length;no++){
			var aTab = document.createElement('DIV');
			aTab.id = 'tabTab' + mainContainerID + "_" +  (no + tabView_countTabs[mainContainerID]);
			aTab.onmouseover = rolloverTab;
			aTab.onmouseout = rolloutTab;
			aTab.onclick = tabClick;
			aTab.className='tabInactive';
			tabDiv.appendChild(aTab);
			var span = document.createElement('SPAN');
			span.innerHTML = tabTitles[no];
			span.style.position = 'relative';
			aTab.appendChild(span);
			
			if(closeButtonArray[no]){
				var closeButton = document.createElement('IMG');
				closeButton.src = 'images/close.gif';
				closeButton.height = closeImageHeight + 'px';
				closeButton.width = closeImageHeight + 'px';
				closeButton.setAttribute('height',closeImageHeight);
				closeButton.setAttribute('width',closeImageHeight);
				closeButton.style.position='absolute';
				closeButton.style.top = '6px';
				closeButton.style.right = '0px';
				closeButton.onmouseover = hoverTabViewCloseButton;
				closeButton.onmouseout = stopHoverTabViewCloseButton;
				
				span.innerHTML = span.innerHTML + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';	
				
				var deleteTxt = span.innerHTML+'';

				closeButton.onclick = function(){ deleteTab(this.parentNode.innerHTML) };
				span.appendChild(closeButton);
			}
			
			var img = document.createElement('IMG');
			img.valign = 'bottom';
			img.src = 'images/tab_right_inactive.gif';
			// IE5.X FIX
			if((navigatorVersion && navigatorVersion<6) || (MSIE && !strictDocType)){
				img.style.styleFloat = 'none';
				img.style.position = 'relative';	
				img.style.top = '4px'
				span.style.paddingTop = '4px';
				aTab.style.cursor = 'hand';
			}	// End IE5.x FIX
			aTab.appendChild(img);
		}

		var tabs = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV');
		var divCounter = 0;
		for(var no=0;no<tabs.length;no++){
			if(tabs[no].className=='dhtmlgoodies_aTab' && tabs[no].parentNode.id == mainContainerID){
				if(height.length>0)tabs[no].style.height = height;
				tabs[no].style.display='none';
				tabs[no].id = 'tabView' + mainContainerID + "_" + divCounter;
				divCounter++;
			}			
		}	
		tabView_countTabs[mainContainerID] = tabView_countTabs[mainContainerID] + tabTitles.length;	
		showTab(mainContainerID,activeTab);

		return activeTab;
	}	
	
	function showAjaxTabContent(ajaxIndex,parentId,tabId)
	{
		var obj = document.getElementById('tabView'+parentId + '_' + tabId);
		obj.innerHTML = ajaxObjects[ajaxIndex].response;		
	}
	
	function resetTabIds(parentId)
	{
		var tabTitleCounter = 0;
		var tabContentCounter = 0;
		
		
		var divs = dhtmlgoodies_tabObj[parentId].getElementsByTagName('DIV');

		
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='dhtmlgoodies_aTab'){
				divs[no].id = 'tabView' + parentId + '_' + tabTitleCounter;
				tabTitleCounter++;
			}
			if(divs[no].id.indexOf('tabTab')>=0){
				divs[no].id = 'tabTab' + parentId + '_' + tabContentCounter;	
				tabContentCounter++;
			}	
			
				
		}
	
		tabView_countTabs[parentId] = tabContentCounter;
	}
	
	
	function createNewTab(parentId,tabTitle,tabContent,tabContentUrl,closeButton)
	{
		if(tabView_countTabs[parentId]>=tabView_maxNumberOfTabs)return;	// Maximum number of tabs reached - return
		var div = document.createElement('DIV');
		div.className = 'dhtmlgoodies_aTab';
		dhtmlgoodies_tabObj[parentId].appendChild(div);		

		var tabId = initTabs(parentId,Array(tabTitle),0,'','',Array(closeButton),true);
		if(tabContent)div.innerHTML = tabContent;
		if(tabContentUrl){		
			var ajaxIndex = ajaxObjects.length;
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get

			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	
		
		}
				
	}
	
	function getTabIndexByTitle(tabTitle)
	{
		var regExp = new RegExp("(.*?)&nbsp.*$","gi");
		tabTitle = tabTitle.replace(regExp,'$1');
		for(var prop in dhtmlgoodies_tabObj){
			var divs = dhtmlgoodies_tabObj[prop].getElementsByTagName('DIV');
			for(var no=0;no<divs.length;no++){
				if(divs[no].id.indexOf('tabTab')>=0){
					var span = divs[no].getElementsByTagName('SPAN')[0];
					var regExp2 = new RegExp("(.*?)&nbsp.*$","gi");
					var spanTitle = span.innerHTML.replace(regExp2,'$1');
					
					if(spanTitle == tabTitle){
						
						var tmpId = divs[no].id.split('_');						
						return Array(prop,tmpId[tmpId.length-1].replace(/[^0-9]/g,'')/1);
					}		
				}
			}
		}
		
		return -1;
		
	}
	
	/* Call this function if you want to display some content from external file in one of the tabs 
	Arguments: Title of tab and relative path to external file */
	
	function addAjaxContentToTab(tabTitle,tabContentUrl)
	{
		var index = getTabIndexByTitle(tabTitle);
		if(index!=-1){
			var ajaxIndex = ajaxObjects.length;
			
			tabId = index[1];
			parentId = index[0];
			
			
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get

			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function				
			
		}	
	}

	
	
	function deleteTab(tabLabel,tabIndex,parentId)
	{

		if(tabLabel){
			var index = getTabIndexByTitle(tabLabel);
			if(index!=-1){
				deleteTab(false,index[1],index[0]);
			}
			
		}else if(tabIndex>=0){
			if(document.getElementById('tabTab' + parentId + '_' + tabIndex)){
				var obj = document.getElementById('tabTab' + parentId + '_' + tabIndex);
				var id = obj.parentNode.parentNode.id;
				obj.parentNode.removeChild(obj);
				var obj2 = document.getElementById('tabView' + parentId + '_' + tabIndex);
				obj2.parentNode.removeChild(obj2);
				resetTabIds(parentId);
				activeTabIndex[parentId]=-1;
				showTab(parentId,'0');
			}			
		}
		

			
		
		
	}
	
	
/*/ END SCRIPT ********************************************************************
*********************************************************
**************************
*********************
*************
*******
****
*/


var zBox,zStep=0,zLink,zNew;

function doZoom() {
    zStep+=1;zPct=(10-zStep)/10
if (document.layers) {
	zBox.moveTo(toX+zPct*(fromX-toX),toY+zPct*(fromY-toY));
	zBox.document.open();
	zBox.document.write("<table width='"+maxW*(1-zPct)+"' height="+maxH*(1-zPct)+" border=2 cellspacing=0><tr><td></td></tr></table>");
	zBox.document.close();
  }else{
	zBox.style.border="2px solid #999999";
	zBox.style.left=toX+zPct*(fromX-toX);
	zBox.style.top=toY+zPct*(fromY-toY);
	zBox.style.width=maxW*(1-zPct);
	zBox.style.height=maxH*(1-zPct);
	}
zBox.style.visibility="visible";
  if  (zStep < 10) setTimeout("doZoom("+fromX+","+fromY+","+toX+","+toY+")",30);
  else{zBox.style.visibility='hidden';zStep=0;
  if  (zLink && !zNew)location.href=zLink.href;
  else if (zLink && zNew) {
  var w=window.open(''+ zLink + '','','width='+maxW+',height='+maxH+',left='+adjX+',top='+adjY+',scrollbars=auto,resizable');
   zNew=null;
  }
 }
}

function Lvl_Zoom(evt,zlink,maxw,maxh,tox,toy) {
  if (arguments.length > 2) zNew=1;
  scrollH=(window.pageYOffset!=null)?window.pageYOffset:document.body.scrollTop;
     maxW=maxw?maxw:window.innerWidth?innerWidth:document.body.clientWidth;
     maxH=maxh?maxh:window.innerHeight?innerHeight:document.body.clientHeight;
      toX=tox?tox:0;
      toY=(toy?toy:0)+scrollH;
    fromX=evt.pageX?evt.pageX:evt.clientX;
    fromY=(evt.pageY?evt.pageY:evt.clientY)+(document.all?scrollH:0);
     adjX=toX+evt.screenX-fromX;
     adjY=toY+evt.screenY-fromY;
 if (document.createElement && document.body.appendChild && !zBox) {
	zBox=document.createElement("div");
	zBox.style.position="absolute";
	document.body.appendChild(zBox);
 }else if (document.all && !zBox) {
	document.all[document.all.length-1].outerHTML+='<div id="zBoxDiv" style="position:absolute"></div>';
	zBox=document.all.zBoxDiv;
 }else if (document.layers && !zBox) {
	zBox=new Layer(maxW);zBox.style=zBox;
 }
    zLink=zlink;
    doZoom();
}

// [dFilter] - A Numerical Input Mask for JavaScript
// Written By Dwayne Forehand - March 27th, 2003
// Please reuse & redistribute while keeping this notice.

var dFilterStep

function dFilterStrip (dFilterTemp, dFilterMask)
{
    dFilterMask = replace(dFilterMask,'#','');
    for (dFilterStep = 0; dFilterStep < dFilterMask.length++; dFilterStep++)
		{
		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}
		return dFilterTemp;
}

function dFilterMax (dFilterMask)
{
 		dFilterTemp = dFilterMask;
    for (dFilterStep = 0; dFilterStep < (dFilterMask.length+1); dFilterStep++)
		{
		 		if (dFilterMask.charAt(dFilterStep)!='#')
				{
		        dFilterTemp = replace(dFilterTemp,dFilterMask.charAt(dFilterStep),'');
				}
		}
		return dFilterTemp.length;
}

function dFilter (key, textbox, dFilterMask)
{
		dFilterNum = dFilterStrip(textbox.value, dFilterMask);
		
		if (key==9)
		{
		    return true;
		}
		else if (key==8&&dFilterNum.length!=0)
		{
		 	 	dFilterNum = dFilterNum.substring(0,dFilterNum.length-1);
		}
 	  else if (dFilterNum.length<dFilterMax(dFilterMask) )
		{
        dFilterNum=dFilterNum+String.fromCharCode(key);
		}

		var dFilterFinal='';
    for (dFilterStep = 0; dFilterStep < dFilterMask.length; dFilterStep++)
		{
        if (dFilterMask.charAt(dFilterStep)=='#')
				{
					  if (dFilterNum.length!=0)
					  {
				        dFilterFinal = dFilterFinal + dFilterNum.charAt(0);
					      dFilterNum = dFilterNum.substring(1,dFilterNum.length);
					  }
				    else
				    {
				        dFilterFinal = dFilterFinal + "";
				    }
				}
		 		else if (dFilterMask.charAt(dFilterStep)!='#')
				{
				    dFilterFinal = dFilterFinal + dFilterMask.charAt(dFilterStep); 			
				}
//		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}


		textbox.value = dFilterFinal;
    return false;
}

function replace(fullString,text,by) {
// Replaces text with by in string
    var strLength = fullString.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return fullString;

    var i = fullString.indexOf(text);
    if ((!i) && (text != fullString.substring(0,txtLength))) return fullString;
    if (i == -1) return fullString;

    var newstr = fullString.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(fullString.substring(i+txtLength,strLength),text,by);

    return newstr;
}



var letters=' ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáÀÁéèÈÉíìÍÌïÏóòÓÒúùÚÙüÜ'
var numbers='1234567890'
var signs=',.:;@-\''
var mathsigns='+-=()*/'
var custom='<>#$%&?¿'

function alpha(e,allow) {
var k;
k=document.all?parseInt(e.keyCode): parseInt(e.which);
return (allow.indexOf(String.fromCharCode(k))!=-1);
}


// COPY to clipbopard

function ClipBoard(holdtextnum,textcopy) 
{
holdtext.innerText = textcopy;
Copied = holdtext.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
alert (textcopy + '\nURL copied to clipboard'); 
}



/// TOGGLE DIV

function childdiv(whichLayer,divobj,toggleLayer)
{

	if (document.getElementById){
	 box = document.getElementById(divobj);
	 }
	 else if (document.all)
     { 
		box = document.all[divobj];
	 }
		else if (document.layers)
	 {
		box = document.layers[divobj];
	 }


		
	destination = box.options[box.selectedIndex].value;
	var yesvar = whichLayer+'1';
	var novar = whichLayer+'2';	
			
	if (destination == "") {
		if (document.getElementById)
		{
		
		if (toggleLayer) { // Toggle Layers to use
			document.getElementById(toggleLayer).disabled=false;
		}
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"";
		}
		else if (document.all)
		{
		
		if (toggleLayer) { // Toggle Layers to use
			document.all[toggleLayer].disabled=false;
		}
		
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"";
		}
		else if (document.layers)
		{
		if (toggleLayer) { // Toggle Layers to use
			document.layers[toggleLayer].disabled=false;
		}
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"";
		}
		
	}
	
	if (destination == "yes") {

		if (document.getElementById)
		{
		
		if (toggleLayer) { // Toggle Layers to use
			document.getElementById(toggleLayer).disabled='disabled';
		}
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "block":"block";
		
		var style2Sub = document.getElementById(yesvar).style;
		style2Sub.display = style2Sub.display? "block":"block";	
		
		var style2SubNo = document.getElementById(novar).style;
		style2SubNo.display = style2SubNo.display? "none":"none";		
		
		}
		else if (document.all)
		{
		if (toggleLayer) { // Toggle Layers to use
			document.all[toggleLayer].disabled='disabled';
		}
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "block":"block";	
			
		var style2Sub = document.all[yesvar].style;		
		style2Sub.display = style2Sub.display? "block":"block";	
		
		var style2SubNo = document.all[novar].style;		
		style2SubNo.display = style2SubNo.display? "none":"none";	
		}
		else if (document.layers)
		{
		if (toggleLayer) { // Toggle Layers to use
			document.layers[toggleLayer].disabled='disabled';
		}
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "block":"block";
		
		var style2Sub = document.layers[yesvar].style;		
		style2Sub.display = style2sub.display? "block":"block";		
		
		var style2SubNo = document.layers[novar].style;		
		style2SubNo.display = style2subNo.display? "none":"none";				
		
		}
	}
	
	if (destination == "no") {


		if (document.getElementById)
		{
		
		if (toggleLayer) { // Toggle Layers to use
			document.getElementById(toggleLayer).disabled=false;
		}
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "block":"block";
		
		var style2Sub = document.getElementById(yesvar).style;
		style2Sub.display = style2Sub.display? "none":"none";	
		
		var style2SubNo = document.getElementById(novar).style;
		style2SubNo.display = style2SubNo.display? "block":"block";		
		
		}
		else if (document.all)
		{
		if (toggleLayer) { // Toggle Layers to use
			document.all[toggleLayer].disabled=false;
		}
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "block":"block";	
			
		var style2Sub = document.all[yesvar].style;		
		style2Sub.display = style2Sub.display? "none":"none";	
		
		var style2SubNo = document.all[novar].style;		
		style2SubNo.display = style2SubNo.display? "block":"block";	
		}
		else if (document.layers)
		{
		if (toggleLayer) { // Toggle Layers to use
			document.layers[toggleLayer].disabled=false;
		}
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "block":"block";
		
		var style2Sub = document.layers[yesvar].style;		
		style2Sub.display = style2sub.display? "none":"none";		
		
		var style2SubNo = document.layers[novar].style;		
		style2SubNo.display = style2subNo.display? "block":"block";				
		
		}
	}
		
}

/**** Preview Attachement **************/

function previewattach(divID,fileID) {
	  var divname = document.getElementById(divID);
	  //alert("Photo Updated");
	  var d=new Date();
 	  divname.innerHTML = '<div id="webcam_area" name="webcam_area"><img src="read_file_session.php?newsession='+d.getTime()+'" width="120" style="border:#FFFFFF 2px solid;margin:10px" border="0" /><input type="text" name="tmp_filename" value="'+fileID+'"></div>';
	
}

/******************* CHECKBOX VALIDATOR ****************************/


function checkBoxValidate_opt1(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_opt1;
var confirm_field = document.newmsgform.standqty;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_opt2(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_opt2;
var confirm_field = document.newmsgform.standqty;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_opt3(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_opt3;
var confirm_field = document.newmsgform.standqty;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}
/******************* END FIRST OPTION OPT 1 **************************************/

/******* CHECKBOX FOUNTAIN *********/
function checkBoxValidate_fountain_opt1(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_fountain_opt1;
var confirm_field = document.newmsgform.standqty_fountain;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_fountain_opt2(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_fountain_opt2;
var confirm_field = document.newmsgform.standqty_fountain;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_fountain_opt3(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_fountain_opt3;
var confirm_field = document.newmsgform.standqty_fountain;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}
/*************** END FOUNTAIN *******************************/

/******* CHECKBOX CANAL *********/
function checkBoxValidate_canal_opt1(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_canal_opt1;
var confirm_field = document.newmsgform.standqty_canal;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_canal_opt2(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_canal_opt2;
var confirm_field = document.newmsgform.standqty_canal;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_canal_opt3(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_canal_opt3;
var confirm_field = document.newmsgform.standqty_canal;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}
/********************** END CANAL OPTION 3 ****************************/

/******* CHECKBOX GATEWAY *********/
function checkBoxValidate_gateway_opt1(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_gateway_opt1;
var confirm_field = document.newmsgform.standqty_gateway;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_gateway_opt2(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_gateway_opt2;
var confirm_field = document.newmsgform.standqty_gateway;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

function checkBoxValidate_gateway_opt3(cb,this_fieldname) {
var fieldname = document.newmsgform.standno_gateway_opt3;
var confirm_field = document.newmsgform.standqty_gateway;

if (confirm_field.options[confirm_field.selectedIndex].value == '') {
	alert ("Please select number of stands required"); 
	for (j = 0; j < fieldname.length; j++) {
		fieldname[j].checked = false;
	}
	confirm_field.focus();
	} else {
if (confirm_field.options[confirm_field.selectedIndex].value == '1 stand') {
	for (j = 0; j < fieldname.length; j++) {

	if (eval("fieldname[" + j + "].checked") == true) {
	 fieldname[j].checked = false;
	 if (j == cb) {
		fieldname[j].checked = true;
				  }
		  }
	   }
   
	} else { 
	
	for (j = 0; j < fieldname.length; j++) {

		if (eval("fieldname[" + j + "].checked") == true) {
		 
				 if (j == cb) {
					fieldname[j].checked = true;
					fieldname[j+1].checked = true;
							 }
				if (j !== cb) {
				 if (j !== cb +1) {	 
					fieldname[j].checked = false; 
				  }
				}
		
		
			  }
		   }
   
	} // End Else
	
 } // end if confirm_field is not set
}

