function AjaxFillVendors()
 {   
    eval(this.req.responseText);
    FillVendors();
 };
 var SelectProductLineID = '1,2,3,4,';
 var SelectStateID = "AZ,CA,NV,";
 var VendorsListDiv = cmn.gets.getElementByPartIdAndTagName('divList', 'div');
 var strVendorsHolder = "";
 function FillVendors()
 {
    var VendorsListDiv = cmn.gets.getElementByPartIdAndTagName('divList', 'div');
    VendorsListDiv.innerHTML = unescape(strHolder);
 };
function AddTrToTable(_table, _tr)
{
try
{
    _table.children[0].appendChild(_tr);
}
catch(x) {}
try
{
    _table.appendChild(_tr);
}
catch(x) {}
}
function CheckVendors(_stateID, _productLineID, FillType)
 {   
    if (VendorsHolder == null)
        return false;
    if (FillType == null)
        return false;
    for(var i = 0; i < VendorsHolder.Vendors.length; i++)
    {
        if ((VendorsHolder.Vendors[i].StateAbr == _stateID && FillType == 'State') || (VendorsHolder.Vendors[i].ProductLineID == _productLineID && FillType == 'ProductLine'))
        {
           return true;
           break;
        }
    }
    return false;
 };
function VendorControl(StateID, ProductLineID, FullDecs, Name, ImgSrc, SiteLink, StateAbr)
{
    this.StateID = StateID;
    this.StateAbr = StateAbr;
    this.ProductLineID = ProductLineID;
    this.FullDecs = FullDecs;
    this.Name = Name;
    this.ImgSrc = ImgSrc;
    this.SiteLink = SiteLink;
}
function ManageVendors()
{    
    this.Vendors = new Array();
    this.Add = function(StateID, ProductLineID, FullDecs, Name, ImgSrc, SiteLink, StateAbr)
    {
        this.Vendors[this.Vendors.length] = new VendorControl(StateID, ProductLineID, FullDecs, Name, ImgSrc, SiteLink, StateAbr);
    }
}
function removeElement(_table)
{
    try
    {
        _table.innerText = "";
    }
    catch(x) {}
    try
    {
        _table.innerHTML = "";
    }
    catch(x) {}
}
function AddState(state) 
{
    if ( SelectStateID.indexOf(state) == -1)
    {
        if (SelectStateID != "")
            SelectStateID += ",";
        SelectStateID += state;
    }
}
function RemoveState(state) 
{
    if ( SelectStateID.indexOf(state) > -1)
    {
        SelectStateID = SelectStateID.replace(state, "");
        SelectStateID = SelectStateID.replace(",,", ",");
    }
}        
function AddProductLine(productline) 
{
    if ( SelectProductLineID.indexOf(productline) == -1)
    {
        if (SelectProductLineID != "")
            SelectProductLineID += ",";
        SelectProductLineID += productline;
    }
}
function RemoveProductLine(productline) 
{
    if ( SelectProductLineID.indexOf(productline) > -1)
    {
        SelectProductLineID = SelectProductLineID.replace(productline, "");
        SelectProductLineID = SelectProductLineID.replace(",,", ",");
    }
}
function SearchProccess() 
{
    var SearchTextControl = cmn.gets.getElementByPartIdAndTagName('SearchType', 'input');
    SearchTextControl.value = "search";
    var srcinput = cmn.gets.getElementByPartIdAndTagName('src-input', 'input');
    window.location.href = "Search.aspx?SearchText="+srcinput.value;
}
function SearchInputPressed() 
{
    var s = event.keyCode;
    if (event.keyCode == 13)
        SearchProccess();
}
function GetOffsetTop(control)
{
	var _getOffsetTop = control.offsetTop;
	var purent_control = control.parentNode;
	var prev_tag_name = control.tagName, prev_top = control.offsetTop;
	
	while (purent_control.tagName != "BODY")
	{
	    //if (prev_top != purent_control.offsetTop || prev_tag_name != "TD")
	    {
	        prev_top = purent_control.offsetTop;
	        prev_tag_name = purent_control.tagName;
	        _getOffsetTop += prev_top;
	    }
	    purent_control = purent_control.parentNode;
	}
	return _getOffsetTop;
}
function GetOffsetLeft(control)
{
	var _getOffset = 0;
	var _getoffsetWidth = control.offsetWidth;
	var purent_control;
	_getOffset = control.offsetLeft;
	
	purent_control = control.parentNode;
	while (purent_control.tagName != "BODY")
	{
	    _getOffset += purent_control.offsetLeft;
	    purent_control = purent_control.parentNode;
	}
	return _getOffset + _getoffsetWidth;
}
