// JavaScript Document

// Ajax Email Form Mailer

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sendemail() {
	var subject = document.contactform.subject.value;
	var feedbacktype = document.contactform.feedbacktype.value;
	var comments = document.contactform.comments.value;

	var contentrating;
	for (var i = 0; i < document.contactform.contentrating.length; i++) {   
	   if(document.contactform.contentrating[i].checked){
		  contentrating = document.contactform.contentrating[i].value;
	   }
	}
	
	var layoutRating;
	for (var i = 0; i < document.contactform.layoutRating.length; i++) {   
	   if(document.contactform.layoutRating[i].checked){
		  layoutRating = document.contactform.layoutRating[i].value;
	   }
	}
	
	var useRating;
	for (var i = 0; i < document.contactform.useRating.length; i++) {   
	   if(document.contactform.useRating[i].checked){
		  useRating = document.contactform.useRating[i].value;
	   }
	}
	
	var overallRating;
	for (var i = 0; i < document.contactform.overallRating.length; i++) {   
	   if(document.contactform.overallRating[i].checked){
		  overallRating = document.contactform.overallRating[i].value;
	   }
	}

	var visitPurpose = document.contactform.visitPurpose.value;
	var lookingFor = document.contactform.lookingFor.value;
	var name = document.contactform.name.value;
	var company = document.contactform.company.value;
	var email = document.contactform.email.value;
	var phone = document.contactform.phone.value;
	document.contactform.send.disabled=true; 
	document.contactform.send.value='Sending....';

    http.open('get', 'Templates/contact.php?subject='+subject+'&feedbacktype='+feedbacktype+'&comments='+comments+'&contentrating='+contentrating+'&layoutRating='+layoutRating+'&useRating='+useRating+'&overallRating='+overallRating+'&visitPurpose='+visitPurpose+'&lookingFor='+lookingFor+'&name='+name+'&company='+company+'&email='+email+'&phone='+phone+'&action=send');
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
         
        }
    }
}

// ClearIt

function clearIt(what)
{
	if(what.value == what.defaultValue) what.value = '';
}
function setIt(what)
{
	if(what.value == '') what.value = what.defaultValue;
}

// sfhover

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


