var IAmBusy = 0; var AjaxBusy = 0; var GettingMenu = 0; var OSMLv1; var OSMLv2; var bildAlpha = 0; var hash = document.location.hash; function printWindow(pageid, lid) { window.open('/print.asp?id='+pageid+"&lid="+lid,'Print','width=800,height=680,scrollbars=yes,location=no,toolbar=no,directories=no,status=no,menubar=no'); //alert("PID: " + pageid + ", LID: " + lid); } function checkHash() { if(hash && hash.substr(0,8) == '#params:'){ hash = hash.substr(8, hash.length-8); if (getElementFromUserContext(hash, 'id')){ if (getElementFromUserContext(hash, 'lid')){ if(!(getElementFromUserContext(hash, 'lid') == 0)){ if (getElementFromUserContext(hash, 'id') == 0){ moveOnSite(0, getElementFromUserContext(hash, 'lid'), 1); } else { moveOnSite(getElementFromUserContext(hash, 'id'), getElementFromUserContext(hash, 'lid'), 1); } } else { moveOnSite(getElementFromUserContext(hash, 'id'), 0, 1); } } else { moveOnSite(getElementFromUserContext(hash, 'id'), 0, 1); } } } else { //moveOnSite(getElementFromUserContext('id=10&lid=0', 'id'), 0, 1); //_id('container').style.background = 'none'; } } function getElementFromUserContext(userContext, element){ var stringArr = userContext.split('&'); for(var i = 0; i < stringArr.length; i++){ var keyValue = stringArr[i].split('='); if(keyValue[0].toLowerCase() == element.toLowerCase()) return keyValue[1]; } return ""; } window.onload = theStart; function theStart(){ checkHash(); resize(); setTimeout(function(){showIndexPics(_id('index_bild1'), 0)},40); } function Left(str, n){ if (n <= 0){ return ""; } else if (n > String(str).length){ return str; } else{ return String(str).substring(0,n); } } function ajaxResponse(e){ if(AjaxRequest.responseXML.getElementsByTagName(e)[0].childNodes[0]){ return AjaxRequest.responseXML.getElementsByTagName(e)[0].childNodes[0].nodeValue; } else { return false; } } function resize(w, e){ e = document.documentElement.clientWidth; if(e >= 1024){ w = e - 2; } else{ w = 1024; } _id('container').style.width = w+'px'; setTimeout(resize, 500); } function showIndexPics(p, a){ if(a >= 100){ SetOpacity(p, 100); } else{ a = a + 4; SetOpacity(p, a); if(p.id == 'index_bild1'){ if(a == 40){ showIndexPics(_id('index_bild2'), 0) } if(a == 80){ showIndexPics(_id('index_bild3'), 0) } if(a == 100){ showIndexPics(_id('index_bild4'), 0) } if (a == 100){ showIndexPics(_id('index_news_container'), 0) } } setTimeout(function(){showIndexPics(p, a)},60); } } function mm1Mouseover(e){if(e.offsetHeight == 0){ mm1Mouseover_2(e); }} function mm1Mouseover_2(e, a){ if(e.offsetHeight >= 4){a = 5;} else{a = e.offsetHeight + 1; setTimeout(function(){mm1Mouseover_2(e)},40);} e.style.height = a+'px'; } function mm1Mouseout(e){ if(!(e.offsetHeight == 0)){ if(e.offsetHeight == 5){ mm1Mouseout_2(e); } else{ setTimeout(function(){mm1Mouseout(e)},40); } } } function mm1Mouseout_2(e, a){ if(e.offsetHeight <= 1){ a = 0; } else { a = e.offsetHeight - 1; setTimeout(function(){mm1Mouseout_2(e)},40); } e.style.height = a+'px'; } function SMClick(e, lv){ if(IAmBusy == 0){ if(lv == 1){ClickLv1(e);} if(lv == 2){ClickLv2(e);} if(lv == 3){ClickLv3(e);} if(lv == 5){ClickLvP(e);} if(lv == 6){ClickLvP2(e);} if(lv == 9){ClickLvP3(e);} } } function ClickLv1(e){ e.style.background = '#61c325 url(/bilder/design/menu/arrow_1.gif) no-repeat'; e.style.color = '#ffffff'; if(OSMLv1){ if(!(OSMLv1 == e)){ IAmBusy = 1; closeMenu(OSMLv1, 0); OSMLv1.style.background = '#ffffff url(/bilder/design/menu/arrow_0.gif) no-repeat'; OSMLv1.style.color = '#808080'; openMenu(e); OSMLv1 = e; } else { closeMenu(OSMLv2, 0, _id('' + Left(e.id, 4) + '')); openMenu(e); } } else { IAmBusy = 1; openMenu(e); OSMLv1 = e; } if(OSMLv2){ SetOpacity(OSMLv2,70); closeMenu(OSMLv2, 0); OSMLv2 = false; } } function ClickLv2(e){ IAmBusy = 1; if(OSMLv2){ if(!(OSMLv2 == e)){ closeMenu(OSMLv2, 0, _id('' + Left(e.id, 4) + '')); SetOpacity(OSMLv2,70); openMenu(e, _id('' + Left(e.id, 4) + '')); SetOpacity(e,100); OSMLv2 = e; } else{ openMenu(e, _id('' + Left(e.id, 4) + '')); SetOpacity(e,100); IAmBusy = 0; } } else{ openMenu(e, _id(Left(e.id, 4))); SetOpacity(e,100); OSMLv2 = e; } } function ClickLv3(e){moveOnSite(e.id, 0, 0);} function ClickLvP(e){moveOnSite(0, e.id, 0);} function ClickLvP2(e){moveOnSite(0, e.id, 0);} function ClickLvP3(e){ if(OSMLv2){ if(!(OSMLv2 == e)){ SetOpacity(OSMLv2,70); moveOnSite(0, e.id, 0); SetOpacity(e,100); OSMLv2 = e; } else{ moveOnSite(0, e.id, 0); SetOpacity(e,100); } } else{ moveOnSite(0, e.id, 0); SetOpacity(e,100); OSMLv2 = e; } } function openMenu(e, e2){ if(_id('c' + e.id).offsetHeight >= _id('ic' + e.id).offsetHeight){ _id('c' + e.id).style.height = _id('ic' + e.id).offsetHeight + 'px'; if(e2){ _id('c' + e2.id).style.height = _id('ic' + e2.id).offsetHeight +'px'; } IAmBusy = 0; moveOnSite(e.id, 0, 0); } else{ _id('c' + e.id).style.height = (_id('c' + e.id).offsetHeight + 10) + 'px'; if(e2){ _id('c' + e2.id).style.height = (_id('c' + e2.id).offsetHeight + 10) + 'px'; } setTimeout(function(){openMenu(e, e2)},40); } } function closeMenu(e, h, e2){ if(_id('c' + e.id)) { if(_id('c' + e.id).offsetHeight <= (h + 10)){ _id('c' + e.id).style.height = h + 'px'; if(e2){ _id('c' + e2.id).style.height = _id('ic' + e2.id).offsetHeight +'px'; } IAmBusy = 0; } else{ _id('c' + e.id).style.height = (_id('c' + e.id).offsetHeight - 10) + 'px'; if(e2){ _id('c' + e2.id).style.height = (_id('c' + e2.id).offsetHeight - 10) + 'px'; } setTimeout(function(){closeMenu(e, h, e2)},40); } } } function innerContentPosition(id, lid, p){ _id('innerContent').innerHTML = ''; _showId('innerContent'); if(p == 1){ innerContentPosition1(id, lid); } if(p == 2){ innerContentPosition2(id, lid); } if(p == 3){ innerContentPosition3(id, lid); } if(p == 5){ innerContentPosition5(id, lid); } } function innerContentPosition1(id, lid){ b2 = _id('innerContent'); b3 = _id('subMenuContainer'); a2 = b2.offsetWidth; a3 = b3.offsetLeft; if(a2 <= 500 && a3 >= 300 && bildAlpha <= 0){ SetOpacity(_id('bildBox'), 0); b2.style.width = '500px'; b3.style.left = '300px'; setTimeout(function(){getPageContent(id, lid)},40); } else{ i = 30; if(!(bildAlpha <= 0)){ bildAlpha-=10; SetOpacity(_id('bildBox'), bildAlpha); } if(!(a2 <= 500)){ b2.style.width = (a2 - i) + 'px'; } if(!(a3 >= 300)){ b3.style.left = (a3 + i) + 'px'; } setTimeout(function(){innerContentPosition1(id, lid)},40); } } function innerContentPosition2(id, lid){ b2 = _id('innerContent'); b3 = _id('subMenuContainer'); a2 = b2.offsetWidth; a3 = b3.offsetLeft; if(a2 >= 750 && a3 <= 63 && bildAlpha <= 0){ SetOpacity(_id('bildBox'), 0); b2.style.width = '750px'; b3.style.left = '63px'; setTimeout(function(){getPageContent(id, lid)},40); } else{ i = 30; if(!(bildAlpha <= 0)){ bildAlpha-=10; SetOpacity(_id('bildBox'), bildAlpha); } if(!(a2 >= 750)){ b2.style.width = (a2 + i) + 'px'; } if(!(a3 <= 63)){ b3.style.left = (a3 - i) + 'px'; } setTimeout(function(){innerContentPosition2(id, lid)},40); } } function innerContentPosition3(id, lid){ b2 = _id('innerContent'); b3 = _id('subMenuContainer'); a2 = b2.offsetWidth; a3 = b3.offsetLeft; if(a2 <= 500 && a3 >= 300 && bildAlpha >= 100){ SetOpacity(_id('bildBox'), 100); b2.style.width = '500px'; b3.style.left = '300px'; setTimeout(function(){getPageContent(id, lid)},40); } else{ i = 30; if(!(bildAlpha >= 100)){ bildAlpha+=10; SetOpacity(_id('bildBox'), bildAlpha); } if(!(a2 <= 500)){ b2.style.width = (a2 - i) + 'px'; } if(!(a3 >= 300)){ b3.style.left = (a3 + i) + 'px'; } setTimeout(function(){innerContentPosition3(id, lid)},40); } } function innerContentPosition5(id, lid){ _id('innerContent').style.display = 'none'; if(bildAlpha <= 0){ _showId('innerContentFlash'); SetOpacity(_id('bildBox'), 0); var fo = new SWFObject("/flash/inspiration.swf", "flash_inspiration", "1024", "700", "8.0.15", "#ffffff", true); fo.addParam("allowScriptAccess", "always"); fo.addParam("menu", "false"); fo.addParam("wmode", "transparent"); fo.addParam("quality", "high"); fo.addParam("swliveconnect", "true"); fo.write("innerContentFlash"); AjaxBusy = 0; IAmBusy = 0; } else{ i = 30; if(!(bildAlpha <= 0)){ bildAlpha-=10; SetOpacity(_id('bildBox'), bildAlpha); } setTimeout(function(){innerContentPosition5(id, lid)},40); } } function getSubMenu(id, lid){ if(AjaxBusy == 0){ AjaxBusy = 1; if(id == 0) { id = 20; } _id('subMenuContainer').innerHTML = ''; var url = '/ajax/getSubMenu.asp?id='+id+'&lid='+lid+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){getSubMenu_w(id, lid)}; AjaxRequest.send(null); } else { setTimeout(function(){getSubMenu(id, lid)},100); } } function getSubMenu_w(id, lid){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('subMenuContainer').innerHTML = AjaxRequest.responseText; OSMLv1 = null; OSMLv2 = null; AjaxBusy = 0; GettingMenu = 0; if(id.length == 4){ setTimeout(function(){ SMClick(_id(id), '1') },100); } } } function moveOnSite(id, lid, m){ if(IAmBusy == 0){ IAmBusy = 1; checkPageContent(id, lid, m); } } function checkPageContent(id, lid, m){ if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/checkPageContent.asp?id='+id+'&lid='+lid+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){checkPageContent_w(id, lid, m)}; AjaxRequest.send(null); } else{ setTimeout(function(){checkPageContent(id, lid, m)},100); } } function changeBG(bg){ var img = new Image(); img.onload = function(){ _id('container').style.background = 'url(' + img.src + ') no-repeat bottom center'; }; img.src = bg; } function checkPageContent_w(id, lid, m){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ document.location.hash = 'params:id=' + id + '&lid=' + lid; _hideId('innerContentFlash'); _showId('innerContent'); _hideId('drHairFormContent'); _hideId('theIndex'); document.title = '' + ajaxResponse('RUBRIK') + ''; if(Left(id,2) == 15) { mm_mark(1); if(Left(id,4) == 1510) { mm_mark(5); } } if(Left(id,2) == 20) { mm_mark(2); } if(Left(id,2) == 25) { mm_mark(3); } if(Left(id,2) == 60) { mm_mark(4); } if(!(ajaxResponse('BG') == false)){ changeBG(ajaxResponse('BG'), 100); } AjaxBusy = 0; if(ajaxResponse('URL') == '/index.asp'){ _hideId('innerContent'); } if(ajaxResponse('URL') == '/inspiration.asp'){ innerContentPosition(id, lid, 5); } if(ajaxResponse('URL') == '/info.asp' || ajaxResponse('URL') == '/sitemap2.asp' || ajaxResponse('URL') == '/bildbank.asp' || ajaxResponse('URL') == '/404.asp' || ajaxResponse('URL') == '/press.asp' || ajaxResponse('URL') == '/kontakt.asp'){ innerContentPosition(id, lid, 1); } if(ajaxResponse('URL') == '/hair.asp'){ _showId('drHairFormContent'); innerContentPosition(id, lid, 1); } if(ajaxResponse('URL') == '/info2.asp' || ajaxResponse('URL') == '/salonger.asp' || ajaxResponse('URL') == '/ajax/sok.asp' || ajaxResponse('URL') == '/nyheter.asp' || ajaxResponse('URL') == '/prodkat2.asp' || ajaxResponse('URL') == '/prodkat3.asp' || ajaxResponse('URL') == '/prod.asp'){ innerContentPosition(id, lid, 2); } if(ajaxResponse('URL') == '/prodkat.asp'){ IAmBusy = 0; } if(ajaxResponse('URL') == '/info3.asp'){ _id('bildBox').style.background = '#ffffff url(' + ajaxResponse('BILD') + ') center center no-repeat'; innerContentPosition(id, lid, 3); } if(m == 1){ GettingMenu = 1; setTimeout(function(){getSubMenu(id, lid)},100); } if(lid.length > 1) { googleLink = ajaxResponse('REALURL') + "__.html/lid/"+lid+"/" } else { googleLink = ajaxResponse('REALURL') + "__.html" } pageTracker._trackPageview(googleLink); } } function getPageContent(id, lid){ if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/getPageContent.asp?id='+id+'&lid='+lid+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){getPageContent_w(id, lid)}; AjaxRequest.send(null); } else { setTimeout(function(){getPageContent(id, lid)},100); } } function getPageContent_w(id, lid){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('innerContent').innerHTML = AjaxRequest.responseText; AjaxBusy = 0; if(id == 9010){ makeSearch(); } endOfTheLine(); } } function makeSearch(){ if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/sok.asp?sokvarde='+escape(_id('sokvarde').value)+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){makeSearch_w()}; AjaxRequest.send(null); } else { setTimeout(function(){makeSearch()},100); } } function makeSearch_w(){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('innerContent').innerHTML = AjaxRequest.responseText; AjaxBusy = 0; } } function endOfTheLine(){ if(GettingMenu == 0){ IAmBusy = 0; } else{ setTimeout(function(){endOfTheLine()},100); } } function getFragor(k){ _hideId('drhairtext'); _id('drhairkat1').style.color = '#6d6f73'; _id('drhairkat2').style.color = '#6d6f73'; _id('drhairkat3').style.color = '#6d6f73'; _id('drhairkat4').style.color = '#6d6f73'; _id('drhairkat' + k).style.color = '#42a705'; if(k == 1){ _id('drhairkat').innerHTML = 'Frågor och svar om färgning'; } else if(k == 2){ _id('drhairkat').innerHTML = 'Frågor och svar om frisyrer'; } else if(k == 3){ _id('drhairkat').innerHTML = 'Frågor och svar om produkter'; } else if(k == 4){ _id('drhairkat').innerHTML = 'Övriga frågor och svar'; } if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/getFragor.asp?kat='+k+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){getFragor_w()}; AjaxRequest.send(null); } } function getFragor_w(){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('drhaircontent').innerHTML = AjaxRequest.responseText; AjaxBusy = 0; } } function getForsaljare(k){ if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/getForsaljare.asp?sok='+k+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){getForsaljare_w()}; AjaxRequest.send(null); } } function getForsaljare_w(){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('forsaljareContent').innerHTML = AjaxRequest.responseText; AjaxBusy = 0; } } function sendFraga(n, e, f, error){ error = 0; if(e.length == 0) { error = 1; } if(n.length == 0) { error = 1; } if(f.length == 0) { error = 1; } if(error == 1) { alert('Du har inte fyllt i alla fält!'); } else { if(AjaxBusy == 0){ AjaxBusy = 1; var url = '/ajax/sendFraga.asp?namn='+escape(n)+'&epost='+escape(e)+'&fraga='+escape(f)+'&rand='+parseInt(Math.random()*999999999999999);+''; AjaxRequest.open("GET", url, true); AjaxRequest.onreadystatechange = function(){sendFraga_w()}; AjaxRequest.send(null); } } } function sendFraga_w(){ if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){ _id('drForm').innerHTML = ''; _id('drText').innerHTML = 'Tack för din fråga, Dr Hair återkommer med ett svar så snart som möjligt.'; AjaxBusy = 0; } } function mm_mark(m){ _id('mm1').src = '/bilder/design/menu/omgrazette_1053.gif'; _id('mm2').src = '/bilder/design/menu/produkter_1053.gif'; _id('mm3').src = '/bilder/design/menu/salonger_1053.gif'; _id('mm4').src = '/bilder/design/menu/nyheterpress_1053.gif'; _id('mm5').src = '/bilder/design/menu/kontakt_1053.gif'; _id('mm' + m).src = _id('mm' + m).src.replace('.gif','_2.gif'); }