﻿// JScript File
    function getIFrameDocument(aID)
    { 
        var rv = null; 
        var frame=document.getElementById(aID);
        // if contentDocument exists, W3C 

//compliant (e.g. Mozilla) 
        if (frame.contentDocument)
            rv = frame.contentDocument;
        else // bad Internet Explorer  ;)
            rv = document.getElementById(aID).document;
        return rv;
    }

    function adjustMyFrameHeight()
    {
    debugger
        var f = document.getElementById("myFrame");
        //var frameDoc = getIFrameDocument("myFrame");
        //var height = frameDoc.body.scrollHeight;
        var height =  f.contentWindow.document.body.scrollHeight + 'px';
        f.style.height = f.contentWindow.document.body.scrollHeight + 'px';
    }

function highlightLink()
{
    var page = top.location.href;
    newImage = "url(images/menu_active.gif)";
    if(page.match('index.aspx'))
    {        
        //document.getElementById('index').style.backgroundImage = newImage;
        document.getElementById('index').style.color = '#232323';
    }
    else if(page.match('Engines.aspx'))
    {        
        //document.getElementById('Engines').style.backgroundImage = newImage;
        document.getElementById('Engines').style.color = '#232323';
    }
    else if(page.match('Parts.aspx') || page.match('Categories.aspx'))
    {        
        //document.getElementById('Parts').style.backgroundImage = newImage;
        document.getElementById('Parts').style.color = '#232323';
    }
    else if(page.match('Support.aspx'))
    {        
        //document.getElementById('Support').style.backgroundImage = newImage;
        document.getElementById('Support').style.color = '#232323';
    }
    else if(page.match('AboutUs.aspx'))
    {        
        //document.getElementById('AboutUs').style.backgroundImage = newImage;
        document.getElementById('AboutUs').style.color = '#232323';
    }
    else if(page.match('ContactUs.aspx'))
    {        
        //document.getElementById('ContactUs').style.backgroundImage = newImage;
        document.getElementById('ContactUs').style.color = '#232323';
    }            
}
function showAddress(search,div_map) 
      {      
      var map = new GMap(document.getElementById(div_map));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(20,0),2);      
      // ====== Create a Client Geocoder ======
      var geo = new GClientGeocoder();

      // ====== Array for decoding the failure codes ======
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      
        //var search = document.getElementById(search).innerText;
        
        // ====== Perform the Geocoding ======        
        geo.getLocations(search, function (result)
          { 
            // If that was successful
            if (result.Status.code == G_GEO_SUCCESS) {              
              // Loop through the results, placing markers
              for (var i=0; i<result.Placemark.length; i++) {
                var p = result.Placemark[i].Point.coordinates;
                
                //Code for arial view
                var marker = new GMarker(new GLatLng(p[1],p[0]));             
                map.addOverlay(marker);                
                //marker.openInfoWindowHtml('MEMO-Omega MFG, Inc.');                
                //Code ends for arial view
              }
                //Code for arial view
                // centre the map on the first result
                var p = result.Placemark[0].Point.coordinates;
                map.setCenter(new GLatLng(p[1],p[0]),11);
                //Code ends for arial view
              
              //Code for Street view
//                    var fenwayPark = new GLatLng(p[1],p[0]);
//                    panoramaOptions = { latlng:fenwayPark };
//                    var myPano = new GStreetviewPanorama(document.getElementById(div_map), panoramaOptions);
              //Code End for Street view
              
            }
            // ====== Decode the error status ======
            else {
              var reason="Code "+result.Status.code;
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              alert('Could not find "'+search+ '" ' + reason);
            }            
          }          
        );
        //Code for second marker
//        geo.getLocations('Dallas Fort Worth International Airport', function (result)
//          { 
//            // If that was successful
//            if (result.Status.code == G_GEO_SUCCESS) {              
//              // Loop through the results, placing markers
//              for (var i=0; i<result.Placemark.length; i++) {
//                var p = result.Placemark[i].Point.coordinates;
//                
//                //Code for arial view
//                var marker2 = new GMarker(new GLatLng(p[1],p[0]));             
//                map.addOverlay(marker2);
//                //marker2.openInfoWindowHtml('DFW Airport');
//                //Code ends for arial view
//              }
//                //Code for arial view
//                // centre the map on the first result
//                //var p = result.Placemark[0].Point.coordinates;
//                //map.setCenter(new GLatLng(p[1],p[0]),14);
//                //Code ends for arial view
//              
//              //Code for Street view
////                    var fenwayPark = new GLatLng(p[1],p[0]);
////                    panoramaOptions = { latlng:fenwayPark };
////                    var myPano = new GStreetviewPanorama(document.getElementById(div_map), panoramaOptions);
//              //Code End for Street view
//              
//            }
//            // ====== Decode the error status ======
//            else {
//              var reason="Code "+result.Status.code;
//              if (reasons[result.Status.code]) {
//                reason = reasons[result.Status.code]
//              } 
//              alert('Could not find "'+search+ '" ' + reason);
//            }            
//          }          
//        );    
        //Code ends for second marker
        //Code for direction
//        var directionsPanel;
//        var directions;
//        directionsPanel = document.getElementById("my_textual_div");
//        directions = new GDirections(map, directionsPanel);
//        directions.load("from: Dallas Fort Worth International Airport to: 720 South Kimball Avenue,Southlake, Texas");
        //Code ends for direction
      }
    function SearchBoxFocus(txtsearch)
    {
        var search = document.getElementById(txtsearch);
        if (search.value=="Search Memo-Omega...")
        {
            search.value = ""
            search.style.color = "black";
        }
    }
    function SearchBoxBlur(txtsearch)
    {
        var search = document.getElementById(txtsearch);
        if (search.value=="")
        {
            search.value = "Search Memo-Omega..."
            search.style.color = "DimGray";
        }
    }
    function FillCategoryDDL(Country, State,lblSub)
    {
    var Make = document.getElementById(Country).value;
    var States = document.getElementById(State);
    States.style.display = "inline"
    document.getElementById(lblSub).style.display = "inline"
    var count=0;
    var state; 
    if(Make=="Bearings / Bushings")
    {
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Connecting Rod Bearings","Connecting Rod Bearings"); States[count]=state; count++;
        state = new Option("Main Bearings","Main Bearings"); States[count]=state; count++;
        state = new Option("Camshaft Bushings / Washers","Camshaft Bushings / Washers"); States[count]=state; count++;
        state = new Option("Other Bearings / Bushings","Other Bearings / Bushings"); States[count]=state; count++;
     }
    else if(Make=="Filters")
    {
        count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Air Filters","Air Filters"); States[count]=state; count++;
        state = new Option("Fuel Filters","Fuel Filters"); States[count]=state; count++;
        state = new Option("Oil Filters","Oil Filters"); States[count]=state; count++;       
    }
    else if(Make=="Flywheels & Components")
    {
    count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Flywheels","Flywheels"); States[count]=state; count++;
        state = new Option("Ring Gears","Ring Gears"); States[count]=state; count++;
        state = new Option("Other","Other"); States[count]=state; count++;
        
       
    }
    else if(Make=="Gasket Kits")
    {
    count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Complete Engine Gasket Kit","Complete Engine Gasket Kit"); States[count]=state; count++;
        state = new Option("Cylinder Head Gasket Kit","Cylinder Head Gasket Kit"); States[count]=state; count++;
        
    }
    else if(Make=="Gaskets")
    {
    count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Cylinder Head Gaskets","Cylinder Head Gaskets"); States[count]=state; count++;
        state = new Option("Valve Cover Gaskets","Valve Cover Gaskets"); States[count]=state; count++;
        state = new Option("Other Gaskets","Other Gaskets"); States[count]=state; count++;       
    }
    else if(Make=="Pulleys")
    {
    count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Idler Pulleys","Idler Pulleys"); States[count]=state; count++;
        state = new Option("Crankshaft Pulleys","Crankshaft Pulleys"); States[count]=state; count++;
        state = new Option("Other","Other"); States[count]=state; count++; 
    }
    else if(Make=="Valve Drive Components")
    {
    count=0;
        States.options.length = 0;
        state = new Option("Select","Select"); States[count]=state; count++;
        state = new Option("Valves","Valves"); States[count]=state; count++;
        state = new Option("Valve Seats / Seat Inserts","Valve Seats / Seat Inserts"); States[count]=state; count++;
        state = new Option("Valve Guides","Valve Guides"); States[count]=state; count++; 
        state = new Option("Valve Springs","Valve Springs"); States[count]=state; count++; 
        state = new Option("Valve Cones","Valve Cones"); States[count]=state; count++; 
    }
    else
    {
        States.options.length = 0;
        state = new Option("--","--"); States[count]=state; count++;
        States.style.display = "none"
        document.getElementById(lblSub).style.display = "none"
    }
}
function selectOption(control,value)
{debugger
	document.getElementById(control).selectedIndex = value;
}
