// Just a stub function we'll tell ajaxObject to call when it's done
// callback functions get responseText, and responseStat respectively
// in their arguments.
function fin(responseTxt,responseStat) {
  //alert(responseStat+' - '+responseTxt);
}

// create a new ajaxObject, give it a url it will be calling and
// tell it to call the function "fin" when its got data back from the server.
//var test1 = new ajaxObject('http://someurl.com/server.cgi',fin);
//    test1.update();
               
// create a new ajaxObject, give it a url and tell it to call fin when it
// gets data back from the server.  When we initiate the ajax call we'll
// be passing 'id=user4379' to the server.           
//var test2 = new ajaxObject('http://someurl.com/program.php',fin);
//    test2.update('id=user4379');
               
// create a new ajaxObject but we'll overwrite the callback function inside
// the object to more tightly bind the object with the response hanlder.


// create a new ajaxObject and pass the data to the server (in update) as
// a POST method instead of a GET method.
//var test4 = new ajaxObject('http://someurl.com/postit.cgi', fin);
//   test4.update('coolData=47&userId=user49&log=true','POST'); 


function ajaxObject(url, callbackFunction) {
	var that=this;     
  	this.updating = false;
  	this.abort = function() {
    	if (that.updating) {
      		that.updating=false;
      		that.AJAX.abort();
      		that.AJAX=null;
    	}
	}
	this.update = function(passData,postMethod) {
    	if (that.updating) { 
			return false;
		}
    	that.AJAX = null;                         
    	if (window.XMLHttpRequest) {             
      		that.AJAX=new XMLHttpRequest();             
    	} else {                                 
      		that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    	}                                             
    	if (that.AJAX==null) {                             
      		return false;                               
    	} else {
      		that.AJAX.onreadystatechange = function() { 
        		if (that.AJAX.readyState==4) {             
          			that.updating=false;               
          			that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);       
          			that.AJAX=null;                                         
        		}                                                     
      		}                                                       
      		that.updating = new Date();                             
      		if (/post/i.test(postMethod)) {
        		var uri=urlCall+'?'+that.updating.getTime();
        		that.AJAX.open("POST", uri, true);
        		that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        		that.AJAX.send(passData);
      		} else {
        		var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());
        		that.AJAX.open("GET", uri, true);                             
        		that.AJAX.send(null);                                         
      		}             
      		return true;                                             
    	}                                                                           
  	}
  	var urlCall = url;       
  	this.callback = callbackFunction || function () { };
  
}

var AjaxCategoryIdArr=new  Array();


var update=0;
function ShowProcess(baseurl,cid){
   //alert(attributeDisplay);
  AjaxCategoryIdArr.push(cid);
  
 //if(update!=1){
  
	link= baseurl+'process.php?cid='+cid;
	
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
		    document.getElementById('result'+cid).style.display = "block";
            document.getElementById('showCat'+cid).style.display = "none";
            document.getElementById('HideCat'+cid).style.display = "block";
            
            // for internet explorer
        if(( document.getElementById('catArray'+cid).innerHTML=="")&&  
        ( document.getElementById('ProductArray'+cid).innerHTML=="")){
            document.getElementById('result'+cid).style.display = "none";
        } 
           
          // code for category drag and drop 
       if( document.getElementById('catArray'+cid).innerHTML!=""){
     
          var test;
          test=document.getElementById('catArray'+cid).innerHTML;  
    	  var temp1; 
          temp1 =test.split(","); 
    	for(var j=0;j<temp1.length;j++){
    		   new Draggable("item-"+ temp1[j] , {revert:true})
               var initStr = "";
               
			  initStr ="Droppables.add(\"box\"+ "+ temp1[j] + ", {accept:'products', hoverclass:'cart-active',";
			  initStr +=" onDrop: function(element ) {    \n";
			  initStr += "temp2 =element.id.split(\"-\")\n";
			  initStr += "var TempLink \n";
		   
		      initStr +="if(temp2[1]=="+ temp1[j] +" && temp2[0]==\"item\"){ \n";
              initStr +=     "  return; \n"
			
			  
			 initStr += "}else if(temp2[0]==\"item\"){";
			 initStr += "TempLink=\"order.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
		     initStr +="   content:    TempLink, \n";
		     initStr +="   height:     150,\n";
		     initStr +="   width:      350\n";
		     initStr +="  }); \n";
			 initStr +="}else if(temp2[0]==\"product\"){ \n";
			 initStr +=" TempLink=\"order1.php?dropid="+temp1[j]+"&id=\"+temp2[1]+\"&catId=\"+temp2[2] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
			 initStr +="   content:    TempLink, \n";
			 initStr +="   height:     150,\n";
			 initStr +="   width:      350\n";
			 initStr +="  }); \n";
			 initStr +=" }else if(temp2[0]==\"Indproduct\"){ \n";
			 
	        initStr +=" TempLink=\"ind_cat.php?dropid="+temp1[j]+"&id=\"+temp2[1]+\"&catId=\"+temp2[2] \n";
			
      		initStr +="   Shadowbox.open({ \n" ;
			initStr +="    player:     'iframe', \n";
			initStr +="   title:      'Move or Copy', \n";
			initStr +="   content:    TempLink, \n";
			initStr +="   height:     150,\n";
			initStr +="   width:      350\n";
			initStr +="  }); \n";

			 initStr +=" }else if(temp2[0]==\"attributeIcon\"){ \n";
			 
		        initStr +=" TempLink=\"attribute_cat.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
				
	      		initStr +="   Shadowbox.open({ \n" ;
				initStr +="    player:     'iframe', \n";
				initStr +="   title:      'Move or Copy', \n";
				initStr +="   content:    TempLink, \n";
				initStr +="   height:     150,\n";
				initStr +="   width:      350\n";
				initStr +="  }); \n";
			
			
			
			initStr +="}else{ \n";
			initStr +=" alert(\"Invalid move\"); \n";
			initStr += "} \n"; 
			initStr +=" }}) \n";
				
			eval(initStr);
			
		}	
	       
	 }
	  // code for product drag and drop 
     if( document.getElementById('ProductArray'+cid).innerHTML!=""){
     	
          var testProduct;
          testProduct=document.getElementById('ProductArray'+cid).innerHTML;  
    	  var tempProduct; 
          tempProduct =testProduct.split(","); 
    	for(var j=0;j<tempProduct.length;j++){
    	
             new Draggable("product-"+tempProduct[j]+"-"+cid , {revert:true})
           
              var ProductToCatId;
              
             if( document.getElementById('ProductToCatId'+tempProduct[j]).innerHTML!=""){
                ProductToCatId=document.getElementById('ProductToCatId'+tempProduct[j]).innerHTML;
             }
             //alert(ProductToCatId);
              
              var initStr1 = "";
           
			 initStr1 ="Droppables.add(\"boxProduct\"+ "+ tempProduct[j] + ", {accept:'products', hoverclass:'cart-active',";
				
			 initStr1 +=" onDrop: function(element ) {    \n";
			 initStr1 += "temp2 =element.id.split(\"-\")\n";
			 initStr1 += "var TempLink \n";
			  
			 initStr1 +="if(temp2[1]=="+ tempProduct[j] +" && temp2[0]==\"product\"){ \n";
             initStr1 +=     " return; \n"
			 initStr1 += "}else if(temp2[0]==\"partProduct\"){";                                 
			 initStr1 += "TempLink=\"part_product.php?dropid="+tempProduct[j]+"&productcatId="+ProductToCatId+"&id=\"+temp2[1]+\"&catId=\"+temp2[2]\n";
			 initStr1 +="   Shadowbox.open({ \n"
			 initStr1 +="    player:     'iframe', \n";
			 initStr1 +="   title:      'Move or Copy', \n";
		     initStr1 +="   content:    TempLink, \n";
		     initStr1 +="   height:     150,\n";
		     initStr1 +="   width:      350\n";
		     initStr1 +="  }); \n";
             initStr1 +="}else{ \n";
			 initStr1 +=" alert(\"Invalid move\"); \n";
			 initStr1 += "} \n"; 
			 initStr1 +=" }}) \n";
				
			 eval(initStr1);
		   
             if(attributeDisplay==true){
                HideProduct(tempProduct[j]);
            }else{
                ShowProduct(tempProduct[j]);
            }
		}	
	       
	 }
	   Shadowbox.deact();
	   Shadowbox.init();
	 
  }
}
function ShowIndexPage(page){
indexPageNo=page;
     link= 'index1.php?page='+indexPageNo;
     var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
		//	document.getElementById('left').innerHTML = result;  
		   // document.getElementById('left').style.display = "block";
		}
		ShowPage();
		 Shadowbox.deact();
	        Shadowbox.init();
		    
}	
function SearchProduct(){
indexPageNo=1;
     searchKey= document.getElementById('keywordSearch').value;
     if(searchKey=='enter keyword' || searchKey=="" ){
     alert('Please enter keyword');
     }else{
    
     link= 'index1.php?page='+indexPageNo+'&keyword='+searchKey;
     var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
		//	document.getElementById('left').innerHTML = result;  
		   // document.getElementById('left').style.display = "block";
		}
	}	
	
		ShowPage();
		 Shadowbox.deact();
	        Shadowbox.init();
		    
}	
function ShowPage(){
   //alert(indexPageNo);

   if(AjaxCategoryIdArr!="" && searchKey!="" && searchKey!="enter keyword"){
        
         link= 'index1.php?id='+AjaxCategoryIdArr+'&page='+indexPageNo+'&keyword='+searchKey;
   }else if(searchKey!="" &&  searchKey!="enter keyword" && AjaxCategoryIdArr==""){
  
           link= 'index1.php?page='+indexPageNo+'&keyword='+searchKey;
           
  }else if(AjaxCategoryIdArr!=""){
  
           link= 'index1.php?id='+AjaxCategoryIdArr+'&page='+indexPageNo;
 
   }else{
    
    	 link= 'index1.php?page='+indexPageNo;
    }
  	 
   
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('left').innerHTML = result;  
		    document.getElementById('left').style.display = "block";
	 	
		    
	   
	 
		    // code for category drag and drop 
       if( document.getElementById('catArray').innerHTML!=""){
     	   var test;
          test=document.getElementById('catArray').innerHTML;  
         
    	  var temp1; 
          temp1 =test.split(","); 
     
    	for(var j=0;j<temp1.length;j++){
    	 
    	   new Draggable("item-"+ temp1[j] , {revert:true})
            var initStr = "";
			            
			initStr ="Droppables.add(\"box\"+ "+ temp1[j] + ", {accept:'products', hoverclass:'cart-active',";
			initStr +=" onDrop: function(element ) {    \n";
			initStr += "temp2 =element.id.split(\"-\")\n";
			initStr += "var TempLink \n";
			
			initStr +="if(temp2[1]=="+ temp1[j] +" && temp2[0]==\"item\"){ \n";
			initStr +=     "  return; \n"
			
			 
			initStr += "}else if(temp2[0]==\"item\"){";
			initStr += "TempLink=\"order.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			initStr +="   Shadowbox.open({ \n" ;
			initStr +="    player:     'iframe', \n";
			initStr +="   title:      'Move or Copy', \n";
			initStr +="   content:    TempLink, \n";
			initStr +="   height:     150,\n";
			initStr +="   width:      350\n";
			initStr +="  }); \n";
			initStr +="}else if(temp2[0]==\"product\"){ \n";
			initStr +=" TempLink=\"order1.php?dropid="+temp1[j]+"&id=\"+temp2[1]+\"&catId=\"+temp2[2] \n";
			initStr +="   Shadowbox.open({ \n" ;
			initStr +="    player:     'iframe', \n";
			initStr +="   title:      'Assign', \n";
			initStr +="   content:    TempLink, \n";
			initStr +="   height:     150,\n";
			initStr +="   width:      350\n";
			initStr +="  }); \n";
			initStr +=" }else if(temp2[0]==\"attributeIcon\"){ \n";
			 
			 initStr +=" TempLink=\"attribute_cat.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			initStr +="   Shadowbox.open({ \n" ;
			initStr +="    player:     'iframe', \n";
			initStr +="   title:      'Move or Copy', \n";
			initStr +="   content:    TempLink, \n";
			initStr +="   height:     150,\n";
			initStr +="   width:      350\n";
			initStr +="  }); \n";
			
						
			initStr +="}else{ \n";
			initStr +=" alert(\"Invalid move\"); \n";
			initStr += "} \n"; 
			initStr +=" }}) \n";
				
			eval(initStr);
			
		}	
	   
	 }
	   
	 if( document.getElementById('ProductArray').innerHTML!="" &&
    document.getElementById('ProductArray')!=null ){
     	
          var testProduct;
          testProduct=document.getElementById('ProductArray').innerHTML;  
    	  var tempProduct; 
          tempProduct =testProduct.split(","); 
    	for(var j=0;j<tempProduct.length;j++){
    	
             new Draggable("product-"+tempProduct[j] , {revert:true})
	    }
	  }  
	
      
  
		//for selct valus for delete
if(InputcatIdArr.length!=0){
 for(var p1=0;p1<InputcatIdArr.length;p1++){
  document.getElementById("category"+InputcatIdArr[p1]).checked=true;
 }
}

if(InputproductIdArr.length!=0){
 for(var p6=0;p6<InputproductIdArr.length;p6++){
 
  document.getElementById("productCheckId"+InputproductIdArr[p6]).checked=true;

 }
} 
	
		    Shadowbox.deact();
	        Shadowbox.init();
	       }  
          
}          

function HideProcess(baseurl,cid){
   // AjaxCategoryIdArr.pop(cid);
	 for ( var i in AjaxCategoryIdArr )
		{
		
			if(AjaxCategoryIdArr[i]==cid){
				AjaxCategoryIdArr.splice(i,1);
	
			}
  }
	link= baseurl+'process.php?cid='+cid;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			 
			document.getElementById('result'+cid).style.display = "none";
            document.getElementById('showCat'+cid).style.display = "block";
            document.getElementById('HideCat'+cid).style.display = "none";
			//document.getElementById('main').style.display = 'block';         

		}

	}
function HideProduct(id){
var str,tmpId;
 var els = document.getElementsByTagName("div"); 
 var elsLen = els.length;
for (var k=0;k < elsLen;k++) {
 tmpId= els[k].id;     
str = tmpId; 
     	// use to find AttProduct
    if (str.search("AttProduct")!=-1 && str!=null) {      
       document.getElementById( els[k].id).style.display = "none";
 }
} 


}	
function ShowProduct(id){
var str,tmpId;
 var els = document.getElementsByTagName("div"); 
 var elsLen = els.length;
for (var k=0;k < elsLen;k++) {
 tmpId= els[k].id;     
str = tmpId; 
     	// use to find AttProduct
    if (str.search("AttProduct")!=-1 && str!=null) {      
       document.getElementById( els[k].id).style.display = "block";
    }
}
}
function ShowCategory(baseurl,cid,id){
	link= baseurl+'process.php?cid='+cid+'&id='+id;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			document.getElementById('result'+cid).style.display = "block";
            document.getElementById('showCat'+cid).style.display = "none";
            document.getElementById('HideCat'+cid).style.display = "block";
            
                 // for internet explorer
        if( document.getElementById('result'+cid).innerHTML==""){
            document.getElementById('result'+cid).style.display = "none";
        } 
	}

}	
function HideCategory(baseurl,cid,id){
	link= baseurl+'process.php?cid='+cid+'&id='+id;
	var linkComp = link.split( "?");
    var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");
	    obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			document.getElementById('result'+cid).style.display = "none";
            document.getElementById('showCat'+cid).style.display = "block";
            document.getElementById('HideCat'+cid).style.display = "none";
		}

	}
function ShowCategoryList(baseurl,cid,id){
//var CatOptionStatus+cid=true;
var optionCatIdStr=optionCatIdArr.toString();
	link= baseurl+'process1.php?cid='+cid+'&id='+id+'&optionCatIdArr='+optionCatIdStr;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('resultN'+cid).innerHTML = result;  
			 document.getElementById('resultN'+cid).style.display = "block";
            document.getElementById('showCatN'+cid).style.display = "none";
            document.getElementById('HideCatN'+cid).style.display = "block";
        
    	
                 // for internet explorer
        if( document.getElementById('resultN'+cid).innerHTML==""){
            document.getElementById('resultN'+cid).style.display = "none";
        } 
	}

}	
function HideCategoryList(baseurl,cid,id){
//CatOptionStatus+cid=false;
	link= baseurl+'process1.php?cid='+cid+'&id='+id;
	var linkComp = link.split( "?");
    var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");
	    obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('resultN'+cid).innerHTML = result;  
			document.getElementById('resultN'+cid).style.display = "none";
            document.getElementById('showCatN'+cid).style.display = "block";
            document.getElementById('HideCatN'+cid).style.display = "none";
		}

	}
	/*
function ShowMemberLevel(memberid,id){
	link= 'member_process.php?memberid='+memberid+'&id='+id;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('memberResult'+memberid).innerHTML = result;  
			document.getElementById('memberResult'+memberid).style.display = "block";
            document.getElementById('showmember'+memberid).style.display = "none";
            document.getElementById('Hidemember'+memberid).style.display = "block";
            
                 // for internet explorer
        if( document.getElementById('memberResult'+memberid).innerHTML==""){
            document.getElementById('memberResult'+memberid).style.display = "none";
        } 
	}

}	
function HideMemberLevel(memberid,id){
	link='member_process.php?memberid='+memberid+'&id='+id;
	var linkComp = link.split( "?");
    var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");
	    obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('memberResult'+memberid).innerHTML = result;  
			document.getElementById('memberResult'+memberid).style.display = "none";
            document.getElementById('showmember'+memberid).style.display = "block";
            document.getElementById('Hidemember'+memberid).style.display = "none";
		}

	}
	*/	
//********* ATTRIBUTE ************
var AjaxAttributeArr=new Array();
function ShowAttribute(baseurl,cid){
    AjaxAttributeArr.push(cid);
	link= baseurl+'attribute_process.php?cid='+cid;
	var linkComp = link.split( "?");
	var result;
	var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
		
        
      document.getElementById('resultAttribute'+cid).innerHTML = result;  
	  document.getElementById('resultAttribute'+cid).style.display = "block";
      document.getElementById('showAtt'+cid).style.display = "none";
      document.getElementById('HideAtt'+cid).style.display = "block";
        Shadowbox.deact();
        Shadowbox.init();
		}

	}	
function HideAttribute(baseurl,cid,id){
	//AjaxAttributeArr.push(cid);
	for ( var i in AjaxAttributeArr )
	{
	
		if(AjaxAttributeArr[i]==cid){
			AjaxAttributeArr.splice(i,1);

		}
}
	link= baseurl+'system.php?cid='+cid+'&id='+id;
	var linkComp = link.split( "?");
	var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('resultAttribute'+cid).innerHTML = result;  
			document.getElementById('resultAttribute'+cid).style.display = "none";
         document.getElementById('showAtt'+cid).style.display = "block";
         document.getElementById('HideAtt'+cid).style.display = "none";
		
		}

}
function ShowAttributeResult(baseurl,cid,product_id){
 
	link= baseurl+'attribute_result.php?cid='+cid+'&product_id='+product_id;
	var linkComp = link.split( "?");
	var result;
	var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
		
        
      document.getElementById('resultAttribute'+cid).innerHTML = result;  
	  document.getElementById('resultAttribute'+cid).style.display = "block";
      document.getElementById('showAtt'+cid).style.display = "none";
      document.getElementById('HideAtt'+cid).style.display = "block";
        Shadowbox.deact();
        Shadowbox.init();
		}

	}	
function HideAttributeResult(baseurl,cid,id){
	
	link= baseurl+'attribute_result.php?cid='+cid+'&id='+id;
	var linkComp = link.split( "?");
	var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('resultAttribute'+cid).innerHTML = result;  
			document.getElementById('resultAttribute'+cid).style.display = "none";
         document.getElementById('showAtt'+cid).style.display = "block";
         document.getElementById('HideAtt'+cid).style.display = "none";
		
		}

}


	/********** pages       **********/
var AjaxMenuIdArr=new Array();
	var DeparmentIdArr=new Array();
function ShowPages(baseurl,cid){
	AjaxMenuIdArr.push(cid);
	link= baseurl+'process.php?cid='+cid;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			 document.getElementById('result'+cid).style.display = "block";
            document.getElementById('showCat'+cid).style.display = "none";
            document.getElementById('HideCat'+cid).style.display = "block";
            
             // for internet explorer  
         if( document.getElementById('menuArray'+cid).innerHTML==""){
            document.getElementById('result'+cid).style.display = "none";
        }  
            
            // code for category drag and drop 
      if( document.getElementById('menuArray'+cid).innerHTML!=""){
     	
          var test;
          test=document.getElementById('menuArray'+cid).innerHTML;  
    	  var temp1; 
          temp1 =test.split(","); 
        
    	for(var j=0;j<temp1.length;j++){
    		 new Draggable("item-"+ temp1[j] , {revert:true})
    		
    		 var initStr = "";
             initStr ="Droppables.add(\"boxMenu\"+ "+ temp1[j] + ", {accept:'products', hoverclass:'cart-active',";
           
			 initStr +=" onDrop: function(element ) {    \n";
			 initStr += "temp2 =element.id.split(\"-\")\n";
			 initStr += "var TempLink \n";
		     
		     initStr += " if(temp2[0]==\"item\"){";
			 initStr += "TempLink=\"order.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
		     initStr +="   content:    TempLink, \n";
		     initStr +="   height:     150,\n";
		     initStr +="   width:      350\n";
		     initStr +="  }); \n";
			initStr +="}else{ \n";
			initStr +=" alert(\"Invalid move\"); \n";
			initStr += "} \n"; 
			initStr +=" }}) \n";
				
		     eval(initStr);
			
		}	
	 
	 }   
            Shadowbox.deact();
            Shadowbox.init();
		}

	}	
function HidePages(baseurl,cid){
	//AjaxMenuIdArr.pop(cid);
	 for ( var i in AjaxMenuIdArr )
		{
		
			if(AjaxMenuIdArr[i]==cid){
				AjaxMenuIdArr.splice(i,1);
	
			}
}
	link= baseurl+'process.php?cid='+cid;
	var linkComp = link.split( "?");
    var result;
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");
	    obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			document.getElementById('result'+cid).style.display = "none";
            document.getElementById('showCat'+cid).style.display = "block";
            document.getElementById('HideCat'+cid).style.display = "none";
		}

	}
	
//*********** INDUSTRY ***********

function ProductMove(cid,orderid,parentid,task){
 
	link='ordering.php?task='+task+'&parentid='+parentid+'&category='+cid+'&orderid='+orderid;
	var linkComp = link.split( "?");
		
		
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
          
			// we'll do something to process the data here.
			
			result = responseTxt
			alert(result);
		 ShowPage();  
         Shadowbox.deact();
        Shadowbox.init();
		}

	}
	
function MenuMove(cid,orderid,parentid,task){
 // alert(parentid);
 //alert(orderid);
 //alert(cid);
	link='ordering.php?task='+task+'&parentid='+parentid+'&menu='+cid+'&orderid='+orderid;
	var linkComp = link.split( "?");
		
		
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
           ShowBlogPage();  
			// we'll do something to process the data here.
			result = responseTxt
			alert(result);
		//	return; 
       Shadowbox.deact();
        Shadowbox.init();
		}

	}
function AttributeMove(cid,orderid,parentid,task){
 
	link='attribute_ordering.php?task='+task+'&parentid='+parentid+'&category='+cid+'&orderid='+orderid;
	var linkComp = link.split( "?");
		
		
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
           ShowPage();  
			// we'll do something to process the data here.
			result = responseTxt
			alert(result);
		//	return; 

		}

	}
			
function deleteSelectedMenus(){
	 //alert(InputisystemIdArr);
	   link='index_process.php?page='+InputMenuPageIdArr+'&link='+InputMenuLinkIdArr+'&placeholder='+InputMenuPlaceholderIdArr;
		var linkComp = link.split( "?");
	
			
			var result;
			
					
			var obj = new ajaxObject(linkComp[0], fin);

			obj.update(linkComp[1],"GET");

			obj.callback = function (responseTxt, responseStat) {
	           
	           ShowBlogPage(); 
	          // we'll do something to process the data here.
				result = responseTxt
				alert(result);
				 Shadowbox.deact();
			     Shadowbox.init();
			

			}
	}	
function deleteSelectedValues(){
 //alert(InputisystemIdArr);
   link='index_process.php?category='+InputcatIdArr+'&product='+InputproductIdArr;
   InputcatIdArr=[];
   InputproductIdArr=[];
   
   
   
   
   var linkComp = link.split( "?");
		
		
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
           ShowPage();  
			// we'll do something to process the data here.
			result = responseTxt
			alert(result);
			Shadowbox.deact();
			     Shadowbox.init();
		

		}
}	
function ShowBlogPage(){

  //alert(AjaxMenuIdArr);
   link='index1.php?tabAction='+tabAction+'&idArr='+AjaxMenuIdArr+'&BlogIdArray='+AjaxBlogIdArray;
	var linkComp = link.split( "?");
		
		
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
          
			// we'll do something to process the data here.
			result = responseTxt
			document.getElementById('left').innerHTML = result;  
		    document.getElementById('left').style.display = "block";
		
		if( document.getElementById('catArray').innerHTML!=""){
     	
          var test;
          test=document.getElementById('catArray').innerHTML;  
    	  var temp1; 
          temp1 =test.split(","); 
        
    	for(var j=0;j<temp1.length;j++){
    		 new Draggable("item-"+ temp1[j] , {revert:true})
    		
    		 var initStr = "";
             initStr ="Droppables.add(\"boxMenu\"+ "+ temp1[j] + ", {accept:'products', hoverclass:'cart-active',";
           
			 initStr +=" onDrop: function(element ) {    \n";
			 initStr += "temp2 =element.id.split(\"-\")\n";
			 initStr += "var TempLink \n";
		     
		     initStr += " if(temp2[0]==\"item\"){";
			 initStr += "TempLink=\"order.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
		     initStr +="   content:    TempLink, \n";
		     initStr +="   height:     150,\n";
		     initStr +="   width:      350\n";
		     initStr +="  }); \n";
			initStr +="}else{ \n";
			initStr +=" alert(\"Invalid move\"); \n";
			initStr += "} \n"; 
			initStr +=" }}) \n";
				
		     eval(initStr);
			
		}	
	 
	 } 
		
Shadowbox.deact();
         Shadowbox.init();
	
	
	}
}

	
function ShowProductPrice(id,member_id,cid){

	link= 'price.php?id='+id+'&member_id='+member_id+'&cid='+cid;
	var linkComp = link.split( "?");
	var result;
	var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result').innerHTML = result;  
			document.getElementById('result').style.display = "block";
            
          document.getElementById('member_level'+member_id).checked=true;
	      
	       var tbl = document.getElementById('tableId');
           var lastRow = tbl.rows.length;
          
          if(lastRow>1){
          document.getElementById('ButtonId1').style.display = "block";
	      }
		}

	}	
		
function ShowMessageDetails(baseurl,i){
 	link= baseurl+'process.php?id='+i ;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('messageDetails').innerHTML = result;  
			document.getElementById('messageDetails').style.display = "block";
		   
			
		Shadowbox.deact();
        Shadowbox.init();
	  }
}	  
function ShowContactMessageDetails(baseurl,i){
 	link= baseurl+'contact.php?id='+i ;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('messageDetails1').innerHTML = result;  
			document.getElementById('messageDetails1').style.display = "block";
		   
			
		Shadowbox.deact();
        Shadowbox.init();
	  }	  
        
}         	
function ShowCategoryAttribute(baseurl,cid){
   //alert(attributeDisplay);
  AjaxCategoryIdArr.push(cid);
  
 //if(update!=1){
 
	link= baseurl+'category_attribute.php?cid='+cid;
	
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
		    document.getElementById('result'+cid).style.display = "block";
            document.getElementById('showCat'+cid).style.display = "none";
            document.getElementById('HideCat'+cid).style.display = "block";
        // code for category drag and drop 
       if( document.getElementById('catArray'+cid).innerHTML!=""){
     	
          var test;
          test=document.getElementById('catArray'+cid).innerHTML;  
    	  var temp1; 
          temp1 =test.split(","); 
    	for(var j=0;j<temp1.length;j++){
    		   new Draggable("item-"+ temp1[j] , {revert:true})
               var initStr = "";
               
			  initStr ="Droppables.add(\"box\"+ "+ temp1[j] + ", {accept:'products', hoverclass:'cart-active',";
			  initStr +=" onDrop: function(element ) {    \n";
			  initStr += "temp2 =element.id.split(\"-\")\n";
			  initStr += "var TempLink \n";
		   
		      initStr +="if(temp2[1]=="+ temp1[j] +" && temp2[0]==\"item\"){ \n";
              initStr +=     "  return; \n"
			
			  
			 initStr += "}else if(temp2[0]==\"item\"){";
			 initStr += "TempLink=\"order.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
		     initStr +="   content:    TempLink, \n";
		     initStr +="   height:     150,\n";
		     initStr +="   width:      350\n";
		     initStr +="  }); \n";
			 initStr +="}else if(temp2[0]==\"product\"){ \n";
			 initStr +=" TempLink=\"order1.php?dropid="+temp1[j]+"&id=\"+temp2[1]+\"&catId=\"+temp2[2] \n";
			 initStr +="   Shadowbox.open({ \n" ;
			 initStr +="    player:     'iframe', \n";
			 initStr +="   title:      'Move or Copy', \n";
			 initStr +="   content:    TempLink, \n";
			 initStr +="   height:     150,\n";
			 initStr +="   width:      350\n";
			 initStr +="  }); \n";
			 initStr +=" }else if(temp2[0]==\"Indproduct\"){ \n";
			 
	        initStr +=" TempLink=\"ind_cat.php?dropid="+temp1[j]+"&id=\"+temp2[1]+\"&catId=\"+temp2[2] \n";
			
      		initStr +="   Shadowbox.open({ \n" ;
			initStr +="    player:     'iframe', \n";
			initStr +="   title:      'Move or Copy', \n";
			initStr +="   content:    TempLink, \n";
			initStr +="   height:     150,\n";
			initStr +="   width:      350\n";
			initStr +="  }); \n";

			 initStr +=" }else if(temp2[0]==\"attributeIcon\"){ \n";
			 
		        initStr +=" TempLink=\"attribute_cat.php?dropid="+temp1[j]+"&id=\"+temp2[1] \n";
				
	      		initStr +="   Shadowbox.open({ \n" ;
				initStr +="    player:     'iframe', \n";
				initStr +="   title:      'Move or Copy', \n";
				initStr +="   content:    TempLink, \n";
				initStr +="   height:     150,\n";
				initStr +="   width:      350\n";
				initStr +="  }); \n";
			
			
			
			initStr +="}else{ \n";
			initStr +=" alert(\"Invalid move\"); \n";
			initStr += "} \n"; 
			initStr +=" }}) \n";
				
			eval(initStr);
			
		}	
	       
	 }
        Shadowbox.deact();
        Shadowbox.init();
       }	
}
function HideCategoryAttribute(baseurl,cid){
   // AjaxCategoryIdArr.pop(cid);
	 for ( var i in AjaxCategoryIdArr )
		{
		
			if(AjaxCategoryIdArr[i]==cid){
				AjaxCategoryIdArr.splice(i,1);
	
			}
  }
	link= baseurl+'category_attribute.php?cid='+cid;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {

			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('result'+cid).innerHTML = result;  
			 
			document.getElementById('result'+cid).style.display = "none";
            document.getElementById('showCat'+cid).style.display = "block";
            document.getElementById('HideCat'+cid).style.display = "none";
			//document.getElementById('main').style.display = 'block';         
  Shadowbox.deact();
        Shadowbox.init();
		}

	}
	
function EditOption(baseurl,i,product_id){
 	link= baseurl+'edit_option.php?id='+i+'&product_id='+product_id ;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('displayRow'+i).innerHTML = result;  
			document.getElementById('displayRow'+i).style.display = "block";
		   
			
		Shadowbox.deact();
        Shadowbox.init();
	  }	  
        
}
function EditShippingCost(baseurl,i){

 	link= baseurl+'edit_shipping.php?id='+i ;
	var linkComp = link.split( "?");
		var result;
		
				
		var obj = new ajaxObject(linkComp[0], fin);

		obj.update(linkComp[1],"GET");

		obj.callback = function (responseTxt, responseStat) {
           
			// we'll do something to process the data here.
			result = responseTxt
			
			document.getElementById('displayRow'+i).innerHTML = result;  
			document.getElementById('displayRow'+i).style.display = "block";
		 
			
		Shadowbox.deact();
        Shadowbox.init();
	  }	  
        
}	
