	// clydeweb.js
	// javascript function library for Clyde Web Viewer App
//*****************************************************************************************************************************************
// START OF TIME CODE
//*****************************************************************************************************************************************

	//Get Date and time from system
	function startTime()
	{
		var today=new Date();
		var h=today.getHours();
		var m=today.getMinutes();
		var s=today.getSeconds();
		var d=today.getDate();
		var mo=today.getMonth() + 1;
		var y=today.getFullYear();
		//add a zero in front of numbers<10
		d=checkDate(d);
		mo=checkDate(mo);
		m=checkTime(m);
		s=checkTime(s);
		document.getElementById('time').innerHTML=d+"-"+mo+"-"+y+" "+h+":"+m+":"+s;
		t=setTimeout('startTime()',500);
	}
	
	function checkDate(i)
	{
		if (i<10) 
		{i='0' + i}
		return i;
	}

	function checkTime(i)
	{
		if (i<10) 
		{i='0' + i}
		return i;
	}
//*****************************************************************************************************************************************
// START OF AJAX CODE
//*****************************************************************************************************************************************

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// Get Sample Summary Table code

	// When new date range or navigation used retrieve the correct new group of samples to display
	function GetSampleSum(Sess,Sam,QFindCrit,QFindItem,Mode)
	{
		var tmp
		var date1
		var date2
		tmp = document.getElementById("DisplayData"); // Will be blank on refresh
		if (tmp.innerHTML.length == 0)	// no Html inside the SampleData SPAN so no records are currently displayed
		{
			date1 = document.getElementById("calendar");	// get current search criteria dates from the page
			date2 = document.getElementById("calendar1");
			GetSampleSumTable('',date1.value,date2.value,Sess,Sam,Mode,QFindCrit,QFindItem)
		}
	}

	// Get sample records using HttpRequest object so page doesn't reload
	function GetSampleSumTable(Nav,DStart,DEnd,Sess,Sam,Mode,QFindCrit,QFindItem)
	{
		var url="samplesum.esp"; // Sample/Inspection page

		xmlHttp=GetXmlHttpObject(); // create HttpRequest object
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 

		url=url+"?Nav="+Nav+"&Start="+DStart+"&End="+DEnd+"&Sess="+Sess+"&Sample="+Sam+"&SMode="+Mode+"&QFindCrit="+QFindCrit+"&QFindItem="+QFindItem;	// add Navigation mode and dates to the URL so correct samples can be returned
		url=url+"&sid="+Math.random();	// Add random number to stop server returning cached page!
		xmlHttp.onreadystatechange=stateChangedA;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	// Get data response from server and insert Html into relevant position in the page
	function stateChangedA() 
	{ 
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("DisplayData").innerHTML=xmlHttp.responseText; // place returned code from server into SampleData SPAN
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// Get sample detail page

	function GetSampleDetail(Sample, Sess)
	{
		var url="sampledetail.esp"; // Sample page

		xmlHttp=GetXmlHttpObject(); // create HttpRequest object
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 	
		url=url+"?Sample="+Sample+"&Sess="+Sess;	// Sample and session
		url=url+"&sid="+Math.random();	// Add random number to stop server returning cached page!
		xmlHttp.onreadystatechange=stateChangedB;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	// Get data response from server and insert Html into relevant position in the page
	function stateChangedB() 
	{ 
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("DisplayData").innerHTML=xmlHttp.responseText; // place returned code from server into SampleData SPAN
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// Get test sumamry page

	function GetTestSummary(Sample, Sess)
	{
		var url="testsummary.esp"; // Sample page

		xmlHttp=GetXmlHttpObject(); // create HttpRequest object
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		} 	
		url=url+"?Sample="+Sample+"&Sess="+Sess;	// Sample and session
		url=url+"&sid="+Math.random();	// Add random number to stop server returning cached page!
		xmlHttp.onreadystatechange=stateChangedB;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	// Get data response from server and insert Html into relevant position in the page
	function stateChangedB() 
	{ 
		if (xmlHttp.readyState==4)
		{ 
			document.getElementById("DisplayData").innerHTML=xmlHttp.responseText; // place returned code from server into SampleData SPAN
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// Create HttpRequestObject
	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}

//*****************************************************************************************************************************************
// START OF MISC CODE
//*****************************************************************************************************************************************
	
	// Open PDF document
	function viewPDF(pdf)
	{
		document.location.href=pdf;
	}


	// change tab function
	function changetab(mode)
	{
		if (mode==1)
		{
			document.getElementById('tab1').className = 'tabactive';
			document.getElementById('tab2').className = 'tabinactive';
			document.getElementById('tab3').className = 'tabinactive';
			document.getElementById('tab4').className = 'tabinactive';
			document.getElementById('tab5').className = 'tabinactive';
			document.getElementById('tab6').className = 'tabinactive';

		}
		if (mode==2)
		{
			document.getElementById('tab1').className = 'tabinactive';
			document.getElementById('tab2').className = 'tabactive';
			document.getElementById('tab3').className = 'tabinactive';
			document.getElementById('tab4').className = 'tabinactive';
			document.getElementById('tab5').className = 'tabinactive';
			document.getElementById('tab6').className = 'tabinactive';

		}
		if (mode==3)
		{
			document.getElementById('tab1').className = 'tabinactive';
			document.getElementById('tab2').className = 'tabinactive';
			document.getElementById('tab3').className = 'tabactive';
			document.getElementById('tab4').className = 'tabinactive';
			document.getElementById('tab5').className = 'tabinactive';
			document.getElementById('tab6').className = 'tabinactive';
		}
		if (mode==4)
		{
			document.getElementById('tab1').className = 'tabinactive';
			document.getElementById('tab2').className = 'tabinactive';
			document.getElementById('tab3').className = 'tabinactive';
			document.getElementById('tab4').className = 'tabactive';
			document.getElementById('tab5').className = 'tabinactive';
			document.getElementById('tab6').className = 'tabinactive';
		}
		if (mode==5)
		{
			document.getElementById('tab1').className = 'tabinactive';
			document.getElementById('tab2').className = 'tabinactive';
			document.getElementById('tab3').className = 'tabinactive';
			document.getElementById('tab4').className = 'tabinactive';
			document.getElementById('tab5').className = 'tabactive';
			document.getElementById('tab6').className = 'tabinactive';
		}
		if (mode==6)
		{
			document.getElementById('tab1').className = 'tabinactive';
			document.getElementById('tab2').className = 'tabinactive';
			document.getElementById('tab3').className = 'tabinactive';
			document.getElementById('tab4').className = 'tabinactive';
			document.getElementById('tab5').className = 'tabinactive';
			document.getElementById('tab6').className = 'tabactive';
		}
	}

	// change tab function
	function changeInttab(page,mode)
	{
		
		if (page=="news")
		{	
			if (mode==1)
			{
				document.getElementById('tabNews1').className = 'tabactiveInt';
				document.getElementById('tabNews2').className = 'tabinactiveInt';
				document.getElementById('tabpane1News').className = 'tabpaneactiveInt';
				document.getElementById('tabpane2News').className = 'tabpaneinactiveInt';
			}
			if (mode==2)
			{
				document.getElementById('tabNews1').className = 'tabinactiveInt';
				document.getElementById('tabNews2').className = 'tabactiveInt';
				document.getElementById('tabpane1News').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2News').className = 'tabpaneactiveInt';
			}
		}
		if (page=="products")
		{
			if (mode==1)
			{
				document.getElementById('tabProds1').className = 'tabactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==2)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==3)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==4)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==5)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==6)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabactiveInt';
				document.getElementById('tabProds7').className = 'tabinactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneinactiveInt';
			}
			if (mode==7)
			{
				document.getElementById('tabProds1').className = 'tabinactiveInt';
				document.getElementById('tabProds2').className = 'tabinactiveInt';
				document.getElementById('tabProds3').className = 'tabinactiveInt';
				document.getElementById('tabProds4').className = 'tabinactiveInt';
				document.getElementById('tabProds5').className = 'tabinactiveInt';
				document.getElementById('tabProds6').className = 'tabinactiveInt';
				document.getElementById('tabProds7').className = 'tabactiveInt';
				document.getElementById('tabpane1Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane5Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane6Prods').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane7Prods').className = 'tabpaneactiveInt';
			}
		}
		if (page=="sales")
		{	
			if (mode==1)
			{
				document.getElementById('tabSales1').className = 'tabactiveInt';
				document.getElementById('tabSales2').className = 'tabinactiveInt';
				document.getElementById('tabSales3').className = 'tabinactiveInt';
				document.getElementById('tabSales4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Sales').className = 'tabpaneactiveInt';
				document.getElementById('tabpane2Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Sales').className = 'tabpaneinactiveInt';
			}
			if (mode==2)
			{

				document.getElementById('tabSales1').className = 'tabinactiveInt';
				document.getElementById('tabSales2').className = 'tabactiveInt';
				document.getElementById('tabSales3').className = 'tabinactiveInt';
				document.getElementById('tabSales4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Sales').className = 'tabpaneactiveInt';
				document.getElementById('tabpane3Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Sales').className = 'tabpaneinactiveInt';
			}
			if (mode==3)
			{
				document.getElementById('tabSales1').className = 'tabinactiveInt';
				document.getElementById('tabSales2').className = 'tabinactiveInt';
				document.getElementById('tabSales3').className = 'tabactiveInt';
				document.getElementById('tabSales4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Sales').className = 'tabpaneactiveInt';
				document.getElementById('tabpane4Sales').className = 'tabpaneinactiveInt';
			}
			if (mode==4)
			{
				document.getElementById('tabSales1').className = 'tabinactiveInt';
				document.getElementById('tabSales2').className = 'tabinactiveInt';
				document.getElementById('tabSales3').className = 'tabinactiveInt';
				document.getElementById('tabSales4').className = 'tabactiveInt';
				document.getElementById('tabpane1Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Sales').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Sales').className = 'tabpaneactiveInt';
			}
		}
		if (page=="support")
		{	
			if (mode==1)
			{
				document.getElementById('tabSupport1').className = 'tabactiveInt';
				document.getElementById('tabSupport2').className = 'tabinactiveInt';
				document.getElementById('tabSupport3').className = 'tabinactiveInt';
				document.getElementById('tabpane1Support').className = 'tabpaneactiveInt';
				document.getElementById('tabpane2Support').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Support').className = 'tabpaneinactiveInt';
			}
			if (mode==2)
			{
				document.getElementById('tabSupport1').className = 'tabinactiveInt';
				document.getElementById('tabSupport2').className = 'tabactiveInt';
				document.getElementById('tabSupport3').className = 'tabinactiveInt';
				document.getElementById('tabpane1Support').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Support').className = 'tabpaneactiveInt';
				document.getElementById('tabpane3Support').className = 'tabpaneinactiveInt';
			}
			if (mode==3)
			{
				document.getElementById('tabSupport1').className = 'tabinactiveInt';
				document.getElementById('tabSupport2').className = 'tabinactiveInt';
				document.getElementById('tabSupport3').className = 'tabactiveInt';
				document.getElementById('tabpane1Support').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Support').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Support').className = 'tabpaneactiveInt';
			}
		}
		if (page=="info")
		{	
			if (mode==1)
			{
				document.getElementById('tabInfo1').className = 'tabactiveInt';
				document.getElementById('tabInfo2').className = 'tabinactiveInt';
				document.getElementById('tabInfo3').className = 'tabinactiveInt';
				document.getElementById('tabInfo4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Info').className = 'tabpaneactiveInt';
				document.getElementById('tabpane2Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Info').className = 'tabpaneinactiveInt';
			}
			if (mode==2)
			{
				document.getElementById('tabInfo1').className = 'tabinactiveInt';
				document.getElementById('tabInfo2').className = 'tabactiveInt';
				document.getElementById('tabInfo3').className = 'tabinactiveInt';
				document.getElementById('tabInfo4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Info').className = 'tabpaneactiveInt';
				document.getElementById('tabpane3Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Info').className = 'tabpaneinactiveInt';
			}
			if (mode==3)
			{
				document.getElementById('tabInfo1').className = 'tabinactiveInt';
				document.getElementById('tabInfo2').className = 'tabinactiveInt';
				document.getElementById('tabInfo3').className = 'tabactiveInt';
				document.getElementById('tabInfo4').className = 'tabinactiveInt';
				document.getElementById('tabpane1Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Info').className = 'tabpaneactiveInt';
				document.getElementById('tabpane4Info').className = 'tabpaneinactiveInt';
			}
			if (mode==4)
			{
				document.getElementById('tabInfo1').className = 'tabinactiveInt';
				document.getElementById('tabInfo2').className = 'tabinactiveInt';
				document.getElementById('tabInfo3').className = 'tabinactiveInt';
				document.getElementById('tabInfo4').className = 'tabactiveInt';
				document.getElementById('tabpane1Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane2Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane3Info').className = 'tabpaneinactiveInt';
				document.getElementById('tabpane4Info').className = 'tabpaneactiveInt';
			}
		}
		


	}

	// display messages
	function show_message(message)
	{
		alert(message);
	}

	// reads header info for pages with internal tabs so knows what tab to activate
	function gettabmode()
	{
		var qsParm = new Array();
		var query = window.location.search.substring(1);
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) 
		{
			var pos = parms[i].indexOf('=');
			if (pos > 0) 
			{
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParm[i] = val;	
			}
		}
		changeInttab(qsParm[0],qsParm[1]);
	}








	
	
	

	
	
	
	
			
				
					
								

						
						




			
			
			


	
