define(function (){ if (typeof window == 'undefined') return { load: function (n, r, load){ load(); } } ; var head = _AN_Call_getelementsbytagname('getElementsByTagName', document, 'head')[0]; var engine = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/) || 0; var useImportLoad = false ; var useOnload = true ; if (engine[1] || engine[7]) useImportLoad = parseInt(engine[1]) < 6 || parseInt(engine[7]) <= 9; else if (engine[2] || engine[8] || 'WebkitAppearance' in document.documentElement.style) useOnload = false ; else if (engine[4]) useImportLoad = parseInt(engine[4]) < 18; var cssAPI = { } ; cssAPI.pluginBuilder = './css-builder'; var curStyle, curSheet; var createStyle = function (){ curStyle = _AN_Call_createelement('createElement', document, 'style'); _AN_Call_appendchild('appendChild', head, curStyle); curSheet = curStyle.styleSheet || curStyle.sheet; } ; var ieCnt = 0; var ieLoads = [] ; var ieCurCallback; var createIeLoad = function (url){ curSheet.addImport(url); curStyle.onload = function (){ processIeLoad(); } ; ieCnt++ ; if (ieCnt == 31) { createStyle(); ieCnt = 0; } } ; var processIeLoad = function (){ ieCurCallback(); var nextLoad = ieLoads.shift(); if (!nextLoad) { ieCurCallback = null ; return ; } ieCurCallback = nextLoad[1]; createIeLoad(nextLoad[0]); } ; var importLoad = function (url, callback){ if (!curSheet || !curSheet.addImport) createStyle(); if (curSheet && curSheet.addImport) { if (ieCurCallback) { ieLoads.push([url, callback] ); } else { createIeLoad(url); ieCurCallback = callback; } } else { curStyle.textContent = '@import "' + url + '";'; var loadInterval = _AN_Call_setinterval('setInterval', window, function (){ try { curStyle.sheet.cssRules; clearInterval(loadInterval); callback(); } catch (e) { } } , 10); } } ; var linkLoad = function (url, callback){ var link = _AN_Call_createelement('createElement', document, 'link'); link.type = 'text/css'; link.rel = 'stylesheet'; if (useOnload) link.onload = function (){ link.onload = function (){ } ; _AN_Call_settimeout('setTimeout', window, callback, 7); } ; else var loadInterval = _AN_Call_setinterval('setInterval', window, function (){ for (var i = 0; i < _AN_Read_length('length', document.styleSheets); i++ ){ var sheet = document.styleSheets[i]; if (_AN_Read_href('href', sheet) == _AN_Read_href('href', link)) { clearInterval(loadInterval); return callback(); } } } , 10); _AN_Write_href('href', link, false , url); _AN_Call_appendchild('appendChild', head, link); } ; cssAPI.normalize = function (name, normalize){ if (name.substr(_AN_Read_length('length', name) - 4, 4) == '.css') name = name.substr(0, _AN_Read_length('length', name) - 4); return normalize(name); } ; cssAPI.load = function (cssId, req, load, config){ (useImportLoad? importLoad: linkLoad)(req.toUrl(cssId + '.css'), load); } ; return cssAPI; } );