

function fix_shadow(){

	var inner_height = parseInt(document.getElementById('shadow_inner').offsetHeight);

	document.getElementById('shadow_stretch').style.height = (inner_height - 15) + "px";
	document.getElementById('shadow_stretch').style.marginTop = "-" + (inner_height - 3) + "px";

}


function ajaxSend() {
	var contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert('Sorry, we could not send your contact request at this time.');
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function() {
		if (ajaxRequest.readyState == 4) {
			document.getElementById('contact-form').innerHTML = '<br /><br /><span style="text-align:center;"><p>Thank you. We will contact you shortly regarding your query.</p></span>';
		}
	}
	queryString = validateForm('contact');
	if (queryString != false) {
		ajaxRequest.open("POST", "includes/php/contact_mailer.php", true);
		document.getElementById('contact').style.display = 'none';
		document.getElementById('contact-form').innerHTML = '<br /><br /><span style="text-align:center;"><img src="images/loading.gif" /><br/><p>Please wait.. while we send your request.</p></span>';
		ajaxRequest.setRequestHeader('Content-Type', contentType);
		ajaxRequest.send(queryString);
	}
}

var fn = new Array();
fn['your_name'] = 'Your Name';
fn['your_email'] = 'Your Email';
fn['your_phone'] = 'Your Phone';
fn['your_contact_method'] = 'Contact Method';
//fn['your_message'] = 'Your Message';


function validateForm(form_id) {
	elems = document.getElementById(form_id).elements;
	var ret = Array();
	var error = new Array();
	for (var i=0;i<elems.length;i++) {
		if (typeof fn[elems[i].name] != 'undefined') {
			if (elems[i].type == 'select-one') {
				if (elems[i].options[elems[i].selectedIndex].value == '') {
						error.push(fn[elems[i].name]);
				}
			} else {
				if (elems[i].value == '') {
					error.push(fn[elems[i].id]);
				}
			}
		}
		ret.push(elems[i].name+'='+elems[i].value);
	}
	if (error.length == 0) {
		return ret.join('&')
	} else {
		//alert("Submission Error - The following fields require data.\n\nPlease correct the following:\n  - "+error.join("\n  - "));
		alert("Please fill in all fields");
		return false;
	}
}


function confirmOrderSubmit() {
	var contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert('Sorry, we could not send your contact request at this time.');
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function() {
		if (ajaxRequest.readyState == 4) {
			document.getElementById('confirm_order_result').innerHTML = '<span style="text-align:center;"><p>Thank you. We will contact you shortly regarding your order.</p></span>';
		}
	}
	queryString = validateForm('confirm_order_form');
	if (queryString != false) {
		ajaxRequest.open("POST", "includes/php/order_mailer.php", true);
		document.getElementById('confirm_order_result').innerHTML = '<span style="text-align:center;"><img src="images/loading.gif" /><br/><p>Please wait.. while we send through your order.</p></span>';
		ajaxRequest.setRequestHeader('Content-Type', contentType);
		ajaxRequest.send(queryString);
	}
}


function startTestimonials() {
    var arrayLength = testimonial_array.length;
    
    for(var i=0; i<arrayLength; i++){
         $(testimonial_array[i]).hide();    
    }
    
    rotateTestimonials();
    //setInterval('rotateTestimonials()', 5000);    
}

var currentTestimonialShown = -1;

function rotateTestimonials() {
    var arrayLength = testimonial_array.length;    

    var nowShowId = currentTestimonialShown + 1;
    
    if(nowShowId == arrayLength){
        nowShowId = 0;
    }
    
    if(currentTestimonialShown >= 0){
        $(testimonial_array[currentTestimonialShown]).hide();
    }
    
    currentTestimonialShown = nowShowId;
    
    $(testimonial_array[nowShowId]).show('slide', {}, 500);
    //$(testimonial_array[nowShowId]).show();
}

