/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function SingleSelect(regex,current)
{
    re = new RegExp(regex);

    for(i = 0; i < document.forms[0].elements.length; i++) {

        elm = document.forms[0].elements[i];

        if (elm.type == 'checkbox') {

            if (re.test(elm.name)) {

                elm.checked = false;
            }
        }
    }
    current.checked = true;
}

function show(id)
{
    hideshow = document.getElementById(id);
    if (hideshow.style.display == 'none')
    {
        hideshow.style.display = '';
    } else {
        window.clearTimeout(timeoutID);
    }
}

function hide(id) {
    timeoutID=setTimeout("hideshow.style.display = 'none'", 500); //Set delay
}

function stopTimer() {
    window.clearTimeout(timeoutID);
}

function updateListWS()
{
  //  alert("within update");
    timeoutID=setTimeout("hideshow.style.display = 'none'", 500);
    var xmlhttp;
    var urlPrefix = "";
    var newDate = new Date;
    var randomnumber=newDate.getTime();
    var fb_msg = window.document.getElementById('fb_msg').value;
    var fb_value = getFeedbackOption();
    var submit_fb = window.document.getElementById('submit_fb').value;
    var baseURL = window.document.getElementById('baseURL').value;


        urlPrefix="http://zautos.com/ConfiguratorFeedback/ZAutosPortalFeedbackWS";
    
        

    var url = urlPrefix + "?fb_msg=" + escape(fb_msg)
    + "&fb_value=" + escape(fb_value)
    + "&submit_fb=" + escape(submit_fb)
    + "&baseURL=" + escape(baseURL)
    + "&random=" + randomnumber;

   // alert(url);

    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)  {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState==4) {
            if (xmlhttp.status == 200) {
                //alert("success");
             window.document.getElementById('fb_msg').value = " ";
             
            }
        }
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}

function getFeedbackOption()
{
    var option = "";
    if(window.document.getElementById('fb_value1').checked)
        option = window.document.getElementById('fb_value1').value;
    if(window.document.getElementById('fb_value2').checked)
        option = window.document.getElementById('fb_value2').value;
    if(window.document.getElementById('fb_value3').checked)
        option = window.document.getElementById('fb_value3').value;
    if(window.document.getElementById('fb_value4').checked)
        option = window.document.getElementById('fb_value4').value;

    return option;
    //making a change to be able to update to svn server
}
