﻿// ClipBoard
var _ROOT = '/';//'www.noiseon.com';
function clipboardAddSample(id, Obj, OtherFunc, OtherImage)
{
//    if(Obj && OtherFunc)
//    {
//        Obj.onclick=OtherFunc+"("+id+",this,clipboardAddSample,"+this.src+");return false;";
//        Obj.src=OtherImage;
//    }
    new Ajax.Request('/Controls/UserClipboard.aspx?A=add&id='+id,   
    {     method:'get',     
          onSuccess: function(transport)
          {
            var response = transport.responseText || "no response text";
            var el = new Array();
            el = response.split('SSPPLLIITTEERR');
            document.getElementById("clipboardContainer").innerHTML = el[1];
            eval(el[0]);
            //eval('init'+id+'NoiseBoard()');
          },     
          onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 
 }

function clipboardDelSample(id, Obj, OtherFunc, OtherImage)
{
//    if(Obj && OtherFunc)
//    {
//        Obj.onclick=OtherFunc+"("+id+",this,clipboardDelSample,"+Obj.src+");return false;";
//        Obj.src=OtherImage;
//    }
    new Ajax.Request('/Controls/UserClipboard.aspx?A=del&id='+id,   
    {     method:'get',     
          onSuccess: function(transport)
          {
            var response = transport.responseText || "no response text";
            var el = new Array();
            el = response.split('SSPPLLIITTEERR');
            document.getElementById("clipboardContainer").innerHTML = el[1];
            eval(el[0]);
          },     
          onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 
 }

function clipboardClearAllSamples()
{
    new Ajax.Request('/Controls/UserClipboard.aspx?A=clear',   
    {     method:'get',     
          onSuccess: function(transport)
          {
            var response = transport.responseText || "no response text";
            var el = new Array();
            el = response.split('SSPPLLIITTEERR');
            document.getElementById("clipboardContainer").innerHTML = el[1];     
          },     
          onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 
 }

//  Pedals Info
function populateBrandsDropDown(id) {
    new Ajax.Request('/Tools/Tools.aspx?method=getallbrands&format=select',
    {     method:'get',     
          onSuccess: function(transport)
          {
            var options = transport.responseText.split("####");
            el = document.getElementById(id);
            el.options.length=0;
            for(var i=0;i<options.length;i++) {
                elements = options[i].split("%%%%");
                var op = document.createElement('option');
                op.value = elements[0];
                op.innerText = elements[1];
                el.appendChild(op);
            }
            if (el) el.innerHTML = s;
          },     
          onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 
}

function populateProductsDropDown(Id, FilterType, FilterValue) {
    var filter_str = "";
    if(FilterType.length>0 && FilterValue.length>0) {
        filter_str = "&filter="+FilterType+"&value="+FilterValue;
    }
    new Ajax.Request('/Tools/Tools.aspx?method=getproducts'+ filter_str,
    {
        method:'get',     
        asynchronous:'false',
        onSuccess: function(transport)
        {
        var options = transport.responseText.split("####");
        el = document.getElementById(Id);
        el.options.length=0;
        for(var i=0;i<options.length;i++) {
            elements = options[i].split("%%%%");
            var op = document.createElement('option');
            op.value = elements[0];
            op.innerText = elements[1];
            el.appendChild(op);
        }
        if (el) el.innerHTML = s;
        },     
        onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
        }   
    }); 

}

function createNewProduct(ProductName, BrandID) {
    new Ajax.Request('../Tools/Tools.aspx?method=createnewproduct?name='+ ProductName + '&bid=' + BrandID,
    {     
        asynchronous:'false',
        method:'get',     
        onSuccess: function(transport)
          {
            return transport.responseText;
          },     
        onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 

}

function createNewBrand(BrandName) {
    new Ajax.Request('/Tools/Tools.aspx?method=createnewbrand?name='+ BrandName,
    {     
        asynchronous:'false',
        method:'get',     
        onSuccess: function(transport)
          {
            return transport.responseText;
          },     
        onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 

}

function getProductIDByPNameAndBName(ProductName, BrandName) {
    new Ajax.Request('/Tools/Tools.aspx?method=getProductIDByPNameAndBName?pname='+ ProductName + '&bname=' + BrandName,
    {     
        asynchronous:'false',
        method:'get',     
        onSuccess: function(transport)
          {
            return transport.responseText;
          },     
        onFailure: function(transport){ 
            alert('Something went wrong... '+ transport.ResponseXML) 
          }   
    }); 

}

