var leftList;
var rightList;

function delAttribute(){
   leftList = document.getElementById("availableOptions");
    rightList = document.getElementById("selectedOptions");
    var addIndex = rightList.selectedIndex;
    if (addIndex < 0)
        return false;
    leftList.appendChild(
            rightList.options.item(addIndex));
    selectNone(rightList, leftList);
    setSize(rightList, leftList);
    return false;
}
function addAttribute(){
  leftList = document.getElementById("availableOptions");
    rightList = document.getElementById("selectedOptions");
    var addIndex = leftList.selectedIndex;
    if (addIndex < 0)
        return false;
    rightList.appendChild(leftList.options.item(addIndex));
    selectNone(rightList, leftList);
    setSize(rightList, leftList);
    return false;
}

function setTop(top){
	document.getElementById
      ('someLayer').style.top = top;
}
function setLayerTop(lyr,top){
	lyr.style.top = top;
}


function setSize(list1,list2){
    list1.size = getSize(list1);
    list2.size = getSize(list2);
}

function selectNone(list1,list2){
    list1.selectedIndex = -1;
    list2.selectedIndex = -1;
    addIndex = -1;
    selIndex = -1;
}


function getSize(list){
    /* Mozilla ignores whitespace,
       IE doesn't - count the elements
       in the list */
    var len = list.childNodes.length;
    var nsLen = 0;
    //nodeType returns 1 for elements
    for(i=0; i<len; i++){
        if(list.childNodes.item(i).nodeType==1)
            nsLen++;
    }
    if(nsLen<2)
        return 2;
    else
        return nsLen;
}

function delAll(){
leftList = document.getElementById("availableOptions");
    rightList = document.getElementById("selectedOptions");
    var len = rightList.length - 1;
    for (i = len; i >= 0; i--) {
        leftList.appendChild(rightList.item(i));
    }
    selectNone(rightList, leftList);
    setSize(rightList, leftList);
    return false;

}

function addAll(){
     leftList = document.getElementById("availableOptions");
    rightList = document.getElementById("selectedOptions");

    var len = leftList.length - 1;
    for (i = len; i >= 0; i--) {
        rightList.appendChild(leftList.item(i));
    }
    selectNone(leftList, rightList);
    setSize(leftList, rightList);
    return false;
}

function showSelected(){
    var optionList =
       document.getElementById
      ("selectedOptions").options;
    var data = '';
    var len = optionList.length;
    for(i=0; i<len;i++){

        data += optionList.item(i).value;
		 data += ',';
    }
	document.forms['doctorForm'].hospital.value=data;
    alert(data);
}

function selectAll(){
			var expert='';
			 var selectList = document.getElementById("selectedOptions");
    		 for(var i = 0;i < selectList.length;i++)    {
    			 selectList.options[i].selected = true;
  		 	 }

		}

function displayBlock(id1,id2){
        var id1Obj=document.getElementById(id1);
        var id2Obj=document.getElementById(id2);
        id1Obj.style.display="none";
        id2Obj.style.display="";
    }

function changeStyle1(id){
        $('div1').style.background="url(images/hospital/ourdoctor.gif)";
        $('div2').style.background="url(images/hospital/agent_but.gif)";
        $('div3').style.background="url(images/hospital/treatment.gif)";
        var imageUrl;
        if(id=='div1')
            imageUrl="url(images/hospital/ourdoctorW.gif)";
        else if(id=='div2')
            imageUrl="url(images/hospital/agentW_but.gif)";
        else
            imageUrl="url(images/hospital/treatmentW.gif)";
        $(id).style.background=imageUrl;
    }

function showDoctorList(hospitalId){
        var url = "/doctor.html?method=viewAllDoctorsWithAjax&hospitalId="+hospitalId+"&"+Date();
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });
    }

function showAgentList(hospitalId){
        var url = "/editAgent.html?method=showAgentListWithAjax&hospitalId="+hospitalId+"&"+Date();
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });
    }

function showTreatmentList(hospitalId){
        var url = "/treatment.html?method=showTreatmentListWithAjax&hospitalId="+hospitalId+"&"+Date();
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });
    }

function showDoctorListForPagination(hospitalId,pageSize,pageNo,totalSize){
        var url="/doctor.html?method=viewAllDoctorsForPagination&";
        var params="hospitalId="+hospitalId+"&pageNo="+pageNo+"&pageSize="+pageSize+"&totalSize="+totalSize+"&"+Date();
        url+=params;
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });

    }

function showAgentListForPagination(hospitalId,pageSize,pageNo,totalSize){
        var url="/editAgent.html?method=viewAllAgentsForPagination&";
        var params="hospitalId="+hospitalId+"&pageNo="+pageNo+"&pageSize="+pageSize+"&totalSize="+totalSize+"&"+Date();
        url+=params;
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });

    }

function showTreatmentListForPagination(hospitalId,pageSize,pageNo,totalSize){
        var url="/treatment.html?method=viewAllTreatmentsForPagination&";
        var params="hospitalId="+hospitalId+"&pageNo="+pageNo+"&pageSize="+pageSize+"&totalSize="+totalSize+"&"+Date();
        url+=params;
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });

    }

function showHospitalListForPagination(doctorId,pageSize,pageNo,totalSize){
        var url="/hospital.html?method=viewHospitalForPagination&";
        var params="doctorId="+doctorId+"&pageNo="+pageNo+"&pageSize="+pageSize+"&totalSize="+totalSize+"&"+Date();
        url+=params;
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });

    }

function showTreatmentListForPaginationForDoctor(doctorId,pageSize,pageNo,totalSize){
        var url="/treatment.html?method=viewTreatmentsForPagination&";
        var params="doctorId="+doctorId+"&pageNo="+pageNo+"&pageSize="+pageSize+"&totalSize="+totalSize+"&"+Date();
        url+=params;
        var myAjax = new Ajax.Updater('commonPage',url, {method: 'get',onComplete:function(){}
        });

    }

function changeStyleInlineHospitalsTreatments(id){
	$('hospitals').style.background="url(images/treatment/HospitalG.gif)";
	$('treatments').style.background="url(images/hospital/treatment.gif)";
	var imageUrl;
	if(id=='hospitals')
	    imageUrl="url(images/treatment/treatments-list-page_03.gif)";
	else
	    imageUrl="url(images/hospital/treatmentW.gif)";
    $(id).style.background=imageUrl;
}