﻿				
		var source = 0;
		var replacement = 1;
				
		function createRollOver(originalImage,replacementImage) {
				var imageArray = new Array;
				imageArray[source] = new Image;
				imageArray[source].src = originalImage;
				imageArray[replacement] = new Image;
				imageArray[replacement].src = replacementImage;
				return imageArray;
		}
				
		function roll(targetImage,displayImage) {
			targetImage.src = displayImage.src;
		}
		
		var rollImage1 = createRollOver("/images/buttons/convert-greek.png","/images/buttons/convert-greek-rollover.png");



		function makeFinalTextAreaActive() {		
			var ta = document.getElementById("finalTextAreaId");
			ta.setAttribute("class", "textarea-active");
			ta.setAttribute("className", "textarea-active");	
		}
		
		function makeFinalTextAreaInActive() {		
			var ta = document.getElementById("finalTextAreaId");
			ta.setAttribute("class", "textarea-inactive");
			ta.setAttribute("className", "textarea-inactive");	
		}
		
		function makeInitialTextAreaActive() {		
			var ta = document.getElementById("initialTextAreaId");
			ta.setAttribute("class", "textarea-active");
			ta.setAttribute("className", "textarea-active");	
		}
		
		function makeInitialTextAreaInActive() {		
			var ta = document.getElementById("initialTextAreaId");
			ta.setAttribute("class", "textarea-inactive");
			ta.setAttribute("className", "textarea-inactive");	
		}
		
		
		
		function makeTextfieldActive() {
			var ta = document.getElementById("textfieldId");
			ta.setAttribute("class", "contact-active");
			ta.setAttribute("className", "contact-active");
		}
		
		function makeTextfieldInActive() {
			var ta = document.getElementById("textfieldId");
			ta.setAttribute("class", "contact-inactive");
			ta.setAttribute("className", "contact-inactive");
		}
		
		
				
		function showMailinfoDiv() {
			var mailinfoDiv = document.getElementById("mailinfoDiv");
			mailinfoDiv.style.visibility = 'visible';
		}
		
		
		
		function submitMailinfo() {

			var emailAddress = document.mailinfoForm.email.value;
			var initialText = document.instantConvertForm.initialTextArea.value;
			var convertedText = document.convertedTextForm.finalTextArea.value;

			changeContactAjaxDiv();
			
			var url = "/mailit";
			var pars = "email=" + emailAddress + "&initialText=" + initialText +"&convertedText=" + convertedText;
			new Ajax.Request(
				url, 
				{
					method: "post", 
					parameters: pars, 
					onComplete: showContactResponse,
					onFailure: indicateContactError
				});

		}
		
		function showContactResponse(originalRequest) {
			var responseFromServer = originalRequest.responseText;
			//alert("success " + responseFromServer);
			var contactAjaxDiv = $("contactAjaxDiv");
			contactAjaxDiv.innerHTML = responseFromServer;
			var resetMailinfoDiv = $("resetMailinfoDiv");
			resetMailinfoDiv.disabled = false;
			var submitMailinfoDiv = $("submitMailinfoDiv");
			submitMailinfoDiv.disabled = false;
			document.mailinfoForm.email.value ="";
		}
			
		function indicateContactError(originalRequest) {
			var responseFromServer = originalRequest.responseText;
			//alert(responseFromServer);
			var resetMailinfoDiv = $("resetMailinfoDiv");
			resetMailinfoDiv.disabled = false;
			var submitMailinfoDiv = $("submitMailinfoDiv");
			submitMailinfoDiv.disabled = false;
		}
			
		function changeContactAjaxDiv() {
			var contactAjaxDiv = $("contactAjaxDiv");
			var icontactAjaxDivNewHTML = "Παρακαλώ Περιμένετε <br/>";
			icontactAjaxDivNewHTML = icontactAjaxDivNewHTML + "<img src='images/ajax/ajax-loader.gif' />";
			contactAjaxDiv.innerHTML = icontactAjaxDivNewHTML;
		}