function getHostnameLoder(str) {
	var re = new RegExp('^(?:f|ht)tp(?:s)?\://([^/]+)', 'im');
	return str.match(re)[1].toString();
}
var scripts = document.getElementsByTagName( "script" );
var lastScript = scripts[scripts.length - 1];
var rootUrlLoader="";
if(lastScript.src.indexOf("http:")==0)
{
	var hostnameLoader= getHostnameLoder(lastScript.src)
	if(hostnameLoader.length>0)
	{
		rootUrlLoader="http://"+hostnameLoader;
	}
}
var scriptsArray = [
    "library/jquery/i18n/jquery-ui-i18n.js",
    "library/jquery/jquery.ajaxmanager.js",
    "library/jquery/jquery.json.min.js",
    "library/jquery/jquery.autocomplete.js",
    "library/jquery/jquery.blockUI.js",
    "library/jquery/jquery.media.js",
    "library/jquery/jquery.contextmenu.js",
    "library/jquery/jquery.form.js",
    "library/jquery/jquery.cookie.min.js",
    "library/jquery/jquery.tooltip.pack.js",
    "library/jquery/jquery-asyncUpload-0.1.js",
    "library/jquery/jquery.jgrowl_min.js",
    "library/jquery/jquery.marquee.min.js",
    "library/jquery/jquery.validate.min.js",
    "library/jquery/jquery.scrollTo-min.js",
    "library/jquery/jquery.clock.js",
    "library/jquery/jquery.livequery.js",
    "library/jquery/jquery.rotate.1-1.js",
    "library/jquery/jquery.jeditable.js",
    "library/jquery/jquery.tweet.js",
    "library/jquery/jquery.cluetip.js",
    "library/jquery/easySlider.packed.js",
    "library/jquery/ajaxupload.js",
    "library/jquery/hovertip.js",
    "library/jquery/superfish.js",
    "library/jquery/ui.selectmenu.js",
    "library/jquery/jquery.tipsy.js",
    "library/uploadify/jquery.uploadify.v2.1.4.min.js",
    "fbconnect/scripts/script.js",
    "library/uploadify/swfobject.js",
    "library/jquery/jquery.jcarousel.min.js",
    "library/jquery/galleria-1.2.3.js",
    "css/themes/classic/galleria.classic.js"
];

function itaste_getScript(filename) {
    document.write("<script type='text/javascript' src='"+filename+"'></script>");
}

document.write("<script type='text/javascript' src='"+rootUrlLoader+"/library/jquery/jquery.js'></script>");

itaste_getScript(rootUrlLoader+"/library/jquery/jquery-ui-1.8.17.custom.min.js");
itaste_getScript(rootUrlLoader+"/library/nyromodal/jquery.nyroModal.min.js");

var scriptsLen = scriptsArray.length;
var scriptsTmp = [];
var maxScripts = 9;
var currentPacket = 0;
// Loading scripts by packs of 10
for (var i=0; i<scriptsLen; i++)
{
    scriptsTmp.push(scriptsArray[i]);

    // reset current packet and appending script
    if ((i%maxScripts == 0) || i==(scriptsLen-1)){
        itaste_getScript('/min/?f=' + scriptsTmp.join(','));
        //document.write("<script type='text/javascript' src='/min/?f=" + scriptsTmp.join(',') + "'></script>");
        scriptsTmp = [];
    }
}

var googleBaseCountryCode;
if (typeof iTasteLanguage == 'undefined')
    iTasteLanguage = 'fr';
switch (iTasteLanguage)
{
    case 'de':
        googleBaseCountryCode = 'de';
        break;
    case 'en':
        googleBaseCountryCode = 'co.uk';
        break;
    default:
        googleBaseCountryCode = 'fr';
        break;
}

itaste_getScript("http://maps.google." + googleBaseCountryCode + "/maps?file=api&v=2&key="+googleMapKey+"&hl=" + googleBaseCountryCode);
itaste_getScript(rootUrlLoader+'/scripts/iTasteLoaderCONCAT.js');
itaste_getScript(rootUrlLoader+'/scripts/iTasteLoader2.js');
itaste_getScript(rootUrlLoader+'/scripts/iTasteLoaderReady.js');
itaste_getScript(rootUrlLoader+'/library/wizard/wizard.js');
itaste_getScript('https://apis.google.com/js/plusone.js');

