
//    alert(navigator.appName + " <**> " + navigator.userAgent);
//    document.write(navigator.appName + " <**> " + navigator.userAgent);
//alert(document.getElementById("divmn").style.top);
function affheight()
{
//alert(Sys.UI.DomElement.getBounds(document.getElementById("divmn")).y);
//   alert(document.getElementById("divmn").offsetTop + "px");
//   document.getElementById("spheight").height=Sys.UI.DomElement.getBounds(document.getElementById("divmn")).y - 200 + "px";
   
}
var gvariable = "";
function SetBottomLinkHeight()
{
    if(navigator.appName == "Netscape")
    {//FF
        document.getElementById("BottomLink1").style.height = "70px";//bottom link
        document.getElementById("BottomLink2").style.height = "70px";//bottom link
        document.getElementById("BottomLink3").style.height = "89px";//bottom link
        if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
        {//safari
        document.getElementById("BottomLink1").style.height = "70px";//bottom link
        document.getElementById("BottomLink2").style.height = "70px";//bottom link
        document.getElementById("BottomLink3").style.height = "72px";//bottom link
        }
        if(navigator.userAgent.toLowerCase().indexOf("chrome") != -1)
        {//google chrome
        document.getElementById("BottomLink1").style.height = "70px";//bottom link
        document.getElementById("BottomLink2").style.height = "70px";//bottom link
        document.getElementById("BottomLink3").style.height = "73px";//bottom link
        }
    }
    else if(navigator.appName == "Opera")
    {
        document.getElementById("BottomLink1").style.height = "70px";//bottom link
        document.getElementById("BottomLink2").style.height = "70px";//bottom link
        document.getElementById("BottomLink3").style.height = "89px";//bottom link
    }
    else
    {
        document.getElementById("BottomLink1").style.height = "70px";//bottom link
        document.getElementById("BottomLink2").style.height = "70px";//bottom link
        document.getElementById("BottomLink3").style.height = "70px";//bottom link
    }
}            
function initScrollLayer() 
{
  var wndo = new dw_scrollObj('wn', 'lyr1', 't1');
  wndo.setUpScrollbar("dragBar", "track", "h", 1, 1);
//  SetBottomLinkHeight();
}

function HandleTextboxEvent(controlname,eventname)
{
            var sPath = window.location.pathname;
            //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
            var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
//            alert(sPage);
            var adtop = 0;
            var adleft = 0;
            var zipname= "30318"
            if(sPage == "AdvancedSearch.aspx")
            {
                zipname= " 30318"
            }
            else
            {   
                zipname= ""
            }
//            alert(sPage + " : " + zipname);
    if(eventname == "Focus")
    {
        if(controlname == "CityStateSearch")
        {        
            HideNewCatMenuItems();
            if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Example: Atlanta, GA"+zipname)
            {
                document.getElementById("CityStateSearch").value = "";
                document.getElementById("CityStateSearch").className = "citystatezipboxclass";
            }
        }
        if(controlname == "TextBoxCompanyName")
        { 
            if(document.getElementById("TextBoxCompanyName").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Example: Joe's coffee shop")
            {
                document.getElementById("TextBoxCompanyName").value = "";
                document.getElementById("TextBoxCompanyName").className = "citystatezipboxclass";
            }
        
        }
        if(controlname == "TextBoxKeyWord")
        { 
            if(document.getElementById("TextBoxKeyWord").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Example: pizza delivery")
            {
                document.getElementById("TextBoxKeyWord").value = "";
                document.getElementById("TextBoxKeyWord").className = "citystatezipboxclass";
            }
        
        }
    }
    if(eventname == "LostFocus")
    {
        if(controlname == "CityStateSearch")
        {        
            if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "")
            {
                document.getElementById("CityStateSearch").value = "Example: Atlanta, GA"+zipname;
                document.getElementById("CityStateSearch").className = "txtfld";
            }
        }
        if(controlname == "TextBoxCompanyName")
        { 
            if(document.getElementById("TextBoxCompanyName").value.replace(/^\s+/, '').replace(/\s+$/, '') == "")
            {
                document.getElementById("TextBoxCompanyName").value = "Example: Joe's coffee shop";
                document.getElementById("TextBoxCompanyName").className = "txtfld";
            }
        
        }
        if(controlname == "TextBoxKeyWord")
        { 
            if(document.getElementById("TextBoxKeyWord").value.replace(/^\s+/, '').replace(/\s+$/, '') == "")
            {
                document.getElementById("TextBoxKeyWord").value = "Example: pizza delivery";
                document.getElementById("TextBoxKeyWord").className = "txtfld";
            }
        
        }
    }
    if(eventname == "Change")
    {
//        alert("hi");
        if(controlname == "CityStateSearch" )
        {        
            if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "No Match found")
            {
                document.getElementById("CityStateSearch").value = "";
                document.getElementById("CityStateSearch").className = "citystatezipboxclass";
            }
            else if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Suggested")
            {
                document.getElementById("CityStateSearch").value = "";
                document.getElementById("CityStateSearch").className = "citystatezipboxclass";
            }
            else if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "null")
            {
                document.getElementById("CityStateSearch").value = "";
                document.getElementById("CityStateSearch").className = "citystatezipboxclass";
            }
            else
            {
//                document.getElementById("CityStateSearch").value= "";
               
            }
        }
        
    }
}

function getElementsByName_iefix(tag, name) 
{
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) 
     {
          att = elem[i].getAttribute("name");
          if(att == name) 
          {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}
function HideNewCatMenuItems()
{
    var collection = getElementsByName_iefix("div","NewDivCat");//working fine in FF but not in IE7
    //    alert(collection.length);
    for (var x=0; x<collection.length; x++) 
    {
        collection[x].style.visibility="hidden";
    }
}

function ClientPopulated(source, eventArgs)
{
    if (source._currentPrefix != null)
    {
        var list = source.get_completionList();
        
        for (var i = 0; i < list.childNodes.length; i++)
        {
            
            var text = list.childNodes[i].innerHTML; 
            var value="";
            if(i==0)
            {
                value = '<p class="SpanItmClass">'+ text + '</p>';
            }
            else
            {
                value = text;
            }
            list.childNodes[i].innerHTML = value;
           
        }
    }
}

//function ClientPopulated1(source, eventArgs)
//{
//    if (source._currentPrefix != null)
//    {
//        var list = source.get_completionList();
//        var search = source._currentPrefix.toLowerCase();
//        for (var i = 0; i < list.childNodes.length; i++)
//        {
//            var text = list.childNodes[i].innerHTML; 
//            var index = text.toLowerCase().indexOf(search);
//            if (index != -1)
//            {
//                var value = text.substring(0, index);
//                value += '<span class="autocomplete_highlightedListItem">';
//                value += text.substr(index, search.length);
//                value += '</span>';
//                value += text.substring(index + search.length);
//                list.childNodes[i].innerHTML = value;
//            }
//        }
//    }
//}

function PageClick()
{
//    if(gvariable == 0)
//    {
//        HideNewCatMenuItems();
//    }
}
function ServiceIconHover(stp)
{
    var collectionop1 = getElementsByName_iefix("a","serviceicon");
    for (var x=0; x<collectionop1.length; x++) 
    {
        if(collectionop1[x].id != gvariable)
        {
            collectionop1[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop1[x].className.replace("slide","") +".gif)";
            if(collectionop1[x].className == document.getElementById(stp).className)
            {
                collectionop1[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop1[x].className.replace("slide","") +"-hov.gif)";
            }
        }
    }
}
function ServiceIconOut(stp)
{
    var collectionop1 = getElementsByName_iefix("a","serviceicon");
    for (var x=0; x<collectionop1.length; x++) 
    {
        if(collectionop1[x].id != gvariable)
        {
            collectionop1[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop1[x].className.replace("slide","") +".gif)";
        }
//        if(collectionop1[x].className == document.getElementById(stp).className)
//        {
//            collectionop1[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop1[x].className.replace("slide","") +"-hov.gif)";
//        }
    }
}
function ShowCategoryDrp(str)
{
//get current position of the category dropdown
    var toppo=Sys.UI.DomElement.getBounds(document.getElementById("BusinessCategory")).y+document.getElementById("BusinessCategory").offsetHeight;
    var leftpo=Sys.UI.DomElement.getBounds(document.getElementById("BusinessCategory")).x;
//alert(toppo + " <> " + leftpo);

        var collectionop = getElementsByName_iefix("a","serviceicon");//working fine in FF but not in IE7
        for (var x=0; x<collectionop.length; x++) 
        {
            collectionop[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop[x].className.replace("slide","") +".gif)";
            if(collectionop[x].className == document.getElementById(str).className)
            {
                collectionop[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop[x].className.replace("slide","") +"-hov.gif)";
                gvariable = collectionop[x].id;
            }
        }
        
        HideNewCatMenuItems();// hides all the newmenu
        
        str="NewCat"+str;
           document.getElementById(str).style.visibility="visible";
//           alert(str);
            document.getElementById(str).style.left = leftpo + px;//new menu
            document.getElementById(str).style.top = toppo + px;//new menu
}

function SetSelection(subCategoryID, subCategory, MainCategory)
{  
//alert(MainCategory);
    document.getElementById("BusinessCategory").className = "citystatezipboxclass";
    document.getElementById("BusinessCategoryHidden").value = subCategory;
    document.getElementById("BusinessCategory").value = subCategory;
    document.getElementById("SubCategoryID").value = subCategoryID;
    document.getElementById("CategoryNameHidden").value = MainCategory;
    if(document.getElementById("NewCat"+MainCategory) != null)
    {
        document.getElementById("NewCat"+MainCategory).style.visibility="hidden";
    }
    
    var collectionop = getElementsByName_iefix("a","serviceicon");//working fine in FF but not in IE7
    for (var x=0; x<collectionop.length; x++) 
    {
        collectionop[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop[x].className.replace("slide","") +".gif)";
        if(collectionop[x].className == document.getElementById(MainCategory).className)
        {
            collectionop[x].style.backgroundImage = "url(Images/ser-ico"+ collectionop[x].className.replace("slide","") +"-hov.gif)";
            gvariable = collectionop[x].id;
        }
    }
        
}
function function1()
{
    alert(window);
    window.scrollTo(1,300);
}

function OnSearchLinkSubmit()
{       
        
    if((document.getElementById("CityStateSearch").value == "" || document.getElementById("CityStateSearch").value == "Example: Atlanta, GA") && (document.getElementById("BusinessCategory").value == "" || document.getElementById("BusinessCategory").value == "Click here to select a category"))
    {
        alert("Please enter City or Zip and Subcategory");
        return false;
    }
    
    if(document.getElementById("CityStateSearch").value == "" || document.getElementById("CityStateSearch").value == "Example: Atlanta, GA")
    {
        alert("Please enter City or Zip");
        return false;
    }

}
function OnAdvancedSearchLinkSubmit()
{
    
    if(document.getElementById("TextBoxCompanyName").value.replace(/^\s+/, '').replace(/\s+$/, '') != "Example: Joe's coffee shop")
    {
//    alert(document.getElementById("TextBoxCompanyName").value);
//        if((document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "" || document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Example: Atlanta, GA 30318") && (document.getElementById("BusinessCategory").value.replace(/^\s+/, '').replace(/\s+$/, '') == "" || document.getElementById("BusinessCategory").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Click here to select a category"))
//        {
//            alert("Please enter City or Zip and Subcategory");
//            return false;
//        }
//        if(document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "" || document.getElementById("CityStateSearch").value.replace(/^\s+/, '').replace(/\s+$/, '') == "Example: Atlanta, GA 30318")
//        {
//            alert("Please enter City or Zip");
//            return false;
//        }
    }
    else
    {
        alert("Please enter Business Name");
        return false;
    }
        
}
function OnSearchJackPotSubmit()
{       
    if(document.getElementById("CityStateSearch").value == "" || document.getElementById("CityStateSearch").value == "Example: Atlanta, GA 30324")
    {
        alert("Please enter City, State or Zip");
        return false;
    }

//        document.getElementById("ctl00_mainContent_BusinessCategoryNameHidden").value = document.getElementById("ctl00_mainContent_BusinessCategory").value;
//        document.getElementById("ctl00_mainContent_CityZipNameHidden").value = document.getElementById("ctl00_mainContent_CityStateSearch").value;

}

function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
        }
     }
  }
}
frmObj.value = tmpStr;
}