function loadBranding(branding)
{
    var brandingUrl = 'http://astromax.eva.ro/miscellaneous/branding.php';

    var ajaxRequest = new Ajax.Request(
        brandingUrl, {
            method: 'post',
            parameters: 'id='+branding+'&referer='+encodeURIComponent(top.location),
            evalScripts: true,
            stripScripts: false,
        onComplete: function(response){
        
            res= response.responseText;
        
            try  {
                var resObj = res.evalJSON();
            } catch(e) {}

            if (typeof(resObj) != 'object') {
                return false;
            }

	    var pageStyles = $$('link[rel=stylesheet]');
            var bstyle = new Element('link');
            bstyle.rel = 'stylesheet';
            bstyle.href = resObj.css_file;
            
            pageStyles[pageStyles.length-1].insert({after:bstyle});
            
            if (resObj.script_file) {
            
        	var script_head = document.createElement('script');
        	script_head.type = "text/javascript";
        	script_head.src = resObj.script_file;
        	document.getElementsByTagName('head')[0].appendChild(script_head);
            }
                                                            
            try {
    		$('header_v2').insert({before:resObj.html});
    	    } catch(e){}

       }});
}



