/*jslint nomen:false, debug:true, evil:true, vars:false, browser:true, forin:true, undef:false, white:false */
/**
 * Includes a Form with javascript
 * @param {Object} formId
 * @param {Object} initialHeight
 * @param {Object} iframeCode
 */
function FrameBuilder (formId, appendTo, initialHeight, iframeCode){
    this.formId = formId;
    this.initialHeight = initialHeight;
    this.iframeCode = iframeCode;
    this.frame = null;
    this.timeInterval= 200;
    this.appendTo = appendTo || false;
    
    // initialize function for object
    this.init = function(){
        this.createFrame();
        this.addFrameContent(this.iframeCode);
    };
    
    // Create the frame
    this.createFrame = function(){
        var htmlCode = "<"+"iframe src=\"\" allowtransparency=\"true\" frameborder=\"0\" name=\""+this.formId+"\" id=\""+this.formId+"\" style=\"width:100%; height:"+this.initialHeight+"px; border:none;\" scrolling=\"no\"></if"+"rame>";
        if(this.appendTo === false){
            document.write(htmlCode);
        }else{
            var tmp = document.createElement('div');
            tmp.innerHTML = htmlCode;
            var a = this.appendTo;
            document.getElementById(a).appendChild(tmp.firstChild);            
        }
        // also get the frame for future use.
        this.frame = document.getElementById(this.formId);
        // set the time on the on load event of the frame
        this.addEvent(this.frame, 'load', this.bindMethod(this.setTimer, this));
    };
    
    // add event function for different browsers
    this.addEvent = function( obj, type, fn ) {
        if ( obj.attachEvent ) {
            obj["e"+type+fn] = fn;
            obj[type+fn] = function() { obj["e"+type+fn]( window.event ); };
            obj.attachEvent( "on"+type, obj[type+fn] );
        }
        else{
            obj.addEventListener( type, fn, false );   
        }
    };
    
    this.addFrameContent = function (string){
        string = string.replace(new RegExp('src\\=\\"[^"]*captcha.php\"><\/scr'+'ipt>', 'gim'), 'src="http://api.recaptcha.net/js/recaptcha_ajax.js"></scr'+'ipt><'+'div id="recaptcha_div"><'+'/div>'+
                '<'+'style>#recaptcha_logo{ display:none;} #recaptcha_tagline{display:none;} #recaptcha_table{border:none !important;} .recaptchatable .recaptcha_image_cell, #recaptcha_table{ background-color:transparent !important; } <'+'/style>'+
                '<'+'script defer="defer"> window.onload = function(){ Recaptcha.create("6Ld9UAgAAAAAAMon8zjt30tEZiGQZ4IIuWXLt1ky", "recaptcha_div", {theme: "clean",tabindex: 0,callback: function (){'+
                'if (document.getElementById("uword")) { document.getElementById("uword").parentNode.removeChild(document.getElementById("uword")); } if (window["validate"] !== undefined) { if (document.getElementById("recaptcha_response_field")){ document.getElementById("recaptcha_response_field").onblur = function(){ validate(document.getElementById("recaptcha_response_field"), "Required"); } } } if (document.getElementById("recaptcha_response_field")){ document.getElementsByName("recaptcha_challenge_field")[0].setAttribute("name", "anum"); } if (document.getElementById("recaptcha_response_field")){ document.getElementsByName("recaptcha_response_field")[0].setAttribute("name", "qCap"); }}})'+
                ' }<'+'/script>');
        string = string.replace(/(type="text\/javascript">)\s+(validate\(\"[^"]*"\);)/, '$1 jTime = setInterval(function(){if("validate" in window){$2clearTimeout(jTime);}}, 1000);');
        var frameDocument = (this.frame.contentWindow) ? this.frame.contentWindow : (this.frame.contentDocument.document) ? this.frame.contentDocument.document : this.frame.contentDocument;
        frameDocument.document.open();
        frameDocument.document.write(string);
        setTimeout( function(){
            frameDocument.document.close();
            try{
                if('JotFormFrameLoaded' in window){
                    JotFormFrameLoaded();
                }
            }catch(e){}
        },200);
    };
    
    this.setTimer = function(){
        var self = this;
        this.interval = setTimeout(function(){self.changeHeight();},this.timeInterval);
    };
    
    this.changeHeight = function (){
        var actualHeight = this.getBodyHeight();
        var currentHeight = this.getViewPortHeight();
        if(actualHeight === undefined){
            this.frame.style.height = "100%";
            if(!this.frame.style.minHeight){
                this.frame.style.minHeight = "300px";
            }
        }else if  (Math.abs(actualHeight - currentHeight) > 18){
            this.frame.style.height = (actualHeight)+"px";
        }
        this.setTimer();
    };
    
    this.bindMethod = function(method, scope) {
        return function() {
            method.apply(scope,arguments);
        };
    };
    
    this.getBodyHeight = function (){
        var height;
        var scrollHeight;
        var offsetHeight;
        try{  // Prevent IE from throw errors
            if (this.frame.contentWindow.document.height){
                
                height = this.frame.contentWindow.document.height;
                //Emre: to prevent "iframe height"  problem (61059)
                if (this.frame.contentWindow.document.body.scrollHeight){
                    height = scrollHeight = this.frame.contentWindow.document.body.scrollHeight;
                }
                
                if (this.frame.contentWindow.document.body.offsetHeight){
                    height = offsetHeight = this.frame.contentWindow.document.body.offsetHeight;
                }
                
            } else if (this.frame.contentWindow.document.body){
                
                if (this.frame.contentWindow.document.body.scrollHeight){
                    height = scrollHeight = this.frame.contentWindow.document.body.scrollHeight;
                }
                
                if (this.frame.contentWindow.document.body.offsetHeight){
                    height = offsetHeight = this.frame.contentWindow.document.body.offsetHeight;
                }
                
                if (scrollHeight && offsetHeight){
                    height = Math.max(scrollHeight, offsetHeight);
                }
            }            
        }catch(e){ }
        return height;
    };
    
    this.getViewPortHeight = function(){
        var height = 0;
        try{ // Prevent IE from throw errors
            if (this.frame.contentWindow.window.innerHeight)
            {
                height = this.frame.contentWindow.window.innerHeight - 18;
            }
            else if ((this.frame.contentWindow.document.documentElement) &&
                     (this.frame.contentWindow.document.documentElement.clientHeight))
            {
                height = this.frame.contentWindow.document.documentElement.clientHeight;
            }
            else if ((this.frame.contentWindow.document.body) &&
                     (this.frame.contentWindow.document.body.clientHeight))
            {
                height = this.frame.contentWindow.document.body.clientHeight;
            }            
        }catch(e){ }
        return height;
    };
    
    this.init();
}
FrameBuilder.get = [];
var i93430103490 = new FrameBuilder("93430103490", false, "", "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\">\n<html><head>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" \/>\n<meta name=\"HandheldFriendly\" content=\"true\" \/>\n<title>Form<\/title>\n<link href=\"http:\/\/max.jotfor.ms\/min\/g=formCss?3.0.2435\" rel=\"stylesheet\" type=\"text\/css\" \/>\n<style type=\"text\/css\">\n    .form-label{\n        width:150px !important;\n    }\n    .form-label-left{\n        width:150px !important;\n    }\n    .form-line{\n        padding:5px;\n    }\n    .form-label-right{\n        width:150px !important;\n    }\n    body, html{\n        margin:0;\n        padding:0;\n        background:black;\n    }\n\n    .form-all{\n        margin:0px auto;\n        padding-top:20px;\n        width:520px;\n        background:black;\n        color:white !important;\n        font-family:Verdana;\n        font-size:12px;\n    }\n<\/style>\n\n<script src=\"http:\/\/max.jotfor.ms\/min\/g=jotform?3.0.2435\" type=\"text\/javascript\"><\/script>\n<script type=\"text\/javascript\">\n var jsTime = setInterval(function(){try{\n   JotForm.jsForm = true;\n\n   JotForm.init();\n\n   clearInterval(jsTime);\n }catch(e){}}, 1000);\n<\/script>\n<\/head>\n<body>\n<form class=\"jotform-form\" action=\"http:\/\/submit.jotform.com\/submit.php\" method=\"post\" name=\"form_93430103490\" id=\"93430103490\" accept-charset=\"utf-8\">\n  <input type=\"hidden\" name=\"formID\" value=\"93430103490\" \/>\n  <div class=\"form-all\">\n    <ul class=\"form-section\">\n      <li class=\"form-line\" id=\"id_10\">\n        <div id=\"cid_10\" class=\"form-input-wide\">\n          <div id=\"text_10\" class=\"form-html\">\n            At Radio Awesome, you're feedback is always needed especially when it comes to music. We try our best to make sure that we are playing what you want to hear. By voting for your favorite single, you will help that artist get into the Weekly Top 20 countdown!\n          <\/div>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_0\">\n        <label class=\"form-label-left\" id=\"label_0\" for=\"input_0\">\n          First Name:<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_0\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox validate[required]\" id=\"input_0\" name=\"q0_firstName\" size=\"20\" maxlength=\"100\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_1\">\n        <label class=\"form-label-left\" id=\"label_1\" for=\"input_1\">\n          E-mail:<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_1\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox validate[required, Email]\" id=\"input_1\" name=\"q1_email\" size=\"20\" maxlength=\"150\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_19\">\n        <label class=\"form-label-left\" id=\"label_19\" for=\"input_19\">\n          Age:<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_19\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox validate[required]\" id=\"input_19\" name=\"q19_age\" size=\"20\" maxlength=\"100\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_2\">\n        <label class=\"form-label-left\" id=\"label_2\" for=\"input_2\">\n          City:<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_2\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox validate[required]\" id=\"input_2\" name=\"q2_city\" size=\"20\" maxlength=\"100\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_11\">\n        <label class=\"form-label-left\" id=\"label_11\" for=\"input_11\">\n          State<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_11\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox validate[required]\" id=\"input_11\" name=\"q11_state\" size=\"20\" maxlength=\"100\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_12\">\n        <label class=\"form-label-left\" id=\"label_12\" for=\"input_12\"> Country <\/label>\n        <div id=\"cid_12\" class=\"form-input\">\n          <input type=\"text\" class=\"form-textbox\" id=\"input_12\" name=\"q12_country\" size=\"20\" maxlength=\"100\" \/>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_13\">\n        <label class=\"form-label-left\" id=\"label_13\" for=\"input_13\">\n          Artist &amp; Single (A-E)<span class=\"form-required\">*<\/span>\n        <\/label>\n        <div id=\"cid_13\" class=\"form-input\">\n          <select class=\"form-dropdown validate[required]\" style=\"width:300px\" id=\"input_13\" name=\"q13_artistamp\">\n            <option>  <\/option>\n            <option value=\"22-20's - Latest Heartbreak\"> 22-20's - Latest Heartbreak <\/option>\n            <option value=\"A.A. Bondy - When the Devil's Loose\"> A.A. Bondy - When the Devil's Loose <\/option>\n            <option value=\"A Classic Education - What My Life Could Have Been\"> A Classic Education - What My Life Could Have Been <\/option>\n            <option value=\"A Place to Bury Strangers - Keep Slipping Away\"> A Place to Bury Strangers - Keep Slipping Away <\/option>\n            <option value=\"Acorn - No Ghost\"> Acorn - No Ghost <\/option>\n            <option value=\"Amely - On My Own\"> Amely - On My Own <\/option>\n            <option value=\"American Hi-Fi - Lost\"> American Hi-Fi - Lost <\/option>\n            <option value=\"Angus & Julia Stone - Big Jet Plane\"> Angus & Julia Stone - Big Jet Plane <\/option>\n            <option value=\"Antlers - Kettering\"> Antlers - Kettering <\/option>\n            <option value=\"Apparatjik - Antlers\"> Apparatjik - Antlers <\/option>\n            <option value=\"Apples in Stereo - Energy\"> Apples in Stereo - Energy <\/option>\n            <option value=\"Arcade Fire - The Suburbs\"> Arcade Fire - The Suburbs <\/option>\n            <option value=\"Aviation Orange - Radio\"> Aviation Orange - Radio <\/option>\n            <option value=\"Bad Books - You Wouldn't Have to Ask\"> Bad Books - You Wouldn't Have to Ask <\/option>\n            <option value=\"Bad Veins - Go Home\"> Bad Veins - Go Home <\/option>\n            <option value=\"Band of Horses - Factory\"> Band of Horses - Factory <\/option>\n            <option value=\"Band of Skulls - Light of the Morning\"> Band of Skulls - Light of the Morning <\/option>\n            <option value=\"Bavarian Druglords - Leaf\"> Bavarian Druglords - Leaf <\/option>\n            <option value=\"Bay State - Liars\"> Bay State - Liars <\/option>\n            <option value=\"Beach House - Norway\"> Beach House - Norway <\/option>\n            <option value=\"Bear Hands - Can't Stick Em\"> Bear Hands - Can't Stick Em <\/option>\n            <option value=\"Bear in Heaven - Wholehearted Mess\"> Bear in Heaven - Wholehearted Mess <\/option>\n            <option value=\"Bell - Dialtone\"> Bell - Dialtone <\/option>\n            <option value=\"Best Coast - When I'm With You\"> Best Coast - When I'm With You <\/option>\n            <option value=\"Beth Burden Band - Another Day\"> Beth Burden Band - Another Day <\/option>\n            <option value=\"Between the Trees - We Can Try\"> Between the Trees - We Can Try <\/option>\n            <option value=\"Biffy Clyro - God & Satan\"> Biffy Clyro - God & Satan <\/option>\n            <option value=\"Big Scary - Hey Somebody\"> Big Scary - Hey Somebody <\/option>\n            <option value=\"Black Angels - Bad Vibrations\"> Black Angels - Bad Vibrations <\/option>\n            <option value=\"Black Atlantic - Fragile Meadow\"> Black Atlantic - Fragile Meadow <\/option>\n            <option value=\"Black Keys - Next Girl\"> Black Keys - Next Girl <\/option>\n            <option value=\"Black Mountain - The Hair Song\"> Black Mountain - The Hair Song <\/option>\n            <option value=\"Black Pacific - Living with Ghosts\"> Black Pacific - Living with Ghosts <\/option>\n            <option value=\"Black Swan Green - The Lake\"> Black Swan Green - The Lake <\/option>\n            <option value=\"Black Taxi - Up Here for Thinking, Down There for Dancing\"> Black Taxi - Up Here for Thinking, Down There for Dancing <\/option>\n            <option value=\"Blind Pilot - 3 Rounds and a Sound\"> Blind Pilot - 3 Rounds and a Sound <\/option>\n            <option value=\"Blitzen Trapper - Heaven & Earth\"> Blitzen Trapper - Heaven & Earth <\/option>\n            <option value=\"Blue Giant - Clean the Clock\"> Blue Giant - Clean the Clock <\/option>\n            <option value=\"Blue Roses - Doubtful Comforts\"> Blue Roses - Doubtful Comforts <\/option>\n            <option value=\"Bobby Long - The Bount of Mary Jane\"> Bobby Long - The Bount of Mary Jane <\/option>\n            <option value=\"Bodega Girls - Primetime Sex Crime\"> Bodega Girls - Primetime Sex Crime <\/option>\n            <option value=\"Bonobo - Eyesdown ft. Andreya Triana\"> Bonobo - Eyesdown ft. Andreya Triana <\/option>\n            <option value=\"Born Ruffians - What to Say\"> Born Ruffians - What to Say <\/option>\n            <option value=\"Boy & Bear - Mexican Mavis\"> Boy & Bear - Mexican Mavis <\/option>\n            <option value=\"Boys Will Be Boys - Make This Acoustic\"> Boys Will Be Boys - Make This Acoustic <\/option>\n            <option value=\"Brick + Mortar - I Told You (Not to Let Go)\"> Brick + Mortar - I Told You (Not to Let Go) <\/option>\n            <option value=\"Broken Bells - The High Road\"> Broken Bells - The High Road <\/option>\n            <option value=\"Broken Social Scene - All to All\"> Broken Social Scene - All to All <\/option>\n            <option value=\"Cake - Sick of You\"> Cake - Sick of You <\/option>\n            <option value=\"Cary Brothers - Belong\"> Cary Brothers - Belong <\/option>\n            <option value=\"Cee Lo Green - Forget You\"> Cee Lo Green - Forget You <\/option>\n            <option value=\"Chief - Night & Day\"> Chief - Night & Day <\/option>\n            <option value=\"Christina Perri - Jar of Hearts\"> Christina Perri - Jar of Hearts <\/option>\n            <option value=\"Cinematic Orchestra - To Build a Home\"> Cinematic Orchestra - To Build a Home <\/option>\n            <option value=\"City and Colour - Comin Home\"> City and Colour - Comin Home <\/option>\n            <option value=\"Civil Twilight - Letters From the Sky\"> Civil Twilight - Letters From the Sky <\/option>\n            <option value=\"Civil Wars - Poison & Wine\"> Civil Wars - Poison & Wine <\/option>\n            <option value=\"Classic Crime - Cheap Shots\"> Classic Crime - Cheap Shots <\/option>\n            <option value=\"Cold War Kids - Audience\"> Cold War Kids - Audience <\/option>\n            <option value=\"Come On Come On - So Much Love\"> Come On Come On - So Much Love <\/option>\n            <option value=\"Conditions - Iluminati\"> Conditions - Iluminati <\/option>\n            <option value=\"Constellations - Felicia\"> Constellations - Felicia <\/option>\n            <option value=\"Corin Tucker Band - Riley\"> Corin Tucker Band - Riley <\/option>\n            <option value=\"Count Your Blessings - The Way You Move\"> Count Your Blessings - The Way You Move <\/option>\n            <option value=\"Crocodiles - Sleep Forever\"> Crocodiles - Sleep Forever <\/option>\n            <option value=\"Crystal Method - Drown in the Now ft. Matisyahu\"> Crystal Method - Drown in the Now ft. Matisyahu <\/option>\n            <option value=\"Cylew - Familiar\"> Cylew - Familiar <\/option>\n            <option value=\"Dale Earnhardt Jr. Jr. - Nothing But Our Love\"> Dale Earnhardt Jr. Jr. - Nothing But Our Love <\/option>\n            <option value=\"Dan Auerbach - Heartbroken, In Disrepair\"> Dan Auerbach - Heartbroken, In Disrepair <\/option>\n            <option value=\"Dark Dark Dark - Bright Bright Bright\"> Dark Dark Dark - Bright Bright Bright <\/option>\n            <option value=\"Darker My Love - Dear Author\"> Darker My Love - Dear Author <\/option>\n            <option value=\"Darwin Deez - Constellations\"> Darwin Deez - Constellations <\/option>\n            <option value=\"Dead Confederate - Giving It All Away\"> Dead Confederate - Giving It All Away <\/option>\n            <option value=\"Deer Tick - Twenty Miles\"> Deer Tick - Twenty Miles <\/option>\n            <option value=\"Delorean - Stay Close\"> Delorean - Stay Close <\/option>\n            <option value=\"Delphic - Halcyon\"> Delphic - Halcyon <\/option>\n            <option value=\"Delta Spirit - Bushwick Blues\"> Delta Spirit - Bushwick Blues <\/option>\n            <option value=\"Dev - Fireball\"> Dev - Fireball <\/option>\n            <option value=\"Dirty Flaggs - Stars and Segways\"> Dirty Flaggs - Stars and Segways <\/option>\n            <option value=\"Dirty Projectors - Ascending Melody\"> Dirty Projectors - Ascending Melody <\/option>\n            <option value=\"Disappears - Gone Completely\"> Disappears - Gone Completely <\/option>\n            <option value=\"Do - On My Shoulders\"> Do - On My Shoulders <\/option>\n            <option value=\"Dom - Living in America\"> Dom - Living in America <\/option>\n            <option value=\"Dominant Legs - Clawing Out at the Walls\"> Dominant Legs - Clawing Out at the Walls <\/option>\n            <option value=\"Downtown Fiction - Best I Never Had\"> Downtown Fiction - Best I Never Had <\/option>\n            <option value=\"Dr. Dog - Shadow People\"> Dr. Dog - Shadow People <\/option>\n            <option value=\"Drive-By Truckers - Birthday Boy\"> Drive-By Truckers - Birthday Boy <\/option>\n            <option value=\"Drones - The Minotaur\"> Drones - The Minotaur <\/option>\n            <option value=\"Drums - Forever and Ever Amen\"> Drums - Forever and Ever Amen <\/option>\n            <option value=\"Duke Spirit - The Step and The Walk\"> Duke Spirit - The Step and The Walk <\/option>\n            <option value=\"Dum Dum Girls - Bhang Bhang I'm a Burnout\"> Dum Dum Girls - Bhang Bhang I'm a Burnout <\/option>\n            <option value=\"Echo Helstrom - Paper Airplane\"> Echo Helstrom - Paper Airplane <\/option>\n            <option value=\"Edward Sharpe & The Magnetic Zeros - Home\"> Edward Sharpe & The Magnetic Zeros - Home <\/option>\n            <option value=\"Eels - Looking Up\"> Eels - Looking Up <\/option>\n            <option value=\"Elizaveta - Ordinary Life\"> Elizaveta - Ordinary Life <\/option>\n            <option value=\"Emarosa - A Toast to Future Kids!\"> Emarosa - A Toast to Future Kids! <\/option>\n          <\/select>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_7\">\n        <div id=\"cid_7\" class=\"form-input-wide\">\n          <div style=\"margin-left:156px\" class=\"form-buttons-wrapper\">\n            <button id=\"input_7\" type=\"submit\" class=\"form-submit-button\">\n              Submit\n            <\/button>\n          <\/div>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_14\">\n        <div id=\"cid_14\" class=\"form-input-wide\">\n          <div id=\"text_14\" class=\"form-html\">\n            The Artists\/Bands listed here are reflective of where they fall in the alphabet \"A-E\". If you wanted a different single, please return back to the \"Bands\" page and click the \"Vote Now\" button next to the song you wanted.\n          <\/div>\n        <\/div>\n      <\/li>\n      <li class=\"form-line\" id=\"id_18\">\n        <div id=\"cid_18\" class=\"form-input-wide\">\n          <div id=\"text_18\" class=\"form-html\">\n            You can only submit one vote per song, per 24 hour period.\n          <\/div>\n        <\/div>\n      <\/li>\n      <li style=\"display:none\">\n        Should be Empty:\n        <input type=\"text\" name=\"website\" value=\"\" \/>\n      <\/li>\n    <\/ul>\n  <\/div>\n  <input type=\"hidden\" id=\"simple_spc\" name=\"simple_spc\" value=\"93430103490\" \/>\n  <script type=\"text\/javascript\">\n  document.getElementById(\"si\" + \"mple\" + \"_spc\").value = \"93430103490-93430103490\";\n  <\/script>\n<\/form><\/body>\n<\/html>\n");

