
function ListComparingPhones(){
    var xhr = new createXHR();
    xhr.open('GET', './AjaxServer.aspx?action=ListComparingPhones', true);
    xhr.onreadystatechange = function (){
        if (xhr.readyState == 4 && xhr.status == 200){
            if (xhr.responseText=="") return;
                eval(xhr.responseText);
            }
        };
    xhr.setRequestHeader('If-Modified-Since', 'Thu, 1 Jan 1970 00:00:00 GMT');
    xhr.setRequestHeader('Cache-Control', 'no-cache');
    xhr.send(null);
}

function SelectPhoneForCompare(id,img){
    var xhr = new createXHR();
    xhr.open('GET', './AjaxServer.aspx?action=AddPhoneToCompare&id=' + id + '&img='+img, true);
    xhr.onreadystatechange = function (){
        if (xhr.readyState == 4 && xhr.status == 200){
            if (xhr.responseText=="") return;
                eval(xhr.responseText);
            }
        };
    xhr.setRequestHeader('If-Modified-Since', 'Thu, 1 Jan 1970 00:00:00 GMT');
    xhr.setRequestHeader('Cache-Control', 'no-cache');
    xhr.send(null);
}


function ComparingPhone(position,phoneId,fileId){
    var img;
    var lnk;
    
    try{
        var img=document.getElementById( 'comparedImg' + position );
        var lnk=document.getElementById( 'removeLnk' + position );

        img.style.visibility='hidden'; lnk.style.visibility='hidden';        

        img.setAttribute("src",fileId);
        lnk.setAttribute("phoneId",phoneId);

        if( phoneId!='undefined' && phoneId > 0 ){      
            img.style.visibility='visible';
            lnk.style.visibility='visible';
        }
    }catch(e){
//        alert(e.toString());
    }
    
}

function ComparingPhones(phone1,file1,phone2,file2,phone3,file3){

    ComparingPhone(1,phone1,file1);
    ComparingPhone(2,phone2,file2);
    ComparingPhone(3,phone3,file3);
}

function RemovePhoneFromCompare( me ){

    var phoneId = me.getAttribute('phoneId');

    var xhr = new createXHR();
    xhr.open('GET', './AjaxServer.aspx?action=RemovePhoneFromCompare&id=' + phoneId, true);
    xhr.onreadystatechange = function (){
        if (xhr.readyState == 4 && xhr.status == 200){
            if (xhr.responseText=="") return;
                eval(xhr.responseText);
            }
        };
    xhr.setRequestHeader('If-Modified-Since', 'Thu, 1 Jan 1970 00:00:00 GMT');
    xhr.setRequestHeader('Cache-Control', 'no-cache');
    xhr.send(null);
}

