Pture = 
{
	init: function()
	{
		if(Pture.getBrowser() != 'Safari')
		{
			$('bodyUploaded').style.display = 'none';
		}
		
		pTarget = $('bodyPreviews');
		
		for(iIndex = 0; iIndex < pTarget.childNodes.length; iIndex++)
		{
			if(pTarget.childNodes[iIndex].nodeName == 'DL')
			{
				Pture.list = $('bodyPreviews').childNodes[iIndex];
			}
		}
		
		Pture.count = 0;
		Pture.showQuota = true;
		Pture.filename = '';
		Pture.response = '';
		Pture.aDetails = new Array();
		
		Pture.toUpload = 0;
		Pture.uploaded = 0;
		
		SI.Files.stylizeAll();		
	},
	
	doNewSession: function()
	{
		if(confirm('Start a new session?\nNote: The \'My Images\' section will be cleared, however the image(s) will remain hosted on our servers.'))
		{
			new Ajax.Request('./session.php', 	{ 	
													asynchronous:	true, 
													onSuccess:		this.doSessionComplete, 
													onFailure:		this.doSessionError
												});
		}
		
		return;
		
	},
	
	doSessionComplete: function()
	{
		$('bodyImages').innerHTML = '';
		
		Pture.filename = '';
		Pture.doLoadGeneral();
		
		return;
	},
	
	doSessionError: function()
	{
		alert('Could not create a new session at this time. Please try again later.');
		
		return;
	},
	
	doDelete: function()
	{
		if(!this.aDetails[1] || !Pture.filename)
		{
			alert('You must first select an image to remove.');
			
			return;
		}
		
		if(!confirm('Delete the selected image?\nNote: The selected image will be permanently removed from our servers.'))
		{
			return;
		}
		
		new Ajax.Request('./delete.php', 	{ 	
												asynchronous:	true, 
												method:			'post', 
												postBody: 		'iId=' + this.aDetails[8], 
												onSuccess:		this.doDeleteComplete, 
												onFailure:		this.doDeleteError
											});
	},
	
	doDeleteComplete: function(pResponse)
	{
		if(pResponse.responseText == 'BAD')
		{
			alert('You must first select an image to remove.');
			
			return;
		}
		
		pImage = 'image' + pResponse.responseText;
		
		$('bodyImages').removeChild($(pImage));
		
		Pture.filename = '';
		Pture.doLoadGeneral();
		
		return;
	},
	
	doDeleteError: function()
	{
		alert('Could not remove the image at this time. Please try again later.');
		
		return;
	},
	
	doReduceStr: function(szText, iLength)
	{
		if(szText.length > iLength)
		{
			szText = szText.substr(0, iLength) + '...';
		}
		
		return szText;
	},
	
	getPreview: function(pUpload)
	{
		if($('bodyPreviews').childNodes[0].childNodes.length == 8)
		{
			if(confirm('You may upload a maximum of eight (8) images per request.\nUpload the ones you have selected now?'))
			{
				Pture.doUpload();
			}
			
			return;
		}
		
		var pDT = document.createElement('dt');
		this.count++;
		
		var pImage = document.createElement('img');
		pImage.setAttribute('src', './images/icon-cancel.png');
		pImage.setAttribute('class', 'imgIcon');
		pImage.setAttribute('className', 'imgIcon');
		pImage.setAttribute('id', 'image' + Pture.count);
		pImage.style.cursor = 'pointer';
		
		pImage.onclick = function() { Pture.doCancel(this); }
		
		pDT.appendChild(pImage);

		var aFileParts = pUpload.value.split('\\');
		var szFilename = aFileParts[aFileParts.length - 1];
		
		szFilename = this.doReduceStr(szFilename, 25);
		
		var pDiv = document.createElement('div');
		pDiv.innerHTML = szFilename;
		
		pDT.appendChild(pDiv);
		this.list.appendChild(pDT);
		
		var pTarget = $('bodyForms');
		var pForm = document.createElement('form');
		
		pForm.setAttribute('enctype', 'multipart/form-data');
		pForm.setAttribute('encoding', 'multipart/form-data');
		pForm.setAttribute('method', 'post');
		pForm.setAttribute('action', 'upload.php');
		pForm.setAttribute('class', 'cabinet');
		pForm.setAttribute('className', 'cabinet');
		pForm.setAttribute('target', 'iframe' + this.count);
		
		var pUpload = this.createNamedElement('input', 'objUpload');
		
		pUpload.setAttribute('type', 'file');
		pUpload.setAttribute('size', 1);
		pUpload.setAttribute('class', 'file');
		pUpload.setAttribute('className', 'file');
		pUpload.onchange = function() { Pture.getPreview(this); }
		
		for(iIndex = 0; iIndex < pTarget.childNodes.length; iIndex++)
		{
			pTarget.childNodes[iIndex].style.height = '0px';
			pTarget.childNodes[iIndex].style.width = '0px';	
			pTarget.childNodes[iIndex].style.position = 'absolute';
		}
		
		var pFrames = $('bodyUploaded');
		var pFrame = this.createNamedElement('iframe', 'iframe' + this.count);
		
		var pHidden = this.createNamedElement('input', 'iIdentifier');
		pHidden.setAttribute('type', 'hidden');
		pHidden.setAttribute('value', this.count);

		pFrames.appendChild(pFrame);
		
		pForm.appendChild(pHidden);
		pForm.appendChild(pUpload);
		
		pTarget.appendChild(pForm);
		
		this.list.style.display = '';
		
		SI.Files.stylizeAll();		
	},
	
	doCancel: function(pChildTarget)
	{
		pDL = pChildTarget.parentNode.parentNode;
		pTarget = $('bodyForms');
		
		for(iIndex = 0; iIndex < pDL.childNodes.length; iIndex++)
		{
			if(pDL.childNodes[iIndex].childNodes[0].getAttribute('id') == pChildTarget.getAttribute('id'))
			{
				pDL.removeChild(pDL.childNodes[iIndex]);
				pTarget.removeChild(pTarget.childNodes[iIndex]);
				
				return;
			}
		}
		
		return;
	},
	
	doUpload: function()
	{
		$('btnUpload').setAttribute('disabled', true);
		$('btnUpload').style.backgroundImage = "url(./images/btnuploading.jpg)";
		//$('btnUpload').setAttribute('value', 'Uploading...');
		
		pTarget = $('bodyForms');
		
		this.showQuota = true;
		
		for(iIndex = 0; iIndex <= pTarget.childNodes.length; iIndex++)
		{
			if(!pTarget.childNodes[iIndex])
			{
				continue;
			}
			
			if(!pTarget.childNodes[iIndex].childNodes[1].value)
			{
				continue;
			}
			
			Pture.toUpload++;
			pTarget.childNodes[iIndex].submit();
		}
		
		if(Pture.toUpload == 0)
		{
			$('btnUpload').removeAttribute('disabled');
			$('btnUpload').style.backgroundImage = "url(./images/btnupload.jpg)";
			//$('btnUpload').setAttribute('value', 'Upload Selected');
			
			alert('You have not chosen any images to be uploaded.');
		}
		
		return;
	},
	
	doCleanFinalise: function()
	{
		clearInterval(pInterval);
		
		this.list.style.display = 'none';
		this.list.innerHTML = '';
		
		pTarget = $('bodyForms');
		
		for(iIndex = 0; iIndex < pTarget.childNodes[0].childNodes.length; iIndex++)
		{
			if(pTarget.childNodes[0].childNodes[iIndex].getAttribute('type') == 'file')
			{
				pTarget.childNodes[0].childNodes[iIndex].removeAttribute('disabled');
				//pTarget.childNodes[0].childNodes[iIndex].style.backgroundImage = "url('./images/btnbrowse.jpg')";
				return;
			}
		}
		
		return;
	},
	
	doCloseToS: function()
	{
		$('bodyToS').hide();
		$('bodyForms').show();
	},
	
	doOpenToS: function()
	{
		$('bodyToS').show();
		$('bodyForms').hide();
	},
	
	doClean: function()
	{
		$('bodyForms').innerHTML = '';
		
		pInterval = setInterval('Pture.doCleanFinalise()', 3000);
		
		var pTarget = $('bodyForms');
		var pForm = document.createElement('form');
		
		pForm.setAttribute('enctype', 'multipart/form-data');
		pForm.setAttribute('encoding', 'multipart/form-data');
		pForm.setAttribute('method', 'post');
		pForm.setAttribute('action', 'upload.php');
		pForm.setAttribute('class', 'cabinet');
		pForm.setAttribute('className', 'cabinet');
		pForm.setAttribute('target', 'iframe' + this.count);
		
		var pUpload = this.createNamedElement('input', 'objUpload');
		
		pUpload.setAttribute('type', 'file');
		pUpload.setAttribute('disabled', true);
		pUpload.setAttribute('size', 1);
		pUpload.setAttribute('class', 'file');
		pUpload.setAttribute('className', 'file');
		pUpload.onchange = function() { Pture.getPreview(this); }
		
		var pFrames = $('bodyUploaded');
		var pFrame = this.createNamedElement('iframe', 'iframe' + this.count);
		
		var pHidden = this.createNamedElement('input', 'iIdentifier');
		pHidden.setAttribute('type', 'hidden');
		pHidden.setAttribute('value', this.count);

		pFrames.appendChild(pFrame);
		
		pForm.appendChild(pHidden);
		pForm.appendChild(pUpload);
		
		pTarget.appendChild(pForm);
		
		this.toUpload = 0;
		this.uploaded = 0;
				
		SI.Files.stylizeAll();		

		return;
	},
	
	doShow: function(szFilename, szPage)
	{
		if(!szFilename)
		{
			return;
		}
		
		Pture.doResetLinks(szPage);
		
		if(Pture.aDetails[4] == szFilename)
		{
			Pture.aDetails[0] = szPage;
			this.doShowComplete(false);
			return;
		}
		
		Pture.filename = szFilename;
		
		new Ajax.Request('./request.php', 	{ 	
												asynchronous:	true, 
												method:			'post', 
												postBody: 		'txtFilename=' + szFilename + '&txtPage=' + szPage, 
												onSuccess:		this.doShowComplete, 
												onFailure:		this.doShowError
											});
		
		return;
	},
	
	doResetLinks: function(szPage)
	{
		pTarget = $('mainNavigation');
		
		for(iIndex = 0; iIndex < pTarget.childNodes.length; iIndex++)
		{
			if(pTarget.childNodes[iIndex].nodeName == 'IMG')
			{
				pImage = pTarget.childNodes[iIndex];
				szSource = pImage.getAttribute('src').replace(/\-active/i, '');

				pImage.setAttribute('src', szSource);
			}
		}
		
		switch(szPage)
		{
			case('General'):
				$('imgLinkGeneral').setAttribute('src', './images/tab-general-active.jpg');
				break;
				
			case('Resize'):
				$('imgLinkResize').setAttribute('src', './images/tab-resize-active.jpg');
				break;
				
			case('Email'):
				$('imgLinkEmail').setAttribute('src', './images/tab-email-active.jpg');
				break;
		}
	},
	
	doShowComplete: function(pResponse)
	{
		if(pResponse.responseText)
		{
			Pture.aDetails = pResponse.responseText.split(',');
		}
		
		switch(Pture.aDetails[0].toLowerCase())
		{
			case('general'):
				Pture.doLoadGeneral();
				break;
				
			case('resize'):
				Pture.doLoadResize();
				break;
				
			case('email'):
				Pture.doLoadEmail();
				break;
				
			default:
				alert('You have specified an invalid page to display.');
				break;
		}
	},
	
	doShowError: function()
	{
		alert('Could not display image at this time. Please try again later.');
	},
	
	doLoadEmail: function()
	{
		pTarget = $('bodyDetails');
		
		var pDivBB = document.createElement('div');
		pDivBB.setAttribute('class', 'bodyRow');
		pDivBB.setAttribute('className', 'bodyRow');
		
		var pH1 = document.createElement('h1');
		pH1.innerHTML = this.doReduceStr(this.aDetails[1], 14);

		var pSpan = document.createElement('span');
		pSpan.innerHTML = this.aDetails[5];
		
		var pImage = document.createElement('img');
		pImage.setAttribute('alt', this.aDetails[1]);
		pImage.setAttribute('src', this.aDetails[3]);
		
		var pLabel = document.createElement('label');
		pLabel.setAttribute('for', 'txtEmail');
		pLabel.innerHTML = 'E-mail:';
		
		var pText = document.createElement('input');
		pText.setAttribute('type', 'text');
		pText.setAttribute('id', 'txtEmail');
		pText.setAttribute('class', 'frmEmail');
		pText.setAttribute('className', 'frmEmail');
		
		pButton = document.createElement('input');
		pButton.setAttribute('value', 'Send Link');
		pButton.setAttribute('type', 'button');
		pButton.setAttribute('class', 'frmButton');
		pButton.setAttribute('className', 'frmButton');
		pButton.setAttribute('id', 'btnEmail');
		
		pButton.onclick = function() { Pture.doSendEmail(); }
		
		pDivBB.appendChild(pLabel);
		pDivBB.appendChild(pText);
		pDivBB.appendChild(pButton);
		
		pTarget.innerHTML = '';
		
		pTarget.appendChild(pImage);
		pTarget.appendChild(pH1);
		pTarget.appendChild(pSpan);
		pTarget.appendChild(pDivBB);
	},
	
	doSendEmail: function()
	{
		$('btnEmail').setAttribute('disabled', true);
		$('btnEmail').setAttribute('value', 'Sending...');
		
		var szEmail = $('txtEmail').value;
		var szLink = this.aDetails[7] + this.aDetails[2];
		
		if(szEmail.length == 0)
		{
			$('btnEmail').removeAttribute('disabled');
			$('btnEmail').setAttribute('value', 'Send Link');
			
			alert('E-mail address cannot be empty.');
			return;
		}
		
		if(!szEmail.match(/^[A-Z0-9\-\_\.]+@[A-Z0-9\-\.]+\.[A-Z\.]{2,6}$/i))
		{
			$('btnEmail').removeAttribute('disabled');
			$('btnEmail').setAttribute('value', 'Send Link');
		
			alert('The recepient\'s e-mail address appears to be invalid.');
			return;
		}
		
		new Ajax.Request('./mail.php', 	{ 	
											asynchronous:	true, 
											method:			'post', 
											postBody: 		'txtEmail=' + szEmail + '&txtLink=' + szLink,
											onSuccess:		this.doEmailComplete, 
											onFailure:		this.doEmailError
										});
	},
	
	doEmailError: function()
	{
		alert('We were unable to send the e-mail at this time. Please try again later.');
		
		$('btnEmail').removeAttribute('disabled');
		$('btnEmail').setAttribute('value', 'Send Link');
		
		return;
	},
	
	doEmailComplete: function(pResponse)
	{
		$('btnEmail').removeAttribute('disabled');
		$('btnEmail').setAttribute('value', 'Send Link');
		
		if(pResponse.responseText != 'OK')
		{
			alert('We were unable to send the e-mail at this time. Please try again later.');
			return;
		}
		
		alert('The image has been sent to the recipient!');
		
		$('txtEmail').value = '';
		$('txtEmail').select();
		
		return;
	},
	
	doLoadResize: function()
	{
		pTarget = $('bodyDetails');
		
		var pH1 = document.createElement('h1');
		pH1.innerHTML = this.doReduceStr(this.aDetails[1], 14);

		var pSpan = document.createElement('span');
		pSpan.innerHTML = this.aDetails[6];
		
		var pImage = document.createElement('img');
		pImage.setAttribute('alt', this.aDetails[1]);
		pImage.setAttribute('src', this.aDetails[3]);
		
		var pDivBB = document.createElement('div');
		pDivBB.setAttribute('class', 'bodyRow');
		pDivBB.setAttribute('className', 'bodyRow');
		
		var pLabel = document.createElement('label');
		pLabel.innerHTML = 'Resize:';
		
		var pSelectRatio = document.createElement('select');
		pSelectRatio.setAttribute('id', 'selRatio');
		
		aRatios = new Array(	['80x80'		,	'80x80 (square avatar)'],
								['100x75' 		,	'100x75 (avatar)'],
								['150x112'		,	'150x112 (thumbnail)'],
								['320x240'		,	'320x240 (email)'],
								['640x480'		,	'640x480 (forums)'],
								['800x600'		,	'800x600'],
								['1024x768'		,	'1024x768'],
								['1280x1024'	,	'1280x1024'],
								['1600x1200'	,	'1600x1200']);
		
		for(iIndex = 0; iIndex < aRatios.length; iIndex++)
		{
			var pOption = document.createElement('option');
			pOption.setAttribute('value', aRatios[iIndex][0]);
			pOption.text = aRatios[iIndex][1];
			
			try
			{
				pSelectRatio.add(pOption, null);
			}
			catch(ex)
			{
				pSelectRatio.add(pOption);
			}
		}
		
		var pInput = document.createElement('input');
		pInput.setAttribute('value', 'Resize Picture');
		pInput.setAttribute('type', 'button');
		pInput.setAttribute('class', 'frmButton');
		pInput.setAttribute('className', 'frmButton');
		pInput.setAttribute('id', 'btnResize');
		
		pInput.onclick = function() { Pture.doResize(); }

		pDivBB.appendChild(pLabel);
		pDivBB.appendChild(pSelectRatio);
		pDivBB.appendChild(pInput);
		
		pTarget.innerHTML = '';
		
		pTarget.appendChild(pImage);
		pTarget.appendChild(pH1);
		pTarget.appendChild(pSpan);
		pTarget.appendChild(pDivBB);
		
		return;
	},
	
	doResize: function()
	{
		$('btnResize').setAttribute('disabled', true);
		$('btnResize').setAttribute('value', 'Resizing...');
		
		szResolution = $('selRatio').childNodes[$('selRatio').selectedIndex].getAttribute('value');
		
		new Ajax.Request('./resize.php', 	{ 	
												asynchronous:	true, 
												method:			'post', 
												postBody: 		'txtFilename=' + Pture.aDetails[4] + '&txtResolution=' + szResolution,
												onSuccess:		this.doResizeComplete, 
												onFailure:		this.doResizeError
											});
	},
	
	doResizeComplete: function(pResponse)
	{
		$('btnResize').removeAttribute('disabled');
		$('btnResize').setAttribute('value', 'Resize Picture');
		
		if(!pResponse.responseText)
		{
			alert('Could not resize the image at this time. Please try again later.');
			return;
		}
		
		if(pResponse.responseText == 'REACHED_QUOTA')
		{
			Pture.hasReachedQuota();
			return;
		}
		
		var pTarget = $('bodyImages');
		var pImage = document.createElement('img');
		var aDetails = pResponse.responseText.split(',');
		
		pImage.setAttribute('id', 'image' + aDetails[0]);
		pImage.setAttribute('src', aDetails[1]);
		pImage.setAttribute('class', 'imgPreview');
		pImage.setAttribute('className', 'imgPreview');
		
		pImage.onclick = function() { Pture.doShow(pResponse.responseText, 'General'); }
		
		pTarget.appendChild(pImage);
		
		return;
	},
	
	doLoadGeneral: function()
	{
		if(!Pture.filename)
		{
			$('bodyDetails').innerHTML = '';
			
			pDiv = document.createElement('div');
			
			pDiv.setAttribute('id', 'bodyDetailsMessage');
			pDiv.innerHTML = 'You have not selected an image yet.';
			
			$('bodyDetails').appendChild(pDiv);
			
			return;
		}
		
		pTarget = $('bodyDetails');
		
		var pH1 = document.createElement('h1');
		pH1.innerHTML = this.doReduceStr(this.aDetails[1], 14);
		
		var pImage = document.createElement('img');
		pImage.setAttribute('alt', this.aDetails[1]);
		pImage.setAttribute('src', this.aDetails[3]);

		var pSpan = document.createElement('span');
		pSpan.innerHTML = this.aDetails[5];
		
		/* Begin BB Code Row */
		
		var pDivBB = document.createElement('div');
		pDivBB.setAttribute('class', 'bodyRow');
		pDivBB.setAttribute('className', 'bodyRow');
		
		var pLabelBB = document.createElement('label');
		pLabelBB.innerHTML = 'BB Code:';
		
		var pInputBB = document.createElement('input');
		pInputBB.setAttribute('value', '[img]' + this.aDetails[7] + this.aDetails[2] + '[/img]');
		pInputBB.onfocus = function() { this.select(); }
		
		pDivBB.appendChild(pLabelBB);
		pDivBB.appendChild(pInputBB);
		
		/* End BB Code Row */
		
		/* Begin Direct Link Code Row */
		
		var pDivDirect = document.createElement('div');
		pDivDirect.setAttribute('class', 'bodyRow');
		pDivDirect.setAttribute('className', 'bodyRow');
		
		var pLabelDirect = document.createElement('label');
		pLabelDirect.innerHTML = 'Direct:';
		
		var pInputDirect = document.createElement('input');
		pInputDirect.setAttribute('value', this.aDetails[7] + this.aDetails[2]);
		pInputDirect.onfocus = function() { this.select(); }
		
		pDivDirect.appendChild(pLabelDirect);
		pDivDirect.appendChild(pInputDirect);
		
		/* End Direct Link Code Row */
		
		pTarget.innerHTML = '';
		
		pTarget.appendChild(pImage);
		pTarget.appendChild(pH1);
		pTarget.appendChild(pSpan);
		
		pTarget.appendChild(pDivBB);
		pTarget.appendChild(pDivDirect);
	},
	
	doChangeToComplete: function(szIdentifier, bType)
	{
		if(!$(szIdentifier))
		{
			return;
		}
		
		$(szIdentifier).onclick = function() { return; }
		$(szIdentifier).style.cursor = 'default';
				
		switch(bType)
		{
			case(true):
				$(szIdentifier).setAttribute('src', './images/icon-uploaded.png');
				break;
			
			case(false):
				$(szIdentifier).setAttribute('src', './images/icon-disallowed.png');
				break;
		}
	},
	
	doComplete: function(szFilename, szIdentifier, iImageId)
	{
		Pture.doChangeToComplete(szIdentifier, true);
		
		var pTarget = $('bodyImages');
		var pImage = document.createElement('img');
		
		pImage.setAttribute('id', 'image' + iImageId);
		pImage.setAttribute('src', szFilename);
		pImage.setAttribute('class', 'imgPreview');
		pImage.setAttribute('className', 'imgPreview');
		
		pImage.onclick = function() { Pture.doShow(szFilename, 'General'); }
		
		pTarget.appendChild(pImage);
		Pture.isComplete(true);
		
		return;
	},
	
	isComplete: function(bCleanup)
	{
		Pture.uploaded++;
		
		if(Pture.uploaded == Pture.toUpload)
		{
			if(bCleanup)
			{
				this.doClean();
			}
		
			$('btnUpload').removeAttribute('disabled');
			$('btnUpload').style.backgroundImage = "url(./images/btnupload.jpg)";
			//$('btnUpload').setAttribute('value', 'Upload Selected');
		}
		
		return;
	},
	
	doPurge: function(pTarget)
	{
		if(confirm('Delete all of your images?\nNote: All images in the \'My Images\' section will be permanently removed from our servers.'))
		{
			$('bodyImages').innerHTML = '';
		
			Pture.filename = '';
			Pture.doLoadGeneral();
			
			new Ajax.Request('./purge.php', { 	
												asynchronous:	true
											});
		}
		
		return;
	},
	
	isNotAllowed: function(szRealname, szIdentifier)
	{
		Pture.doChangeToComplete(szIdentifier, false);
		Pture.isComplete(true);
		
		alert('"' + szRealname + '" cannot be uploaded because its extension has been disallowed.');
	},
	
	isNotAllowedBad: function(szRealname, szIdentifier)
	{
		Pture.doChangeToComplete(szIdentifier, false);
		Pture.isComplete(true);
		
		alert('"' + szRealname + '" cannot be uploaded because although its extension is acceptable, the file-type does not match its extension.');
	},
	
	hasReachedQuota: function()
	{
		if(this.showQuota == true)
		{
			alert('You have reached the maximum amount of allowed images per session. Please purge them to continue.');
			this.showQuota = false;
		}
		
		Pture.isComplete(false);
		
		return;
	},
	
	createNamedElement: function(type, name)
	{
		var element = null;
		// Try the IE way; this fails on standards-compliant browsers
		try
		{
		  element = document.createElement('<'+type+' name="'+name+'">');
		}
		catch (e)
		{
			}
			if (!element || element.nodeName != type.toUpperCase())
			{
			  // Non-IE browser; use canonical method to create named element
			  element = document.createElement(type);
			  element.name = name;
			}
		
		return element;
	},
	
	getBrowser: function()
	{
		var agt=navigator.userAgent.toLowerCase();
		if (agt.indexOf("opera") != -1) return 'Opera';
		if (agt.indexOf("staroffice") != -1) return 'Star Office';
		if (agt.indexOf("webtv") != -1) return 'WebTV';
		if (agt.indexOf("beonex") != -1) return 'Beonex';
		if (agt.indexOf("chimera") != -1) return 'Chimera';
		if (agt.indexOf("netpositive") != -1) return 'NetPositive';
		if (agt.indexOf("phoenix") != -1) return 'Phoenix';
		if (agt.indexOf("firefox") != -1) return 'Firefox';
		if (agt.indexOf("safari") != -1) return 'Safari';
		if (agt.indexOf("skipstone") != -1) return 'SkipStone';
		if (agt.indexOf("msie") != -1) return 'Internet Explorer';
		if (agt.indexOf("netscape") != -1) return 'Netscape';
		if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
		if (agt.indexOf('\/') != -1) {
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
		return navigator.userAgent.substr(0,agt.indexOf('\/'));}
		else return 'Netscape';} else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0,agt.indexOf(' '));
		else return navigator.userAgent;
	}
}

Event.observe(window, 'load', Pture.init, false);
