var strDays = 31;
function startGallery(id){
AjaxRequest.open("GET", "/ajax/galleri.asp?id="+id+"", true);
AjaxRequest.onreadystatechange = function(){startGallery2()};
AjaxRequest.send(null);
}
function startGallery2(){
if(AjaxRequest.readyState==4 || AjaxRequest.readyState=='complete'){
_id('galleryContent').innerHTML = AjaxRequest.responseText;
LBsetLightbox();
//alert(AjaxRequest.responseText);
//_id('bannerleft').style.display = 'none';
_id('t_1').firstChild.style.display = 'none';
oldPic = _id('t_1').firstChild.id.replace('thumb_', '');
_id('galleryPicText_1').style.display = 'block';
oldMargin = 0;
oldPicCount = 1;
Cufon.refresh();
}
}
function LBsetLightbox() {
var h = 710;
var w = 849;
//var h = 667;
//var w = 806;
if(_id('Lightbox')) { _id('Lightbox').style.display = 'block'; }
else {
newE = document.createElement("div");
newE.id = 'Lightbox';
newE.style.position = 'absolute';
newE.style.top = '0px';
newE.style.left = '0px';
newE.style.height = '' + document.documentElement.scrollHeight + 'px';
newE.style.width = '100%';
newE.style.cursor = 'pointer';
newE.style.zIndex = '999';
newE.style.backgroundColor = '#000000';
newE.style.filter = 'alpha(opacity=70)';
newE.style.opacity = '.70';
document.body.insertBefore(newE, document.body.firstChild);
}
if(_id('LightboxContent')) {
e1 = _id('LightboxContent');
e1.style.display = 'block';
e1.style.top = '100px';
e1.style.left = '' + (((document.documentElement.offsetWidth / 2) - parseInt(w / 2)) - document.documentElement.scrollLeft) + 'px';
}
else { newA = document.createElement("div");
newA.id = 'LightboxContent';
newA.style.position = 'absolute';
newA.style.top = '50px';
newA.style.left = '' + (((document.documentElement.offsetWidth / 2) - parseInt(w / 2)) - document.documentElement.scrollLeft) + 'px';
newA.style.height = '' + h + 'px';
newA.style.width = '' + w + 'px';
newA.style.zIndex = '1001';
newA.style.background = 'url(/bilder/design/bg_gallery_lightbox.png)';
document.body.insertBefore(newA, document.body.firstChild);
}
_id('LightboxContent').innerHTML = _id('galleryContent').innerHTML;
if(navigator.appName == "Microsoft Internet Explorer") { _id('Lightbox').attachEvent('onclick', LBcloseLightbox); }
else { _id('Lightbox').addEventListener('click', LBcloseLightbox,false); }
}
function LBcloseLightbox() { _id('Lightbox').style.display = 'none'; _id('LightboxContent').style.display = 'none'; _id('LightboxContent').innerHTML = '';
if (document.getElementById('flashcontent')) { document.getElementById('flashcontent').style.visibility = 'visible'; }
}
var oldPic = '';
var oldMargin = 0;
var oldPicCount = 1;
function thumbClick(e, m){
_id('thumb_'+oldPic+'').style.display = 'block';
_id('pic_'+oldPic+'').style.zIndex = '99990';
_id('galleryPicText_'+_id('thumb_'+oldPic+'').parentNode.id.replace('t_', '')+'').style.display = 'none';
SetOpacity(_id(''+e.id.replace('thumb_', 'pic_')+''),100);
if(oldMargin <= m){moveMarginLeft(oldMargin, m, e);} else {moveMarginRight(oldMargin, m, e);}
_id('galleryPicText_'+e.parentNode.id.replace('t_', '')+'').style.display = 'block';
fadeOutPic(_id('pic_'+oldPic+''), 100);
oldPic = e.id.replace('thumb_', '');
oldMargin = m;
oldPicCount = e.parentNode.id.replace('t_', '');
}
function LBNext() {
if(_id('t_'+(parseInt(oldPicCount) + 1)+'')) {
thumbClick(_id('t_'+(parseInt(oldPicCount) + 1)+'').firstChild, (parseInt(oldPicCount) * 79));
}
}
function LBPrev() {
if(_id('t_'+(parseInt(oldPicCount) - 1)+'')) {
thumbClick(_id('t_'+(parseInt(oldPicCount) - 1)+'').firstChild, ((parseInt(oldPicCount) * 79) - 158));
}
}
function moveMarginLeft(m,m2,e2){var e = _id('galleryThumbMover');
if(m>=m2){e.style.marginLeft='-'+m2+'px';e2.style.display='none';}
else{e.style.marginLeft='-'+m+'px';m=m+79;setTimeout(function(){moveMarginLeft(m,m2,e2)},40);}
}
function moveMarginRight(m,m2,e2){var e = _id('galleryThumbMover');
if(m<=m2){e.style.marginLeft='-'+m2+'px';e2.style.display='none';}
else{e.style.marginLeft='-'+m+'px';m=m-79;setTimeout(function(){moveMarginRight(m,m2,e2)},40);}
}
function fadeOutPic(e,f){if(f<=0){SetOpacity(e,0);e.style.zIndex=1;}else{SetOpacity(e,f);f-=15;setTimeout(function(){fadeOutPic(e,f)},30);}}
function visaMoblering(e, imgurl) {
$("#mobleringval a").removeClass("active");
$(e).addClass("active");
$("#mobleringbild").attr("src", imgurl);
Cufon.refresh();
}
function Left(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
function Right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
function sendBokning() {
Datum = _id('BManad').value + '-' + _id('BDag').value;
if ((parseInt(_id('BDag').value) + parseInt(_id('BNatter').value) >= strDays)) {
overday = strDays - (parseInt(_id('BDag').value) + parseInt(_id('BNatter').value));
overday = Math.abs(overday);
if(parseInt(Right(_id('BManad').value, 2)) == 12) {
Datum2 = (parseInt(Left(_id('BManad').value, 4)) + 1) + '-01-' + overday;
}
else {
theMonth = (parseInt(Right(_id('BManad').value, 2)) + 1)
if(theMonth <= 9){theMonth = '0'+theMonth+''}
Datum2 = Left(_id('BManad').value, 4) + '-' + theMonth + '-' + overday;
}
//alert(overday);
}
else {
Datum2 = _id('BManad').value + '-' + (parseInt(_id('BDag').value) + parseInt(_id('BNatter').value));
}
Vuxna = _id('BVuxna').value;
var bokningstyp = $('input[name=BTyp]:checked').val();
if (bokningstyp == "p")
{
bokning_url = "http://www.hotellkristina.se/byosweb/redirfromsearchform.aspx?categoryID=D95D9879-80FD-42C0-AB40-16F62E4191DB&dateFrom=" + Datum + "&dateTo=" + Datum2 + "&numAdults=" + Vuxna
} else {
bokning_url = "http://motesbokning.hotellkristina.se/byosweb/redirfromsearchform.aspx?categoryID=856D2476-3618-4A44-A15D-64986700416D&dateFrom=" + Datum + "&dateTo=" + Datum2 + "&numAdults=" + Vuxna
}
window.location = bokning_url;
}
function getDays(strMonth,strYear) {
strYear = parseInt(Left(strMonth, 4));
strMonth = parseInt(Right(strMonth, 2));
//alert(strYear);
//alert(strMonth);
if(strMonth == 1 || strMonth == 3 || strMonth == 5 || strMonth == 7 || strMonth == 8 || strMonth == 10 || strMonth == 12) {
strDays = 31;
_showId('BDay29');
_showId('BDay30');
_showId('BDay31');
}
if(strMonth == 4 || strMonth == 6 || strMonth == 9 || strMonth == 11) {
strDays = 30;
_showId('BDay29');
_showId('BDay30');
_hideId('BDay31');
}
if(strMonth == 2) {
if((parseInt(strYear) % 4 == 0 && !(parseInt(strYear) % 100 == 0)) || (parseInt(strYear) % 400 == 0)) {
strDays = 29;
_showId('BDay29');
_hideId('BDay30');
_hideId('BDay31');
}
else {
strDays = 28;
_hideId('BDay29');
_hideId('BDay30');
_hideId('BDay31');
}
}
}
function typeChanged() {
$('#BVuxna').empty();
$('#BNatter').empty();
var bokningstyp = $('input[name=BTyp]:checked').val();
if (bokningstyp == "p")
{
var minantal = 1;
var maxantal = 2;
var natter = 4;
} else {
var minantal = 6;
var maxantal = 80;
var natter = 3;
}
var i;
for (i=minantal;i<=maxantal;i++) {
$('#BVuxna').append("");
}
for (i=1;i<=natter;i++) {
$('#BNatter').append("");
}
}