﻿function InitType(){
    $('#pnlType').find("table").find("tr:eq(0)").find("td:eq(1)").addClass("tdType");
    $('#pnlType').find("table").css("borderBottom","1px solid #FFF3F3");
    $('#pnlType').find("table").find("tr:eq(0)").find("td:eq(1)").hover(
	    function() {$(this).addClass("tdTypeOver");}
	    , 
	    function() {$(this).removeClass("tdTypeOver");}
	    );

    $('#pnlType').find("table").find("tr:eq(0)").find("td:eq(1)").click(
	    function() {
	        var obj=document.getElementById($(this.parentNode).find("td:eq(0)").find("input[@type=checkbox]").attr("id"));
	        obj.checked=!obj.checked;
	        executeType();
	    }
	    );

    $('#pnlType').find("input").click(
	    function() {
	        executeType();
	        }
	    );
}

function chkTypeAllClick(){
    var chk=document.getElementById("chkTypeAll").checked;
    $("#pnlType").find("input").attr("checked",chk)
    executeType();
}

function executeType(){
    var val="";
    var objTd;
    var AllChecked=true;
    $("#pnlType").find("input").each(function(i){
      objTd=this.parentNode.parentNode.cells[1];
      if(this.checked==true){
        val+=this.value+"_";
        objTd.className="tdTypeSelect";
      }else{
        objTd.className="tdType";
        AllChecked=false;
      }
    });
    document.getElementById("chkTypeAll").checked=AllChecked;
    PageMethods.GetPublishersHTML(val,listPublishers)
    document.getElementById("_Types").value=val;
}

function listPublishers(val){
    document.getElementById("pnlPublisher").innerHTML=val;
    InitPublisher();
    executePublisher()
    
    document.getElementById("chkPublisherAll").checked=false;
    document.getElementById("chkSectionAll").checked=false;
    document.getElementById("pnlSection").innerHTML=""
    document.getElementById("_Publishers").value="";
    document.getElementById("_Sections").value="";
}






function InitPublisher(){
    $('#pnlPublisher').find("table").find("tr:eq(0)").find("td:eq(1)").addClass("tdType");
    $('#pnlPublisher').find("table").css("border-bottom","1px solid #FFF3F3");
    $('#pnlPublisher').find("table").find("tr:eq(0)").find("td:eq(1)").hover(
	    function() {$(this).addClass("tdPublisherOver");}
	    , 
	    function() {$(this).removeClass("tdPublisherOver");}
	    );

    $('#pnlPublisher').find("table").find("tr:eq(0)").find("td:eq(1)").click(
	    function() {
	        var obj=document.getElementById($(this.parentNode).find("td:eq(0)").find("input[@type=checkbox]").attr("id"));
	        obj.checked=!obj.checked;
	        executePublisher();
	    }
	    );

    $('#pnlPublisher').find("input").click(
	    function() {
	        executePublisher();
	        }
	    );
}

function chkPublisherAllClick(){
    var chk=document.getElementById("chkPublisherAll").checked;
    $("#pnlPublisher").find("input").attr("checked",chk)
    executePublisher();
}

function executePublisher(){
    var val="";
    var objTd;
    var AllChecked=true;
    $("#pnlPublisher").find("input").each(function(i){
      objTd=this.parentNode.parentNode.cells[1];
      if(this.checked==true){
        val+=this.value+"_";
        objTd.className="tdPublisherSelect";
      }else{
        objTd.className="tdPublisher";
        AllChecked=false;
      }
    });
    document.getElementById("chkPublisherAll").checked=AllChecked;
    PageMethods.GetSectionsHTML(val,listSections)
    document.getElementById("_Publishers").value=val;
    
}

function listSections(val){
    document.getElementById("pnlSection").innerHTML=val;
    InitSection();
    document.getElementById("chkSectionAll").checked=false;
    document.getElementById("_Sections").value="";
}






function InitSection(){
    $('#pnlSection').find("table").find("tr:eq(0)").find("td:eq(1)").addClass("tdType");
    $('#pnlSection').find("table").css("border-bottom","1px solid #FFF3F3");
    $('#pnlSection').find("table").find("tr:eq(0)").find("td:eq(1)").hover(
	    function() {$(this).addClass("tdSectionOver");}
	    , 
	    function() {$(this).removeClass("tdSectionOver");}
	    );

    $('#pnlSection').find("table").find("tr:eq(0)").find("td:eq(1)").click(
	    function() {
	        var obj=document.getElementById($(this.parentNode).find("td:eq(0)").find("input[@type=checkbox]").attr("id"));
	        obj.checked=!obj.checked;
	        executeSection();
	    }
	    );

    $('#pnlSection').find("input").click(
	    function() {
	        executeSection();
	        }
	    );
}




function chkSectionAllClick(){
    var chk=document.getElementById("chkSectionAll").checked;
    $("#pnlSection").find("input").attr("checked",chk)
    executeSection();
}

function executeSection(){
    var val="";
    var objTd;
    var AllChecked=true;
    $("#pnlSection").find("input").each(function(i){
      objTd=this.parentNode.parentNode.cells[1];
      if(this.checked==true){
        val+=this.value+"_";
        objTd.className="tdSectionSelect";
      }else{
        objTd.className="tdSection";
        AllChecked=false;
      }
    });
    document.getElementById("chkSectionAll").checked=AllChecked;
    document.getElementById("_Sections").value=val;

}


