// JavaScript Document
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
if (window.attachEvent) window.attachEvent("onload", correctPNG);

function bookmarksite(title){
	url = self.location;
	
	if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all) {// ie
		window.external.AddFavorite(url, title);
	} else if (window.sidebar) {// firefox 
		window.sidebar.addPanel(title, url, "");
	}

}

function show(id) {
	$("span#service_" + id).toggle();
}

function validateCaptcha()
{
    challengeField = $("input#recaptcha_challenge_field").val();
    responseField = $("input#recaptcha_response_field").val();
    //alert(challengeField);
    //alert(responseField);
    //return false;
    var html = $.ajax({
    type: "POST",
    url: "ajax.recaptcha.php",
    data: "recaptcha_challenge_field=" + challengeField + "&amp;recaptcha_response_field=" + responseField,
    async: false
    }).responseText;
 
    if(html == "success")
    {
        $("#captchaStatus").html(" ");
        // Uncomment the following line in your application
        return true;
    }
    else
    {
        $("#captchaStatus").html("Your captcha is incorrect. Please try again");
        Recaptcha.reload();
        return false;
    }
}

$(document).ready(function() {
	$("#amount_1, #amount_2, #amount_3, #amount_4").click(function() {
		$("#total").attr("value", $(this).attr("value"));														
		
	});

});


function showhide(divid){
    
	if ($("#accessory").is(":checked")) {
		$("#amount_1, #amount_2, #amount_3").attr("disabled", "disabled");	
	} else {
		$("#amount_1, #amount_2, #amount_3").attr("disabled", "");	
	}
}




function processForm() {
    //get form variables
    var theItems = document.getElementsByName( "item" );
    
    var theQty = Number( document.getElementById( "qty" ).value );
    
    var theAcsy = document.getElementById( "accessory").checked;
    
    
    //set shipping rate
    var theShipping = 0;
    
    
    //variable for selected item
    var selectedItem;
    
    
    //variable for order total
    var orderTotal = 0.00;
    
    
    //the display box
    var outBox = document.getElementById( "total" );
    
    
    //set selectedItem = checked item
    for(var i = 0; i < theItems.length; i++) {
        if( theItems[i].checked) {
            selectedItem = theItems[i].value;
            
            break;
            
        }
        
    }
    
    
    //get price for selected item
    switch(selectedItem) {
        case "A":
        total = 278.00;
        
        break;
        
        case "B":
        total = 556.00;
        
        break;
        
        case "C":
        total = 834.00;
        
        break;
        
        default:
        total = 0.00;
        
    }
    
    
    //add accessory to base price if selected
    if( theAcsy ) {
        total = (1 * theQty);
        
    }
    
    
    //figure final total
    total = total;
    
    
    //output to text box
    outBox.value = "$" + total.toString();
    
}

