﻿try {
    if (typeof(window.google_ad_skip) == 'undefined') {
        window.google_ad_skip = 0;
    }
}
catch (e) { window.google_ad_skip = 0; }

try {
    if (typeof(window.google_page_location) == 'undefined') {
        window.google_page_location = '';
    }
}
catch (e) { window.google_page_location = ''; }

try {
    if (typeof(google_page_channel) == 'undefined') {
        var google_page_channel = '';
    }
    else {
        google_page_channel = '';
    }
}
catch (e) { window.google_page_channel = ''; }

try {
    if (typeof(AdInput) == 'undefined') {
        var AdInput = new Array();
    }
}
catch (e) { window.AdInput = new Array(); }

try {
    if (typeof(AdImpression) == 'undefined') {
        var AdImpression = new Array();
    }
}
catch (e) { window.AdImpression = new Array(); }

try {
    if (typeof(AdClick) == 'undefined') {
        var AdClick = new Object();
    }
}
catch (e) { window.AdClick = new Object(); }

try {
    if (typeof(advertise_on_ehow) == 'undefined') {
        var advertise_on_ehow = true;
    }
    else {
        advertise_on_ehow = true;
    }
}
catch (e) { }

function HandleAdUnitImpression(google_ads) {
    try {
        if (typeof(google_ads) != 'undefined') {
            AdImpression.push(google_ads);
        }
    }
    catch (e) {}
    return;
}


//google callback function
function google_ad_request_done(google_ads) {

    if (google_ads.length == 0) {
        try {
            HandleAdUnitImpression(google_ads);
        }
        catch (e) {}
        return;
    }

    //*************************************************************************
    //CREATIVE SECTION
    //*************************************************************************

    var apostrophe1 = /'/ig;
    var apostrophe2 = /&#39;/ig;
    var s = "";
    if (google_ads[0].type == "image") {
        try {
            if (google_ad.image_width <= 160) {
                s += '<a class="header" href="' + google_info.feedback_url + '">Ads by Google</a>';
            }
        }
        catch (e) {}
        s +=    '<table border="0">';
        s +=    '<tr>';
        s +=    '<td colspan="2">';
        s +=    '<a rel="no follow" id=' + adunit_id + ' target="newwindow" href="' + google_ads[0].url + '" target="_top" title="go to ' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + '">';
        s +=    '<img border="0" src="' + google_ads[0].image_url + '" width="' + google_ads[0].image_width + '" height="' + google_ads[0].image_height + '">';
        s +=    '</a>';
        s +=    '</td>';
        s +=    '</tr>';
        s +=    '<tr>';
        s +=    '<td align="left" class="advertise" valign="top">';
        s +=    '<a rel="no follow" id=' + adunit_id + ' target="newwindow" href="' + google_ads[0].url + '" target="_top" title="go to ' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + '">';
                if (google_ads[0].visible_url.replace(apostrophe1,"&#39;").length <= 25) {
                    s += google_ads[0].visible_url.replace(apostrophe1,"&#39;");
                }
                else {
                    s += '<span class="LongURL">' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + "</span>";
                }
        s +=    '</a>';
        s +=    '</td>';
        s +=    '<td align="right" nowrap>';
                try {
                    if (google_ad.image_width <= 160) {
                        s += '';
                    }
                    else {
                        s += '<a class="header" href="' + google_info.feedback_url  + '">';
                            if (google_ads[0].visible_url.replace(apostrophe1,"&#39;").length <= 25) {
                                s += 'Ads by Google';
                            }
                            else {
                                s += '<span class="LongURLHeader">Ads by Google</span>';
                            }
                        s += '</a>';
                    }
                }
                catch (e) {}
        s +=    '</td>';
        s +=    '</table>';
    }
    else if (google_ads[0].type == "flash") {
        try {
            if ((google_ad.image_width <= 160) && (google_ad.image_url.indexOf('googleadplayer.swf') == -1)) {
                s += '<a class="header" href="' + google_info.feedback_url + '">Ads by Google</span>';
            }
        }
        catch (e) {}
        s +=    '<table border="0">';
        s +=    '<tr>';
        s +=    '<td colspan="2">';
        s +=    '<span>';
        s +=    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        s +=    'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
        s +=    'WIDTH="' + google_ad.image_width + '" ';
        s +=    'HEIGHT="' + google_ad.image_height + '"';
        s +=    '>';
        s +=    '<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">';
        s +=    '<PARAM NAME="quality" VALUE="high">';
        s +=    '<PARAM NAME="AllowScriptAccess" VALUE="never">';
        s +=    '<PARAM NAME="wmode" VALUE="transparent">';
        s +=    '<EMBED src="' + google_ad.image_url + '" WIDTH="' + google_ad.image_width + '" HEIGHT="' + google_ad.image_height + '" TYPE="application/x-shockwave-flash"' + ' wmode="transparent" ' + ' AllowScriptAccess="never" ' + ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
        s +=    '</object>';
        s +=    '</span>';
        s +=    '</td>';
        s +=    '</tr>';
        s +=    '<tr>';
        s +=    '<td align="left" class="advertise" valign="top">';
                try {
                    if (google_ad.image_url.indexOf('googleadplayer.swf') != -1) {
                        s +=    '';
                    }
                    else {
                        s +=    '<a rel="no follow" id=' + adunit_id + ' target="newwindow" href="' + google_ads[0].url + '" target="_top" title="go to ' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + '">';
                        if (google_ads[0].visible_url.replace(apostrophe1,"&#39;").length <= 25) {
                            s += google_ads[0].visible_url.replace(apostrophe1,"&#39;");
                        }
                        else {
                            s += '<span class="LongURL">' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + "</span>";
                        }
                        s +=    '</a>';
                        }
                    }
                catch (e) {}
                s += '</td>';
                s += '<td align="right">';
                s += '<a class="header" style="text-align:right;" href="' + google_info.feedback_url + '">';
                try {
                    if (google_ad.image_url.indexOf('googleadplayer.swf') != -1) {
                        s +=    '';
                    }
                    else {
                        try {
                            if (google_ad.image_width <= 160) {
                                s +=    '';
                            }
                            else {
                                s +=    'Ads by Google';
                            }
                        }
                        catch (e) {}
                    }
                }
                catch (e) {}
        s +=    '</a>';
        s +=    '</td>';
        s +=    '</tr>';
        s +=    '</table>';
    }
    else if (google_ads[0].type == "text") {

        window.google_ad_skip += google_ads.length;

        s += '<a class="header" href="' + google_info.feedback_url + '">Ads by Google</a>';

        if (google_ads.length == 1) {
            s +=    '<div class="Ad">';
            s +=        '<a rel="no follow" id=' + adunit_id + ' target="newwindow" href="' + google_ads[0].url + '" target="_top" title="go to ' + google_ads[0].visible_url.replace(apostrophe1,"&#39;") + '">';
            s +=        '<span class="title">';
                        if ((typeof(google_ads[0].line1) != 'undefined') && (google_ads[0].line1 != null) && (google_ads[0].line1 != '')) {
            s +=            google_ads[0].line1.replace(apostrophe1,"&#39;");
                        }
            s +=        '<br />';
            s +=        '</span>';
            s +=        '<span class="copy">';
                        if ((typeof(google_ads[0].line2) != 'undefined') && (google_ads[0].line2 != null) && (google_ads[0].line2 != '')) {
            s +=            google_ads[0].line2.replace(apostrophe1,"&#39;");
            s +=            '&nbsp;';
                        }
                        if ((typeof(google_ads[0].line3) != 'undefined') && (google_ads[0].line3 != null) && (google_ads[0].line3 != '')) {
            s +=            google_ads[0].line3.replace(apostrophe1,"&#39;");
                        }
            s +=        '<br />';
            s +=        '</span>';
            s +=        '<span class=\"baseurl\">';
                        if ((typeof(google_ads[0].visible_url) != 'undefined') && (google_ads[0].visible_url != null) && (google_ads[0].visible_url != '')) {
            s +=            google_ads[0].visible_url.replace(apostrophe1,"&#39;");
                        }
            s +=        '</span>';
            s +=        '</a>';
            s +=    '</div>';
        }
        else if (google_ads.length > 1) {
            for (var i=0; i < google_ads.length; i++) {
                s +=    '<div class="Ad">';
                s +=        '<a style="display:block" rel="no follow" id=' + adunit_id + ' target="newwindow" href="' + google_ads[i].url + '" target="_top" title="go to ' + google_ads[i].visible_url.replace(apostrophe1,"&#39;") + '">';
                s +=        '<span class="title">';
                            if ((typeof(google_ads[i].line1) != 'undefined') && (google_ads[i].line1 != null) && (google_ads[i].line1 != '')) {
                s +=            google_ads[i].line1.replace(apostrophe1,"&#39;");
                            }
                s +=        '<br />';
                s +=        '</span>';
                s +=        '<span class="copy">';
                            if ((typeof(google_ads[i].line2) != 'undefined') && (google_ads[i].line2 != null) && (google_ads[i].line2 != '')) {
                s +=            google_ads[i].line2.replace(apostrophe1,"&#39;");
                s +=            '&nbsp;';
                            }
                            if ((typeof(google_ads[i].line3) != 'undefined') && (google_ads[i].line3 != null) && (google_ads[i].line3 != '')) {
                s +=            google_ads[i].line3.replace(apostrophe1,"&#39;");
                            }
                s +=        '<br />';
                s +=        '</span>';
                s +=        '<span class="baseurl">';
                            if ((typeof(google_ads[i].visible_url) != 'undefined') && (google_ads[i].visible_url != null) && (google_ads[i].visible_url != '')) {
                s +=            google_ads[i].visible_url.replace(apostrophe1,"&#39;");
                            }
                s +=        '</span>';
                s +=        '</a>';
                s +=    '</div>';
                s +=    '<br />';
            }
        }
    }
    //*
    //*************************************************************************
    //CREATIVE SECTION
    //*************************************************************************

    try {
        google_ads.push(new Object());
        //google_ads[google_ads.length-1].n = google_ads.length;
        google_ads[google_ads.length-1].markup = s;
        google_ads[google_ads.length-1].adunit_id = adunit_id;

        //if (typeof(google_ad_div) != 'undefined') {
        //    if (google_ad_div != null && google_ad_div != '') {
        //        google_ads[google_ads.length-1].google_ad_div = google_ad_div;
        //    }
        //}
    }
    catch (e) {}

    try {
        HandleAdUnitImpression(google_ads);
    }
    catch (e) {}

    try {
        if ((typeof(google_ad_div) != 'undefined') && (google_ad_div != null) && (google_ad_div != '')) {
            try {
                var targetDiv;
                if (document.getElementById) {
                    //document.getElementById(google_ad_div).innerHTML = s;
                    targetDiv = document.getElementById(google_ad_div);
                    targetDiv.innerHTML = s;
                }
                else if (document.all) {
                    //document.all[google_ad_div].innerHTML = s;
                    targetDiv = document.all[google_ad_div];
                    targetDiv.innerHTML = s;
                }
                else if (document.layers) {
                    targetDiv = document.layers[google_ad_div];
                    targetDiv.document.open();
                    targetDiv.document.writeln(s);
                    targetDiv.document.close();
                }
                else {
                    document.getElementById(google_ad_div).innerHTML = s;
                }
            }
            catch (e) {}
        }
    }
    catch (e) {}

    try {
        if (typeof(google_page_channel) == 'undefined') {
            try {
                window.google_page_channel = '';
                if (typeof(window.channel) != 'undefined') {
                    if ((window.channel != null) && (window.channel != '')) {
                        window.google_page_channel = window.channel;
                    }
                }
            }
            catch (e) { window.google_page_channel = 'nocat'; }
        }
        else {
            try {
                if (typeof(window.channel) != 'undefined') {
                    if ((window.channel != null) && (window.channel != '')) {
                        google_page_channel = window.channel;
                    }
                }
            }
            catch (e) { }
        }
    }
    catch (e) { window.google_page_channel = 'nocat'; }

    return;
}   //end function google_ad_request_done
