﻿// JScript File
var GMapTimeout;

function GoogleAnalytics()
{
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
}

function PageTracker()
{
    try 
    {
        var pageTracker = _gat._getTracker("UA-11711732-1");
        pageTracker._trackPageview();
    } 
    catch(err) 
    {
    }
}

function ResetForm()
{
    document.forms[0].reset();    
    return false;
}

function txtKeyword_OnFocus(txtKeyword)
{
    var controlid = txtKeyword.id;
    var lastindex = controlid.lastIndexOf("_");        
    var prefix = controlid.substr(0,lastindex + 1);        
    var hfKeywordText = document.getElementById(prefix + 'hfKeywordText');
    if(txtKeyword.value == hfKeywordText.value)
        txtKeyword.value = "";
}

function txtKeyword_OnBlur(txtKeyword)
{    
    var controlid = txtKeyword.id;
    var lastindex = controlid.lastIndexOf("_");        
    var prefix = controlid.substr(0,lastindex + 1);  
    var hfKeywordText = document.getElementById(prefix + 'hfKeywordText');
    if(txtKeyword.value == '')
        txtKeyword.value = hfKeywordText.value;
}

function checkTextBoxAction(event,control)
{
    if(event.keyCode == 13)
    {
        var controlid = control.id;
        var lastindex = controlid.lastIndexOf("_"); 
        var prefix = controlid.substr(0,lastindex + 1);       
        var hfSearchFor = document.getElementById(prefix + 'hfSearchFor').value;                
        if(hfSearchFor != "business")
        {           
            document.getElementById(prefix + 'ibtnContentSearch').click();
        }
        else
        {         
           if(document.getElementById(prefix + 'txtBusinessName').value !="" 
                    && document.getElementById(prefix + 'txtZipCode').value !="") 
                onSubmitSearch(document.forms[0],control);
        }
    }
}

function onSubmitSearch(frm,control)
{ 
    var qs = '';    
    var controlid = control.id;
    var lastindex = controlid.lastIndexOf("_"); 
    var prefix = controlid.substr(0,lastindex + 1);
    var hfSearchFor = document.getElementById(prefix + 'hfSearchFor').value;    
    if(hfSearchFor == "business")
    {
        
        var txtBusinessName = document.getElementById(prefix + 'txtBusinessName').value.replace("&","%26").replace("=","%3D");
        var txtZipCode = document.getElementById(prefix + 'txtZipCode').value.replace("&","%26").replace("=","%3D");
       
        qs = '?searchfor=' + hfSearchFor
             + '&BK=' + txtBusinessName
             + '&BL=' + txtZipCode
             + '&ITS=1'; 
    }
    else
    {
        
        var hfSelectedValues = document.getElementById(prefix + 'ddlDepartments').value.replace("&","%26").replace("=","%3D");
        var ddlInterest = '';
        if(document.getElementById(prefix + 'ddlInterest') != 'undefined' && document.getElementById(prefix + 'ddlInterest') != null)
        {
            ddlInterest = document.getElementById(prefix + 'ddlInterest').value.replace("&","%26").replace("=","%3D");
        }
        var ddlLocations = document.getElementById(prefix + 'ddlLocations').value.replace("&","%26").replace("=","%3D");
        var ddlMedia = document.getElementById(prefix + 'ddlMedia').value.replace("&","%26").replace("=","%3D");
        var txtKeywords = document.getElementById(prefix + 'txtKeywords').value.replace("&","%26").replace("=","%3D");
        var hfKeywordText = document.getElementById(prefix + 'hfKeywordText').value.replace("&","%26").replace("=","%3D");
        if(txtKeywords == hfKeywordText)
        {
            txtKeywords = "";
        }
        qs = '?searchfor=' + hfSearchFor
             + '&K=' + txtKeywords
             + '&L=' + ddlLocations
             + '&I=' + ddlInterest
             + '&M=' + ddlMedia 
             + '&D=' + hfSelectedValues
             + '&ITS=1'; 
    }    
    var URL = document.getElementById(prefix + 'hfURL').value;
    var newAction = URL + qs;   
    frm.action = newAction;    
    frm.submit();
}

function onResetSearch(frm,control)
{ 
    var qs = '';    
    var controlid = control.id;
    var lastindex = controlid.lastIndexOf("_"); 
    var prefix = controlid.substr(0,lastindex + 1);
    var hfSearchFor = document.getElementById(prefix + 'hfSearchFor').value;    
    if(hfSearchFor == 'do' || hfSearchFor == 'eat' || hfSearchFor == 'stay')
    {
        qs = '?ITS=1&searchfor=' + hfSearchFor;
    }
    else
    {
        qs = '?ITS=0&searchfor=' + hfSearchFor;
    }
    var newAction = document.getElementById(prefix + 'hfURL').value + qs;    
    frm.action = newAction;    
    frm.submit();
}

function openImage(url)
{
    var sOptions;
    sOptions = 'dependent=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,toolbar=no,directories=no';
    sOptions = sOptions + ',width=300';
    sOptions = sOptions + ',height=300';
    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
    window.open(url,null,sOptions);
}

function PrintMap()
{
    window.print();
    return false;
}

var SplitResult = new Array();        
var seperatedArticleArray = new Array();   
var currentPageno = 1;
var totalPages = 0;
var pagingFirstTime = true;

function seperateArticleText()
{      
   var location = window.location.href;
   
   //ids is collection which is defined in the page (UCArticle.ascx) and holds the clientid of different controls...
   var Article = $("#" + ids.lblPreview); 
   if(Article != null)
   {
        var articleText = Article.html();
        seperatedArticleArray = articleText.split("<!--PAGEBR-->");            
        totalPages = SplitResult.length;
        displayPage(currentPageno);       
        Article.attr("style", "display:block");  
    }    
}

function displayPage(pageNo)
{
    currentPageno = parseInt(pageNo);
    var page_counts_to_display = 4;
    var start_page_number = 0;
    var title = $("#" + ids.hfTitle).val(); 
    if(seperatedArticleArray.length > 1)
    {
        if(currentPageno <= seperatedArticleArray.length && currentPageno >= 1)
        {
            var preText = "<table width=\"578px\" cellpadding='0' cellspacing='0' height=\"100%\" style='vertical-align:top;' align=\"center\"><tr><td width=\"100%\" align=\"left\" valign=\"top\">";
            var postText = "</td></tr><tr><td></td></tr></table>";
            var Article = $("#" + ids.lblPreview);
            var pagingText = "<table width=\"578px\" align=\"center\"><tr><td align=\"left\" valign=\"top\">";
            
            if(currentPageno != seperatedArticleArray.length)
            {
                var nextPage = currentPageno + 1;
                pagingText = '<a href="javascript:displayPage('+ nextPage +')"><b>Continued: </b> ' + title + ' </a></td></tr><tr><td>';
            }
            if(currentPageno > 1)
            {
                pagingText += '<span align="left" style="padding-right:4px;"><a href="javascript:displayPage('+ parseInt(parseInt(currentPageno) - 1) +')">Previous</a></span>|' ;
            }            
            for(var j=1;j<=seperatedArticleArray.length; j++)
            {
                
                if(j != currentPageno)
                {
                    pagingText += '<span align="left" style="padding-right:4px;"><a href="javascript:displayPage('+ j +')">' + j + '</a></span>';
                }
                else
                {
                    pagingText += '<span align="left" style="padding-right:4px;font-weight:bold;color:#000066;">' + j + '</span>';
                }
                if(j != seperatedArticleArray.length)
                {
                    pagingText += '|';
                }
            }
            if(currentPageno < seperatedArticleArray.length)
            {
                pagingText += '|<span align="left" style="padding-right:4px;"><a href="javascript:displayPage('+ parseInt(parseInt(currentPageno) + 1) +')">Next</a></span>';
            }
            
            pagingText +=  "</td></tr></table>"; 
            var headingText = "";
            if(currentPageno > 1) 
            {
                headingText = "<p class='PAGETITLE'>" + title + "<br/><hr/></p>" + pagingText; 
            }
            
            var articleContent = preText + headingText + seperatedArticleArray[currentPageno - 1] + pagingText + postText;
            Article.html("");
            Article.html(articleContent); 
        }
    }
    
    if(!(pagingFirstTime))
    {
        window.location.href =  "#";
    }
    else
    {
        pagingFirstTime = false;
    }    
}

function MapToGeog(type)
{  
    if ($find('GMapPopup') != null)
    {            
        var title; 
        var id = $("#" + ids.hfContentID).val();
        if(type=="video")
            title = $("#" + ids.hfVideoTitle).val();    
        else if(type=="article")
            title = $("#" + ids.hfTitle).val();
        title = escape(title);    
        var  Targeturl = $("#" + ids.hfURL).val();          
        var frame = $get('iframeGMap');    
        frame.src = Targeturl+'?contentId=' + id + '&title=' + title;
        $find('GMapPopup').show();  
        window.clearTimeout(GMapTimeout); 
    }
    else
    {
        GMapTimeout = window.setTimeout("MapToGeog('" + type + "')",100);
    }
    return false;
}

function ClosePopup()
{
    window.parent.document.getElementById('btnClose').click();
}       

function DisplayGMapWindow(id,title,PersistentID,Targeturl,type)
{            
    if ($find('GMapPopup') != null)
    {                    
        title = escape(title);                   
        var frame = $get('iframeGMap'); 
        if (type=='Article')
        {   
            frame.src = Targeturl+'?contentId=' + id + '&title=' + title;
        }
        else
        {
            frame.src = Targeturl+'?&vendorId=' + id+'&title='+title+'&pId='+PersistentID;
        }
        $find('GMapPopup').show();  
        window.clearTimeout(GMapTimeout); 
    }
    else
    {
        GMapTimeout = window.setTimeout("MapToGeog('" + type + "')",100);
    }
} 

function setBlackBackground()
{   
   resizeVideo();    
}

function resizeVideo()
{        
    var _videoEmbed = $("#" + ids.lblVideoContainer + " embed") 
    if (_videoEmbed != null && _videoEmbed != 'undefined')
    {
        for(var i=0; i < _videoEmbed.length; i++)
        {
            _videoEmbed[i].width = "400";                           
            _videoEmbed[i].height = "348";                 
        }
    }
}    

function OnArticleSearchLoad()
{
    try
    {
        GetArticleMap();
        FillArticleArray();        
        if(defaultAddress != null)
        {                       
            map.setCenter(new GLatLng(defaultAddress.Latitude,defaultAddress.Longitude), defaultAddress.Zoom);
        }    
    }
    catch(e)
    {
    } 
}

function OnVendorSearchLoad()
{
    try
    {
        initialize();
        GetVendorMap();
        FillVendorArray();        
    }
    catch(e)
    {
    } 
}

function Address()
{
    this.contentId = ""; 
    this.title = "";
    this.type = ""; 
    this.add = ""; 
    this.Latitude=0.0;
    this.Longitude=0.0;
    this.Zoom=9;
    this.pinNumber='';
    this.isDefault = false;
    this.address = ''; 
    this.Street =""; 
}

function GetVendorMap()
{       
    if (document.getElementById('myMap')!=null)
    { 
        if(geoArray.length > 0)
        {                        
             var addr = geoArray[0];
             var address = addr.street +','+addr.city;
             if(address !='undefined' && address !=null)
             {
                 if (geocoder)
                 {
                    geocoder.getLatLng(address,function(point)
                    {
                        if (!point) 
                        {
                            alert(address + " not found");
                        } 
                        else
                        {
                           map = new GMap2(document.getElementById("myMap"));
                           map.addControl(new GLargeMapControl()); 
                           map.addControl(new GMapTypeControl()); 
                           
                           map.setCenter(new GLatLng(point.lat(),point.lng()), 10);
                           PointLati = point.lat();
                           PointLong = point.lng();
                       }
                    }
                 );
               }
             }
             else
             {
                alert("Geocoder not found...");
             }   
                  
        }
        else
        {
            alert("address not found...");
        }
    } 
    else
    {
        alert("google map undefined...");
    }
                         
} 

function initialize()
{
  if (GBrowserIsCompatible()) 
  {
    geocoder = new GClientGeocoder();
  }
}    

function GetArticleMap()
{       
    if (document.getElementById('myMap')!=null)
    { 
        map = new GMap2(document.getElementById("myMap"));
        map.addControl(new GLargeMapControl()); 
        map.addControl(new GMapTypeControl()); 
     
        //code for show default address if multiple record exist or show single address if multiplr record not exist.
        var nonDefaultTotal =0;
        for(var j=0;j<geoArray.length;j++)
        {                        
            var addr = geoArray[j];
            if(addr.isDefault == true)
            {
                map.setCenter(new GLatLng(addr.Latitude,addr.Longitude), addr.Zoom);
                break;
            }
            else
            {
                nonDefaultTotal++;                                               
            }
        }
        
        if (nonDefaultTotal == geoArray.length)
        {
            map.setCenter(new GLatLng(geoArray[0].Latitude,geoArray[0].Longitude), geoArray[0].Zoom);
        }
     }               
}  

function showArticlePushPin(j)
{
      var addr = geoArray[j]; 
      var point = new GLatLng(addr.Latitude,addr.Longitude);
      map.setZoom(addr.Zoom); 
      map.panTo(point); 
      if(addr.add=='')
        map.openInfoWindow(point, addr.Street);
      else
        map.openInfoWindow(point, addr.Street + '(' + addr.add  +')');
}

function showVendorPushPin(j)
{
      var addr = geoArray[j]; 
      var point = new GLatLng(PointLati,PointLong);
      map.setZoom(10); 
      map.panTo(point); 
      if(addr.add=='')
            map.openInfoWindow(point, addr.Street);
      else
            map.openInfoWindow(point, addr.Street + '(' + addr.add  +')');
}

function FillVendorArray()
{           
    if(map != 'undefined' && map != null)
    {            
        if(geoArray  != 'undefined' && geoArray.length != 0)
        {                    
             var addr = geoArray[0]; 
             var iconOptions = {}; 
             iconOptions.primaryColor = "#7DDB6E";
             iconOptions.strokeColor = "#000000"; 
             iconOptions.label = addr.pinNumber;
             iconOptions.labelColor = "#000000"; 
             iconOptions.addStar = false; 
             iconOptions.starPrimaryColor = "#FFFF00"; 
             iconOptions.starStrokeColor = "#0000FF"; 
             var customIcon = MapIconMaker.createLabeledMarkerIcon(iconOptions); 
             marker = new GMarker(new GLatLng(PointLati,PointLong), {icon:customIcon});   
             map.addOverlay(marker);  
        }
        window.clearTimeout(fillArrayTimeOut);
    }
    else
    {
        fillArrayTimeOut = window.setTimeout('FillVendorArray()',100);
    }
}

function FillArticleArray()
{           
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {            
            if(geoArray  != 'undefined' && geoArray.length != 0)
            {                    
                for(var j=0;j<geoArray.length;j++)
                {                        
                     var addr = geoArray[j]; 
                     var iconOptions = {}; 
                     iconOptions.primaryColor = "#7DDB6E";
                     iconOptions.strokeColor = "#000000"; 
                     iconOptions.label = addr.pinNumber;
                     iconOptions.labelColor = "#000000"; 
                     iconOptions.addStar = false; 
                     iconOptions.starPrimaryColor = "#FFFF00"; 
                     iconOptions.starStrokeColor = "#0000FF"; 
                     var customIcon = MapIconMaker.createLabeledMarkerIcon(iconOptions); 
                     marker = new GMarker(new GLatLng(addr.Latitude,addr.Longitude), {icon:customIcon});   
                     map.addOverlay(marker);  
               } 
            }
            window.clearTimeout(fillArrayTimeOut);
        }
        else
        {
            fillArrayTimeOut = window.setTimeout('FillArticleArray()',100);
        }
    }   
}

function MagazineGeogGMaptxtKeyword_OnFocus(txtKeyword)
{            
    if(txtKeyword.value == "Search by Keyword")
        txtKeyword.value = "";
}
function MagazineGeogGMaptxtKeyword_OnBlur(txtKeyword)
{            
    if(txtKeyword.value == '')
        txtKeyword.value = "Search by Keyword";
}

function MagazineGeogGMaptxtAddress_OnFocus(txtAddress)
{
    if(txtAddress.value == "Enter City or Zip Code")
        txtAddress.value = "";    
}
function MagazineGeogGMaptxtAddress_OnBlur(txtAddress)
{            
    if(txtAddress.value == '')
        txtAddress.value = "Enter City or Zip Code";
}

function MagazineGeogMapOnSearchLoad()
{
     MagazineGeogMapGetMap();
     MagazineGeogMapFillArray();
}

function MagazineGeogMapGetMap()
{       
    if (document.getElementById('myMap')!=null)
    { 
         map = new GMap2(document.getElementById("myMap"));
         map.setCenter(new GLatLng(defaultLatitute,defaultLongitute), 8);
         
         map.addControl(new GLargeMapControl()); 
         map.addControl(new GMapTypeControl());
    }   
}  

function MagazineGeogMapFillArray()
{
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {            
            if(GeoArray  != 'undefined' && GeoArray.length != 0)
            { 
                deleteAllShapesFromAllLayer();
            }
            window.clearTimeout(fillArrayTimeOut);
        }
        else
        {
            fillArrayTimeOut = window.setTimeout('MagazineGeogMapFillArray()',100);
        }
    }   
}
// to delete all layers (i.e all shapes from all layers) and create new layer and add to map
function deleteAllShapesFromAllLayer()
{
    geoArticleArray = null;
    geoArticleArray = new Array();
    geoVideoArray = null;
    geoVideoArray = new Array();
    geoPhotoEssayArray = null;
    geoPhotoEssayArray = new Array();
    geoVendorArray = null;
    geoVendorArray = new Array();
    
    if(map != 'undefined' && map != null)
    {
        map.clearOverlays();
    }
}     
// to add new address to corresponding array
function fillPushPinArray(lati, longi, zoom, pinNumber, type, title, address)
{
    var addr = new Address();
    addr.contentId = ""; 
    addr.title = title;
    addr.type = type; 
    addr.add = address; 
    addr.Latitude = lati;
    addr.Longitude = longi;
    addr.Zoom = zoom;
    addr.pinNumber = pinNumber;
    if(addr.type == "article")
    {
        geoArticleArray.push(addr);
    }
    else if(addr.type == "video")
    {
        geoVideoArray.push(addr);
    }
    else if(addr.type == "photoessay")
    {
        geoPhotoEssayArray.push(addr);
    }
    else if(addr.type == "vendor" || addr.type == "")
    {
        geoVendorArray.push(addr);
    }
}       
// to get the focus to particular pin which is already added in layer
function showMagazineGeogArticlePushPin(j)
{
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {       
          for(var i=0;i<geoArticleArray.length;i++)
          {
            var arObj = geoArticleArray[i];
            if(arObj.pinNumber == j)
            {
                 var point = new GLatLng(arObj.Latitude,arObj.Longitude);
                 map.panTo(point);
                 map.setCenter(point);
                 map.setZoom(defaultPinZoomLevel);
                 break; 
            }
         }
       }
    } 
}                         
// delete articlelayer and then create new articleLayer and add that layer to map
function deleteAllShapesFromArticleLayer()
{
    if(map != null && map != 'undefined')
    {
        map.clearOverlays();
    } 
}               
// here we actually add the push pins for all addresses from geoArticleArray
function showAllArticlePushPins()
{
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {            
            if(geoArticleArray  != 'undefined' && geoArticleArray.length != 0)
            {
                var tempArray = geoArticleArray;
                deleteAllShapesFromArticleLayer();
                geoArticleArray = tempArray;
                for(var i=0; i < geoArticleArray.length; i++ )
                {
                     var addr = geoArticleArray[i];
                     var point = new GLatLng(addr.Latitude,addr.Longitude);
                     var iconOptions = {}; 
                     iconOptions.primaryColor = "#7DDB6E";//"#FF0000"; 
                     iconOptions.strokeColor = "#000000"; 
                     iconOptions.label =String(addr.pinNumber);
                     iconOptions.labelColor = "#000000"; 
                     iconOptions.addStar = false; 
                     iconOptions.starPrimaryColor = "#FFFF00"; 
                     iconOptions.starStrokeColor = "#0000FF"; 
                     var customIcon = MapIconMaker.createLabeledMarkerIcon(iconOptions); 
                     marker = new GMarker(new GLatLng(addr.Latitude,addr.Longitude), {icon:customIcon});   
                     map.addOverlay(marker); 
                     map.panTo(point);
                }
            }
            window.clearTimeout(fillArticleArrayTimeOut);
        }
        else
        {
            fillArticleArrayTimeOut = window.setTimeout('showAllArticlePushPins()',100);
        }
     }
    else
    {
        fillArticleArrayTimeOut = window.setTimeout('showAllArticlePushPins()',100);
    } 
}                      
// Code for Video...
function showMagazineGeogVideoPushPin(j)
{
  for(var i=0;i<geoVideoArray.length;i++)
  {
        var arObj = geoVideoArray[i];
        if(arObj.pinNumber == j)
        {
             var point = new GLatLng(arObj.Latitude,arObj.Longitude);
             map.panTo(point);
             map.setCenter(point);
             map.setZoom(defaultPinZoomLevel);
             break;
        }
  }
}

function showAllVideoPushPins()
{
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {            
            if(geoVideoArray  != 'undefined' && geoVideoArray.length != 0)
            {
                var tempArray = geoVideoArray;                
                geoVideoArray = tempArray;
                for(var i=0; i < geoVideoArray.length; i++ )
                {
                       //Commented now... 
                     var addr = geoVideoArray[i];
                     var point = new GLatLng(addr.Latitude,addr.Longitude);
                     var iconOptions = {}; 
                     iconOptions.primaryColor = "#0235F6";//"#FF0000"; 
                     iconOptions.strokeColor = "#000000"; 
                     iconOptions.label =String(addr.pinNumber);
                     iconOptions.labelColor = "#FFFFFF";//"#000000"; 
                     iconOptions.addStar = false; 
                     iconOptions.starPrimaryColor = "#FFFF00"; 
                     iconOptions.starStrokeColor = "#0000FF"; 
                     var customIcon = MapIconMaker.createLabeledMarkerIcon(iconOptions); 
                     marker = new GMarker(new GLatLng(addr.Latitude,addr.Longitude), {icon:customIcon});   
                     map.addOverlay(marker); 
                     map.panTo(point); 
                 }
            }
            window.clearTimeout(fillVideoArrayTimeOut);
        }
        else
        {
            fillVideoArrayTimeOut = window.setTimeout('showAllVideoPushPins()',100);
        }
     }
    else
    {
        fillVideoArrayTimeOut = window.setTimeout('showAllVideoPushPins()',100);
    } 
}        

function showMagazineGeogPhotoEssayPushPin(j)
{
      for(var i=0;i<geoPhotoEssayArray.length;i++)
      {
            var arObj = geoPhotoEssayArray[i];
            if(arObj.pinNumber == j)
            {
                var point = new GLatLng(arObj.Latitude,arObj.Longitude);
                map.panTo(point);
                map.setCenter(point);
                map.setZoom(defaultPinZoomLevel);
                break; 
            }
      }
}
        
function showAllPhotoEssayPushPins()
{
    if (document.getElementById('myMap')!= 'undefined' && document.getElementById('myMap')!=null)              
    {
        if(map != 'undefined' && map != null)
        {            
            if(geoPhotoEssayArray  != 'undefined' && geoPhotoEssayArray.length != 0)
            {
                var tempArray = geoPhotoEssayArray;                
                geoPhotoEssayArray = tempArray;
                for(var i=0; i < geoPhotoEssayArray.length; i++ )
                {
                  var point = new GLatLng(addr.Latitude, addr.Longitude);
                  marker = new GMarker(point);
                  map.addOverlay(marker); 
                }
            }
            window.clearTimeout(fillPhotoEssayArrayTimeOut);
        }
        else
        {
            fillPhotoEssayArrayTimeOut = window.setTimeout('showAllPhotoEssayPushPins()',100);
        }
     }
    else
    {
        fillPhotoEssayArrayTimeOut = window.setTimeout('showAllPhotoEssayPushPins()',100);
    } 
}   
           
//This removes the 'class' & 'style' attribute of element. Then set the CSSclass to  'VendorDetails'
function RemoveAttributes(child) 
{
    child.removeAttr('class');
    child.removeAttr('style');
    child.attr('class','VendorDetails');            
}

//This function iterates through children element recursively..
function IterateElements(children) 
{
    if (typeof children == "undefined" || children.size() == 0) 
    {
        return;
    }

    children.each(function()
    {
        var child = $(this);
        if (child.children().size() > 0) 
        {
            IterateElements(child.children());
        }
        RemoveAttributes(child);
    });
}             

function VendorPageLoad()
{
    var lbldesc = $("#" + ids.lblDescription);
    /*
        Iterate thro each child element of lblDescription recursively & 
        removes the 'class' & 'style' attribute of the child element        
        Then set the CSSclass of the child element to 'VendorDetails'
    */
    IterateElements(lbldesc.children());    
    /* 
        Get all <a> (anchor) tags within 'lblDescription'  and attach their onclick event    
        Onclick --> Open the url in new window    
    */        
    $("#" + ids.lblDescription + " a").click 
    (function()
    {           
        window.open(this.href,'_blank','dependent=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,toolbar=no,directories=no,width=500,height=500,screenX=0,screenY=0,left=0,top=0');
        return false;
    });
}

function ShowVendorSignInPopUp()
{
    if ($find('VendorLoginPopup') != null)
    {                            
        $find('VendorLoginPopup').show();       
    } 
    ToggleEmbedVisibility(false);  
    ToggleVendorVideoVisibility(false);
}

function CloseVendorLoginPopup()
{    
    //Reset the control values
    document.getElementById('btnReset').click();    
    //Clear the validation messages if any...
    for (i = 0; i < Page_Validators.length; i++) 
    {
        Page_Validators[i].style.display = 'none';
    }
    window.parent.document.getElementById('btnClose').click();   
    ToggleEmbedVisibility(true); 
    ToggleVendorVideoVisibility(true);
}


/*
This function toogles the video / flash in VideoLibrary/Vendor page for Vendor Login popup
Video / Flash is hidden when popup is displayed
Video / Flash is displayed when popup is hidden
*/
function ToggleEmbedVisibility (value)
{
    try
    {
        var _videoEmbed = $("#" + ids.lblVideoContainer + " embed") 
        if (_videoEmbed != null && _videoEmbed != 'undefined')
        {
            for(var i=0; i < _videoEmbed.length; i++)
            {              
                if (value)                
                    _videoEmbed[i].style.visibility="visible";
                else
                   _videoEmbed[i].style.visibility="hidden";
            }
        }
        
        var _videoObject = $("#" + ids.lblVideoContainer + " object") 
        if (_videoObject != null && _videoObject != 'undefined')
        {
            for(var i=0; i < _videoObject.length; i++)
            {              
                if (value)                
                   _videoObject[i].style.visibility="visible";
                else
                   _videoObject[i].style.visibility="hidden";
            }
        }
     }
     catch(e)
     {
     }
}

function ToggleVendorVideoVisibility (value)
{
    try
    {
        var _videoEmbed = $("#" + ids.lblVideo + " embed")
        if (_videoEmbed != null && _videoEmbed != 'undefined')
        {
            for(var i=0; i < _videoEmbed.length; i++)
            {              
                if (value)                
                    _videoEmbed[i].style.visibility="visible";
                else
                   _videoEmbed[i].style.visibility="hidden";
            }
        }
        
        var _videoObject = $("#" + ids.lblVideo + " object") 
        if (_videoObject != null && _videoObject != 'undefined')
        {
            for(var i=0; i < _videoObject.length; i++)
            {              
                if (value)                
                   _videoObject[i].style.visibility="visible";
                else
                   _videoObject[i].style.visibility="hidden";
            }
        }
    }
    catch(e)
    {
    }
}
function SwapImage(img,newsrc)
{
    img.src = newsrc;
}
function ChangeLinkColorTextOnMouseOver(link)
{
    link.style.color = "#784513";
}
function ChangeLinkColorTextOnMouseOut(link)
{
    link.style.color = "white";
}
function SwapCategoryImage(link,newsrc)
{
    try
    {
        var img;
        for (var i =0; i<link.children.length;i++)
        {
            img = link.children[i];
            img.src=newsrc;
        }
    }
    catch(e)
    {
    }
}