
var Available = 1;


function toggleDiv(what,element){
     var el;
     el = document.getElementById(element);
	 
	 what.className=what.className == 'expanded' ? 'collapsed' : 'expanded'
	 
     if(el.style.display != 'block')
     {
       el.style.display = 'block';
     }
     else
     {
       el.style.display = '';
     }
}

function toggleDivtwo(what,element){
     var el;
     el = document.getElementById(element);
	 
	 what.className=what.className == 'expandedtwo' ? 'collapsedtwo' : 'expandedtwo'
	 
     if(el.style.display != 'block')
     {
       el.style.display = 'block';
     }
     else
     {
       el.style.display = '';
     }


}

$(document).ready(function () {


   $("#jscheck").hide(); 

    var hoverColor = "#ffdc87";
    var selectedColor = "#6699ff";
    var normColor = "#FFFFFF";


    $(".collapsedtwo").hover(function () {
        $(this).parent("li").css("background", "white" );
    }, function () {
        $(this).parent("li").css("background", "transparent");
    });

    $(".expandedtwo").hover(function () {
        $(this).parent("li").css("background", "white");
    }, function () {
        $(this).parent("li").css("background", "transparent");
    });
});


function formatPhone(phonenum) {
    var regexObj = /^(?:\+?1[-. ]?)?(?:\(?([0-9]{3})\)?[-. ]?)?([0-9]{3})[-. ]?([0-9]{4})$/;
    if (regexObj.test(phonenum)) {
        var parts = phonenum.match(regexObj);
        var phone = "";
        if (parts[1]) { phone += "(" + parts[1] + ")"; }
        phone += parts[2] + "-" + parts[3];
        return phone;
    }
    else {
        //invalid phone number
        return phonenum;
    }
}

function formatPhoneBox(controlID) {
    var control = document.getElementById(controlID);
    control.value = formatPhone(control.value);
}

function ProductAvailable(x) {

    Available = x;

}

function checkProductAvailable() {

    var holder = document.getElementById("holder");
    var newmessage = document.createElement("span");
    var message = document.getElementById("message");

    newmessage.id = 'message';

    if (Available == 0) {
        $('#boxTest').show();
        $("#linkRequest").trigger('click');
        if (message == null) {
            holder.appendChild(newmessage);
            newmessage.appendChild(document.createTextNode("Please consult factory for specifications"));
        }
    }
    else if (Available == 2) {
        window.open('/documents/Products/GRMA-010D/grma10d-specifications.pdf', 'Specifications');
    }
    else {
        window.open('/documents/Products/GRMA-010B/grma10b-specifications.pdf', 'Specifications');
    }

}
