// JavaScript-Library
// Projekt: neckermann-reisen.de
// (c)2006 Denkwerk GmbH


//--------------------------------------------------------------------------------
// Öffnet Fenster (popup) mit freien Parametern
//--------------------------------------------------------------------------------

function openPopup(url, w, h, name, parameters) {
    if (name == null) {
        name = "_blank";
    }
    var features = 'width='+w+',height='+h;
    if (parameters == null) {
        features += ',scrollbars=yes,resizable=no,location=no,menubar=no,toolbar=no';
    } else {
        features += "," + parameters;
    }
    if (self.window.name != "popupOK" ) {
        self.window.name == "popupOK"
        thomascookwin = window.open(url, name, features);
        window.thomascookwin.focus();
    }
    else {
        if (window.thomascookwin.closed == true) {
            thomascookwin = window.open(url, name, features);
            window.thomascookwin.focus();
        } else {
            window.thomascookwin.location.href=url;
            window.thomascookwin.resizeTo(w,h);
            window.thomascookwin.focus();
        }
    }
}


function openWindow(inURL, inWidth, inHeight) {
	openPopup(inURL, inWidth, inHeight, 'pop');
}

function winOpen(inURL, inWidth, inHeight) {
	openPopup(inURL, inWidth, inHeight, 'pop');
}


var wstat
var ns4up = (document.layers) ? 1 : 0
var ie4up = (document.all) ? 1 : 0
var xsize = screen.width
var ysize = screen.height
var breite=955
var hoehe=ysize/1.5
var xpos=16
var ypos=16
function opwin(theURL) {
wstat=window.open(theURL,"","scrollbars=yes,status=yes,toolbar=no,location=no,directories=no,resizable=yes,menubar=no,width="+breite+",height="+hoehe+",screenX="+xpos+",screenY="+ypos+",top="+ypos+",left="+xpos)
}






var decrease = .9;
var intvl = 42;
var motion = false;


function setOff(dir) {
    if(!motion) {
        var speed = 40;
        setOffStep = function () {
            window.clearTimeout(motion);
            speed *= decrease;
            speed = Math.ceil(speed);
            myCurrentLeft = myNavContainer.offsetLeft;
            myCurrentLeft += menuLength;
            myCurrentLeft += (speed * dir);
            myCurrentLeft %= menuLength;
            myCurrentLeft -= menuLength;        
            myNavContainer.style.left = myCurrentLeft + 'px';
            if(myCurrentLeft % tripletWidth) {
                motion = window.setTimeout('setOffStep()', intvl);
            } else {
                window.clearTimeout(motion);
                motion = false;
                return;
            }
        }     
        setOffStep();
    }
}


function cloneMenu() {
   myNavContainer = document.getElementById('Spacer');
   var myMenuTables = myNavContainer.getElementsByTagName('Table');
   tripletWidth = myMenuTables[0].offsetWidth;
   var myMTLength = myMenuTables.length;
   menuLength = tripletWidth * myMTLength;
   for (i=0; i<(myMTLength*2) ; i++) {
       myClone = myMenuTables[i].cloneNode(true);
       myNavContainer.appendChild(myClone);
   }
   offsetIndex = parseInt((document.offset.offsetIndex.value-1)/3);
   myNavContainer.style.left = -tripletWidth * offsetIndex + 'px';
   myNavContainer.style.visibility = 'visible';
} 

//--------------------------------------------------------------------------------
// Hotelsuche
//--------------------------------------------------------------------------------

function clearDefaultValue(obj) {
    with(obj) if(value == defaultValue) value = '';
}

function restoreDefaultValue(obj) {
    with(obj) if(value == '') value = defaultValue;
}

function preventDefaultValueSubmit (obj) {
    with(obj) {
        for(i=0; i<elements.length; i++) {
            with(elements[i]) if(value == defaultValue && type=="text") value = "";
        }
    }
}
