﻿(function($) {
    $.ttCache = function(xmlurl) {
        var jsfiles = [];
        if (typeof (xmlurl) == 'string') { // manifest
            $.ajax({ url: xmlurl, async: true, cache: true
                , dataType: ($.browser.msie) ? 'text' : 'xml', error: function(req, status, error) {
                    //do nothing with the error                                
                }, success: function(data) {
                    var xml;
                    if (typeof data == 'string') {
                        xml = new ActiveXObject('Microsoft.XMLDOM');
                        xml.async = false;
                        xml.loadXML(data);
                    } else {
                        xml = data;
                    }                 
                    $('manifest > files > file', xml).each(function() {
                        var file = {};
                        $(this).children().each(function() {
                            var v = $(this);
                            var val = v.text();
                            file[this.nodeName] = val;
                        });
                        if(file.format=='image')
                        {
                            var image = new Image();
                            image.src = file.url;
                        }
                    });
                    AppendIframe();
                }
            });                                
        }      
    }
})(jQuery);
function AppendIframe() {
    if($('iframe#jsframe').length > 0)
    {
        return false;
    } 
    var jsframe = $(document.createElement('iframe'));
    jsframe.attr('src', '/Dependencies/JsFrame');
    jsframe.attr('id', 'jsframe');
    jsframe.attr('width', '0px');
    jsframe.attr('height', '0px');
    jsframe.attr('height', '0px');
    jsframe.attr('frameborder', '0');
    jsframe.attr('scrolling', 'no');
    jsframe.attr('style', 'display:none;width:0px;height:0px;visibility:none;');
    $(document.body).append(jsframe)
   
    /*
    $('iframe#jsframe').load(function() 
    {
        var $head = $("#jsframe").contents().find("head");
        alert('iframserc:' + $head.html());
    });
    */
}

/*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         // (function($) {
$(document).ready(function() {
    $.ttCache('/manifest.xml');
});
*/
//trying new stuff
try
{
    window.onload=function()
    {
        $.ttCache('/manifest.xml');
    }
}
catch(err)
{
  //well this should ensure that the browser doesnt panics
}