﻿function GetLink() {
    var divTag = document.getElementById('image');
    var imgTag = divTag.lastChild;
    var imgSrc = imgTag.attributes.getNamedItem("src").nodeValue;
    var imgSplit = imgSrc.split('/');
    var len = imgSplit.length;
    var imgNum = imgSplit[len - 1];
    imgNum = imgNum.split(".")[0];
    if (imgNum == "1") window.location = "VehicleWraps.aspx";
    if (imgNum == "2") window.location = "Banners.aspx";
    if (imgNum == "3") window.location = "YardSigns.aspx";
    if (imgNum == "4") window.location = "WallDecals.aspx";
}

function Drop(link) {

    if (link == "what") {
        Effect.BlindDown(document.getElementById('whatp'), { duration: 0.5 });
        Effect.BlindUp(document.getElementById('whyp'), { duration: 0.5 });
        Effect.BlindUp(document.getElementById('whop'), { duration: 0.5 });
    }
    if (link == "why") {
        Effect.BlindUp(document.getElementById('whatp'), { duration: 0.5 });
        Effect.BlindDown(document.getElementById('whyp'), { duration: 0.5 });
        Effect.BlindUp(document.getElementById('whop'), { duration: 0.5 });
    }
    if (link == "who") {
        Effect.BlindUp(document.getElementById('whatp'), { duration: 0.5 });
        Effect.BlindUp(document.getElementById('whyp'), { duration: 0.5 });
        Effect.BlindDown(document.getElementById('whop'), { duration: 0.5 });
    }
}
function fnRollOver(img_name, img_src) {
    
    document[img_name].src = img_src;
}
function temp()
{
    alert("test1");
}
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]), 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 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 fnLogin(button) {

document.getElementById(button).style.background = '#000000'//url('App_Images/SubmitOnHover.html.images/bt0_0.gif');
    
    return false;
}
function fnValidateEmail_Phone(txtPhone, txtEmail, btnSend) {

    var tempPhone;
    var tempEmail;
    var tempSend;
    tempPhone = document.getElementById(txtPhone);
    tempEmail = document.getElementById(txtEmail);
    tempSend = document.getElementById(btnSend);
        
    if (tempPhone.value == "" && tempEmail.value == "") {
        tempSend.disabled = true;
        
    }
    else {
        if (!isEmail(tempEmail.value)) {
            tempSend.disabled = true;

        }
        else {
            tempSend.disabled = false;
        }
    }
}
function isEmail(Mail) {

    Mail = Mail.toLowerCase();
    return (Mail.search(/^([a-z]+)([a-z0-9\-\_\.]{1,100})([a-z0-9]+)\@([a-z0-9]+)([a-z0-9\-\.]*)([a-z0-9]+)\.([a-z]{2,6})$/) != -1);
}
function bantextchanged(txtlength,txtwidth,txtArea,txtPrice,txtCost,ddlBanner) {
    
    var length = document.getElementById(txtlength).value;
    var width = document.getElementById(txtwidth).value;
    var type = document.getElementById(ddlBanner).value;
    var price;
    if (type == "Full Color Digital Banner") {
        price = 4;


    }
    else if (type == "Text Only Banner") {
        price = 2;
    }

    else if (type == "2 Color Banner") {
        price = 2.75;
    }

    var area = length * width / 144;

    var newarea = Math.round(area * Math.pow(10, 2)) / Math.pow(10, 2);
    
    var cost = price * area;
    var newcost = Math.round(cost * Math.pow(10, 2)) / Math.pow(10, 2);
    document.getElementById(txtArea).value = newarea;
    document.getElementById(txtCost).value = newcost;
    return false;
}
function bantypechanged(ddlBanner,txtPrice,txtArea,txtCost) {

    var type = document.getElementById(ddlBanner).value;
    var area = document.getElementById(txtArea).value;
    var price;
    if (type == "Full Color Digital Banner") {
        price = 4;


    }
    else if (type == "Text Only Banner") {
    price = 2;
    }

    else if (type == "2 Color Banner") {
    price = 2.75;
    }
    txtPrice = price;
    var cost = price * area;

    var newcost = Math.round(cost * Math.pow(10, 2)) / Math.pow(10, 2);
    document.getElementById(txtCost).value = newcost;
    return false;
}
function banCalculate(ddlBanner, txtPrice, txtlength, txtwidth, txtCost) {

    var type = document.getElementById(ddlBanner).value;
    var length = document.getElementById(txtlength).value;
    var width = document.getElementById(txtwidth).value;
    var price;
    if (type == "Full Color Digital Banner") {
        price = 4;


    }
    else if (type == "Text Only Banner") {
    price = 2;
    }

    else if (type == "2 Color Banner") {
    price = 2.75;
    }
    var area = length * width / 144;

    var newarea = Math.round(area * Math.pow(10, 2)) / Math.pow(10, 2);

    var cost = price * newarea;

    var newcost = Math.round(cost * Math.pow(10, 2)) / Math.pow(10, 2);
    document.getElementById(txtCost).value = newcost;
    
    return false;
}
function banAreaPriceChanged(txtArea, txtPrice, txtCost) {
debugger

    var area = document.getElementById(txtArea).value;
    var price = document.getElementById(txtwidth).value;

    var cost = area * price;
    document.getElementById(txtCost).value = cost;
    return false;
}
function SlideShowTicker() {
    /***********************************************
    * Conveyor belt slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/


    //Specify the slider's width (in pixels)
    var sliderwidth = "400px"
    //Specify the slider's height
    var sliderheight = "250px"
    //Specify the slider's slide speed (larger is faster 1-10)
    var slidespeed = 5
    //configure background color:
    slidebgcolor = ""

    //Specify the slider's images
    var leftrightslide = new Array()
    var finalslide = ''
    leftrightslide[0] = '<a href="http://"><img src="App_Images/SlideShow/VehicleWrap.jpg" border=0></a>'
    leftrightslide[1] = '<a href="http://"><img src="App_Images/SlideShow/Banners1.jpg" border=0></a>'

    //Specify gap between each image (use HTML):
    var imagegap = " "

    //Specify pixels gap between each slideshow rotation (use integer):
    var slideshowgap = 5


    ////NO NEED TO EDIT BELOW THIS LINE////////////

    var copyspeed = slidespeed
    leftrightslide = '<nobr>' + leftrightslide.join(imagegap) + '</nobr>'
    var iedom = document.all || document.getElementById
    if (iedom)
        document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">' + leftrightslide + '</span>')
    var actualwidth = ''
    var cross_slide, ns_slide

    function fillup() {
        if (iedom) {
            cross_slide = document.getElementById ? document.getElementById("test2") : document.all.test2
            cross_slide2 = document.getElementById ? document.getElementById("test3") : document.all.test3
            cross_slide.innerHTML = cross_slide2.innerHTML = leftrightslide
            actualwidth = document.all ? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
            cross_slide2.style.left = actualwidth + slideshowgap + "px"
        }
        else if (document.layers) {
            ns_slide = document.ns_slidemenu.document.ns_slidemenu2
            ns_slide2 = document.ns_slidemenu.document.ns_slidemenu3
            ns_slide.document.write(leftrightslide)
            ns_slide.document.close()
            actualwidth = ns_slide.document.width
            ns_slide2.left = actualwidth + slideshowgap
            ns_slide2.document.write(leftrightslide)
            ns_slide2.document.close()
        }
        lefttime = setInterval("slideleft()", 30)
    }
    window.onload = fillup

    function slideleft() {
        if (iedom) {
            if (parseInt(cross_slide.style.left) > (actualwidth * (-1) + 8))
                cross_slide.style.left = parseInt(cross_slide.style.left) - copyspeed + "px"
            else
                cross_slide.style.left = parseInt(cross_slide2.style.left) + actualwidth + slideshowgap + "px"

            if (parseInt(cross_slide2.style.left) > (actualwidth * (-1) + 8))
                cross_slide2.style.left = parseInt(cross_slide2.style.left) - copyspeed + "px"
            else
                cross_slide2.style.left = parseInt(cross_slide.style.left) + actualwidth + slideshowgap + "px"

        }
        else if (document.layers) {
            if (ns_slide.left > (actualwidth * (-1) + 8))
                ns_slide.left -= copyspeed
            else
                ns_slide.left = ns_slide2.left + actualwidth + slideshowgap

            if (ns_slide2.left > (actualwidth * (-1) + 8))
                ns_slide2.left -= copyspeed
            else
                ns_slide2.left = ns_slide.left + actualwidth + slideshowgap
        }
    }


    if (iedom || document.layers) {
        with (document) {
            document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
            if (iedom) {
                write('<div style="position:relative;width:' + sliderwidth + ';height:' + sliderheight + ';overflow:hidden">')
                write('<div style="position:absolute;width:' + sliderwidth + ';height:' + sliderheight + ';background-color:' + slidebgcolor + '" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
                write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
                write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
                write('</div></div>')
            }
            else if (document.layers) {
                write('<ilayer width=' + sliderwidth + ' height=' + sliderheight + ' name="ns_slidemenu" bgColor=' + slidebgcolor + '>')
                write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
                write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
                write('</ilayer>')
            }
            document.write('</td></table>')
        }
    }

}
function highlightLink() {
    var page = top.location.href;
    newImage = "url(App_Images/Layout/back.png)";
    debugger
    if (page.match('index.aspx')) {
        document.getElementById('home').style.backgroundImage = newImage;
        document.getElementById('home').style.color = '#232323';
    }
    else if (page.match('VehicleWraps.aspx')) {

        document.getElementById('services').style.backgroundImage = newImage;
        document.getElementById('services').style.color = '#232323';
    }
}
function GetVehicleDetails(InpState, Data,Type, OutState) {

    
    var gv = document.getElementById(Data);
    var Make = document.getElementById(InpState).value;
    var States = document.getElementById(OutState);
    var count=0;
    var state;    
    var localtype;
     if(Type == "Make")
     {
        localtype = 0;
     }
     else if (Type == "Model")
     {
        localtype = 1;
     }    
    
    States.options.length = 0;
    state = new Option("Select","Select"); 
    States[0]=state;
        
        
    
    if (gv != null) 
    {
        var elem = gv.rows[1].cells[0].innerHTML;
    }
    var flag;
    var index = 0;
    for (var i = 1; i < gv.rows.length; i++) 
    {
        flag = false;
        if (gv.rows[i].cells[localtype].innerHTML == Make)
        {
            for (var j = 0;j<States.options.length;j++)
            {
                
                if(States[j].value == gv.rows[i].cells[localtype+1].innerHTML)
                {
                    flag = true;
                    break;
                }
            }
            if (flag == false && gv.rows[i].cells[localtype + 1].innerHTML !="")
            {
                state = new Option(gv.rows[i].cells[localtype+1].innerHTML,gv.rows[i].cells[localtype+1].innerHTML);
                States[index] = state
                index++;
            }
        }
    }
}



