// JScript File

 function parseScript(_source) {
	    //alert("parse");
		var source = _source;
		var scripts = new Array();

		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
			var s = source.indexOf("<script");
			var s_e = source.indexOf(">", s);
			var e = source.indexOf("</script", s);
			var e_e = source.indexOf(">", e);

			// Add to scripts array
			scripts.push(source.substring(s_e+1, e));
			// Strip from source
			source = source.substring(0, s) + source.substring(e_e+1);
		}

		// Loop through every script collected and eval it
		for(var i=0; i<scripts.length; i++) {
			try {
				eval(scripts[i]);
			}
			catch(ex) {
				// do what you want here when a script fails
			}
		}

		// Return the cleaned source
		return source;
	}

function leftMenu(containerId, nameId, nameFId ,stateRequestId, serviceURL, serviceNameURL)
{
     this.absPath = "http://"+window.location.host;
     this.activeEl = null;
     var contContainer = document.getElementById(containerId);
     var nameCtr = document.getElementById(nameId);
     var nameFCtr = document.getElementById(nameFId);
	 var stateRequest = document.getElementById(stateRequestId);
     var gal = document.getElementById("ctrGaleryContainer");

     var activecontrol = null;
     this.select = function(senderId,sectionId, tbl){     	 sender =  document.getElementById(senderId);
     	 if(sender){                if(this.activeEl){                	this.activeEl.className = "inactiv_menu";                }
                sender.className = "activ_menu";
                this.activeEl =  sender;

				 ctPdf = document.getElementById('ctrPdf');
                if(ctPdf){
                	ctPdf.innerHTML = "<a href=\"/msabiat/comp/pdf/product.php?id="+sectionId+"&tbl="+tbl+"\" target=\"_blank\"><img src=\"/images/pdf.gif\" alt=\"PDF\" width=\"26\" height=\"26\" /></a><a href=\"/print.php?id="+sectionId+"&tbl="+tbl+"\"  target=\"_blank\"><img src=\"/images/print_big.gif\" alt=\"печать\" width=\"26\" height=\"26\" /></a>";
                }

                this.getNameC(this.absPath+serviceNameURL, sectionId, tbl);
                this.getNameCF(this.absPath+"/servicefunc/getname_s.php", sectionId, tbl);
                this.getContent(this.absPath+serviceURL,sectionId, tbl);     	 }     }

	this.selectWithPage = function(senderId,sectionId,stNumb,count,tbl){
     	 sender =  document.getElementById(senderId);


     	 if(sender){
                if(this.activeEl){
                	this.activeEl.className = "inactiv_menu";
                }
                sender.className = "activ_menu";
                this.activeEl =  sender;
               }
                ctPdf = document.getElementById('ctrPdf');
                if(ctPdf){                	ctPdf.innerHTML = "<a href=\"/msabiat/comp/pdf/product.php?id="+sectionId+"&tbl="+tbl+"\" target=\"_blank\"><img src=\"/images/pdf.gif\" alt=\"PDF\" width=\"26\" height=\"26\" /></a><a href=\"/print.php?id="+sectionId+"&tbl="+tbl+"\" target=\"_blank\"><img src=\"/images/print_big.gif\" alt=\"печать\" width=\"26\" height=\"26\" /></a>";                }
                this.getNameC(this.absPath+serviceNameURL, sectionId, tbl);
                this.getNameCF(this.absPath+"/servicefunc/getname_s.php", sectionId, tbl);
                this.getContentWithPage(this.absPath+serviceURL,sectionId,stNumb, count,tbl);
                this.getGaleryWithPage(this.absPath+"/servicefunc/getgalery.php",sectionId,stNumb, count,tbl);
     }
		this.getContentByTag = function(serviceURL, senderId, tagId, mode){                this.getNameC(this.absPath+"/servicefunc/getname_info.php", tagId, "addinfo");
                btnGoBack = document.getElementById("ctrGoBack");
                if(btnGoBack) btnGoBack.innerHTML = "";
               // senderT =  document.getElementById(senderId);
               // if(senderT){
                requestT=false;
                try {requestT=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {requestT=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)requestT=new XMLHttpRequest();}
                        }
                if (requestT){

                	stateRequest.style.display = "block";
                	contContainer.style.display = "none";
                    requestT.onreadystatechange = this.readycontentT;
                    requestT.open("GET", serviceURL+"?id="+tagId+"&mode="+mode, true);
                    requestT.send(null);
                }
 			//} else{alert("No Sender");}		}

  		 this.readycontentT = function(){
          if (requestT.readyState == 4)
          {
          if (requestT.status == 200)
          {
               contContainer.innerHTML = requestT.responseText;
               stateRequest.style.display = "none";
               contContainer.style.display = "block";
          } else alert("Error"+ requestT.status+":\n" + requestT.statusText);
          }
        }

		this.getGaleryWithPage = function(serviceURL,sectionId,stNumb,count,tbl)
            {
                requestgal=false;

                try {requestgal=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {requestgal=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)requestgal=new XMLHttpRequest();}
                        }
                if (requestgal){

                	stateRequest.style.display = "block";
                	contContainer.style.display = "none";
                    requestgal.onreadystatechange = this.readygal;

                    requestgal.open("GET", serviceURL+"?id="+sectionId+"&sn="+stNumb+"&cn="+count+"&tbl="+tbl, true);
                    requestgal.send(null);
                }
            }

          this.readygal = function(){
          if (requestgal.readyState == 4)
          {
          if (requestgal.status == 200)
          {
              if(gal)
          	   gal.innerHTML = requestgal.responseText;
               parseScript(requestgal.responseText);
               stateRequest.style.display = "none";
               contContainer.style.display = "block";
          } else alert("Error"+ requestgal.status+":\n" + requestgal.statusText);
          }
        }



		this.getContentWithPage = function(serviceURL,sectionId,stNumb,count,tbl)
            {
                request=false;
                try {request=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {request=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)request=new XMLHttpRequest();}
                        }
                if (request){
                	stateRequest.style.display = "block";
                	contContainer.style.display = "none";
                    request.onreadystatechange = this.readycontent;
                   // alert(serviceURL+"?id="+sectionId+"&sn="+stNumb+"&cn="+count+"&tbl="+tbl);
                    request.open("GET", serviceURL+"?id="+sectionId+"&sn="+stNumb+"&cn="+count+"&tbl="+tbl, true);
                    request.send(null);
                }
            }



      this.getContent = function(serviceURL,sectionId, tbl)
            {
                request=false;
                try {request=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {request=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)request=new XMLHttpRequest();}
                        }
                if (request){
                	stateRequest.style.display = "block";
                	contContainer.style.display = "none";
                    request.onreadystatechange = this.readycontent;

                    request.open("GET", serviceURL+"?id="+sectionId+"&tbl", true);
                    request.send(null);
                }
            }

          this.readycontent = function(){
          if (request.readyState == 4)
          {
          if (request.status == 200)
          {
               contContainer.innerHTML = request.responseText;
               parseScript(request.responseText);
               stateRequest.style.display = "none";
               contContainer.style.display = "block";
          } else alert("Error"+ request.status+":\n" + request.statusText);
          }
        }

         this.getNameC = function(serviceURL,sectionId, tbl)
            {

                request1=false;
                try {request1=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {request1=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)request1=new XMLHttpRequest();}
                        }
                if (request1){
                    request1.onreadystatechange = this.readyname;
                    //alert(serviceURL+"?id="+sectionId+"&tbl="+tbl);
                    request1.open("GET", serviceURL+"?id="+sectionId+"&tbl="+tbl, true);
                    //request1.open("POST", serviceURL, true);
                    //var params = "id="+sectionId+"&tbl="+tbl;

                    request1.send(null);
                }
            }

          this.readyname = function(){
          if (request1.readyState == 4)
          {
          if (request1.status == 200)
          {
               nameCtr.innerHTML = request1.responseText;
               //if(nameFCtr)
               //		nameFCtr.innerHTML = request1.responseText;
          } else alert("Error - "+ request1.status+":\n" + request1.statusText+"\n Resp: "+request1.responseText);
          }
        }

        this.getNameCF = function(serviceURL,sectionId, tbl)
            {

                request2=false;
                try {request2=new ActiveXObject('Msxml2.XMLHTTP');}
                catch(e){try {request2=new ActiveXObject('Microsoft.XMLHTTP');}
                         catch(e){if(window.XMLHttpRequest)request2=new XMLHttpRequest();}
                        }
                if (request2){
                    request2.onreadystatechange = this.readynameCF;

                    request2.open("GET", serviceURL+"?id="+sectionId+"&tbl="+tbl, true);
                    request2.send(null);
                }
            }

          this.readynameCF = function(){
          if (request2.readyState == 4)
          {
          if (request2.status == 200)
          {
               //nameCtr.innerHTML = request1.responseText;
               if(nameFCtr)
               		nameFCtr.innerHTML = request2.responseText;
          } else alert("Error"+ request2.status+":\n" + request2.statusText);
          }
        }




}
