//var showname;
//
//function QSObject(querystring){ 
//    //Create regular expression object to retrieve the qs part 
//    var qsReg = new RegExp("[?][^#]*","i"); 
//    hRef = unescape(querystring); 
//    var qsMatch = hRef.match(qsReg); 
// 
//    //removes the question mark from the url 
//    qsMatch = new String(qsMatch); 
//    qsMatch = qsMatch.substr(1, qsMatch.length -1); 
//
//    //split it up 
//    var rootArr = qsMatch.split("&"); 
//    for(i=0;i<rootArr.length;i++){ 
//        var tempArr = rootArr[i].split("="); 
//        if(tempArr.length ==2){ 
//            tempArr[0] = unescape(tempArr[0]); 
//            tempArr[1] = unescape(tempArr[1]); 
//            showname = tempArr[1];
//            this[tempArr[0]]= tempArr[1]; 
//        } 
//    } 
//} 
// 
//var scriptSrc = document.getElementById("darwidget").src;
//qs = new QSObject(scriptSrc); 
 
//document.write("obj1=" + showname + "<br />");
 
    (function() {

    // Localize jQuery variable
    var jQuery;

    /******** Load jQuery if not present *********/
    if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
        var script_tag = document.createElement('script');
        
        script_tag.setAttribute("type","text/javascript");
        script_tag.setAttribute("src",
            "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
        script_tag.onload = scriptLoadHandler;
        script_tag.onreadystatechange = function () { // Same thing but for IE
            if (this.readyState == 'complete' || this.readyState == 'loaded') {
                scriptLoadHandler();
            }
            
        };
        // Try to find the head, otherwise default to the documentElement
        (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
    } else {
        // The jQuery version on the window is the one we want to use
        jQuery = window.jQuery;
        main();
    }

    /******** Called once jQuery has loaded ******/
    function scriptLoadHandler() {
        // Restore $ and window.jQuery to their previous values and store the
        // new jQuery in our local jQuery variable
        jQuery = window.jQuery.noConflict(true);
        // Call our main function
        main(); 
    }

    /******** Our main function ********/
    function main() { 
        jQuery(document).ready(function($) {
            
        $('.record_but').live("click", function(){
           //alert("test");
            $(this).next().show("fast");
        });
        $('.widget_footer').live("click", function(){
           $(this).parent().hide("fast"); 
        });        
            /******* Load CSS *******/
            //var css_link = $("<link>", { 
            //    rel: "stylesheet", 
            //    type: "text/css", 
            //    href: "style.css" 
            //});
            //css_link.appendTo('head');          

            /******* Load HTML *******/
            
            var strVar="";
            strVar += "<form id=\"dar_widget_form\" action=\"http:\/\/www.dar.fm\/schedule_logic.php\" method=\"get\" target=\"widget\" onsubmit=\"window.open( 'http:\/\/www.dar.fm', 'widget', 'scrollbars=yes,width=375,height=100' ); return true;\" >";
            strVar += "    ";
            strVar += "    <input type=\"hidden\" name=\"show_title\" value=\"" + showname + "\" \/>";
            strVar += "    ";
            strVar += "    <div style=\"width:150px;\" class=\"record_form\">";
            strVar += "        <img src=\"http:\/\/dar.fm\/images\/widget_header.png\" class=\"record_but\" \/>";
            strVar += "        <div style=\"display:none;\">";
            strVar += "            <div style=\"margin:2px;font-size:12px;font-family:verdana,arial,helvetica,sans-serif;\">Please enter your email address to be notified when recording is completed.<\/div>              ";
            strVar += "            <input type=\"text\" name=\"user_email\" style=\"width:150px;margin-bottom:2px;border:1px solid #B6C6D4;\" \/>";
            strVar += "            <input type=\"hidden\" name=\"partner_token\" value=\"5994303431\" \/>";
            strVar += "            <input type=\"hidden\" name=\"format_id\" value=\"101\" \/>";
            strVar += "            <input type=\"image\" src=\"http:\/\/dar.fm\/images\/widget_footer.png\" class=\"widget_footer\"\/>";
            strVar += "        <\/div>";
            strVar += "    <\/div>     ";
            strVar += "    ";
            strVar += "<\/form> ";
            //var $div = $('<div id=\'dar-container\'></div>').appendTo("body").html(data);
            $("#dar_container").html(strVar); 
            
            var jsonp_url = "http://www.dar.fm/show_widget.php?showname=" + showname;
/*            $.get(jsonp_url, function(data) {
              $('#dar-container').html(data);
            })*/;
         
        });
    }

    })(); // We call our anonymous function immediately
    

 

