function URLEncode(plaintext) {
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" +                    // Numeric
                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +    // Alphabetic
                    "abcdefghijklmnopqrstuvwxyz" +
                    "-_.!~*'()";                    // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    //var plaintext = document.URLForm.F1.value;
    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ ) {
        var ch = plaintext.charAt(i);
        if (ch == " ") {
            encoded += "+";                // x-www-urlencoded, rather than %20
        } else if (SAFECHARS.indexOf(ch) != -1) {
            encoded += ch;
        } else {
            var charCode = ch.charCodeAt(0);
            if (charCode > 255) {
                alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
                          "(URL encoding only supports 8-bit characters.)\n" +
                          "A space (+) will be substituted." );
                encoded += "+";
            } else {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
            }
        }
    } // for

    //document.URLForm.F2.value = encoded;
    return encoded;
};


if (no_pageview == undefined) var no_pageview = 0;
if (ad_keyword == undefined) var ad_keyword = "";
if (ad_tag == undefined) var ad_tag = "";
if (ad_min_price == undefined) var ad_min_price = 0;
ad_keyword=URLEncode(ad_keyword);
function resize_me(fr,w,h){;fr.style.width=w+"px";fr.style.height=h+"px"}
//get size if no size default to 728 x 90
if(ad_type){ad=ad_type.split("_");t=ad[0];dims=ad[1].split("x");w=dims[0];h=dims[1]}else{ad_type="text_728x90";t="text";w=728;h=90}
//get ad block
document.write ('<iframe width="'+w+'" height="'+h+'" name="mechmedia" scrolling="no" frameborder="0" allowtransparency="true" hspace="0" vspace="0" marginheight="0" marginwidth="0" src="http://costumeads.com/costumeads/showads.php?ad_type='+ad_type+'&amp;keyword='+ad_keyword+'&amp;ad_border='+escape(ad_border)+'&amp;ad_bg='+escape(ad_bg)+'&amp;ad_title='+escape(ad_title)+'&amp;ad_body='+escape(ad_body)+'&amp;ad_link='+escape(ad_link)+'&amp;ad_ft_color='+escape(ad_ft_color)+'&amp;ad_campaign='+escape(ad_campaign)+'&amp;url='+escape(document.location)+'&amp;referer='+escape(document.referrer)+'&amp;no_pageview='+escape(no_pageview)+'&ad_min_price='+ad_min_price+'&tag='+ad_tag+'&pub_id='+pub_id+'"></iframe>');
no_pageview = 1;
