
function launchwin( winUrl, winName, winFeatures ) {
    newWin = window.open( winUrl, winName, winFeatures+',scrollbars=yes,resizable=yes' );
}


function partiallySubmitOrderForm() {
    document.orderShipmentForm.partialSubmission.value = "true";
    document.orderShipmentForm.submit();
}

function partiallySubmitOrderPickupForm() {
    document.orderPickupForm.partialSubmission.value = "true";
    document.orderPickupForm.submit();
}

function partiallySubmitQuickBuyForm() {
    document.quickBuyForm.partialSubmission.value = "true";
    document.quickBuyForm.submit();
}

function confirmLoad( theUrl ) {
    if( confirm( 'Sind Sie sicher?' ) ) {
        location.href = theUrl;
    }
}

function openNewsletter(url) {
	var name = "newsletter";
	var features = "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=660,height=720,top=60,left=100";
	newwin = window.open(url,name,features);
}

function toggleExplanation( obj ) {
    x = document.getElementById( obj );
    if( x.style.display != 'none' ) {
        x.style.display = 'none';
    } else {
        x.style.display='block';
    }
}

function addSearch( urlNr, affiliateName ) {
    if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addSearchEngine == 'function')) {
        window.sidebar.addSearchEngine(
            'http://images.libri.de/shop/logos/mozsearch/' + urlNr + '.src',
            'http://images.libri.de/shop/logos/mozsearch/' + urlNr + '.png',
            affiliateName,
            'Bücher'
            /*'http://www.libri.de/shop/action/shop/addmozsearch/?urlnr='+urlNr,
            'http://images.libri.de/shop/searchengine/'+urlNr+'.png',
            'Libri.de',
            'Bücher'*/
        );
    } else {
        alert('Mozilla M15 or later is required to add a search engine.');
    }
}

function isMoz() {
    if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addSearchEngine == 'function')) {
        return true;
    }
    return false;
}

function openWindowCenter( url, name, width, height ) {
    var winX = (screen.width - width) / 2;
    var winY = (screen.height - height) / 2;
    windowProperties = 'width=' + width + ',height=' + height + ',left=' + winX + ',top=' + winY + ',scrollbars=no,resizable';
    newwin = window.open( url, name, windowProperties );
}

function OpenPopUp(breite,hoehe,Ziel) {
    OpenPopUpName(breite,hoehe,'PopUp',Ziel)
}

function OpenPopUpName(breite,hoehe,pop_name,Ziel) {
    OpenPopUpNamePara(breite,hoehe,pop_name,'',Ziel);
}

function OpenPopUpNamePara(breite,hoehe,pop_name,para,Ziel) {
    var fc_js_pos = getCenterPosition(breite,hoehe);
    
    var options ="width="+breite+",height="+hoehe+",toolbar=no,locationbar=no,directories=no,scrollbars=auto,status=no,menubar=no,resizable=no"+fc_js_pos;
    if (para == 'scroll') {
        options ="width="+breite+",height="+hoehe+",toolbar=no,locationbar=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=no"+fc_js_pos;
    }
    if (para == 'noscroll') {
        options ="width="+breite+",height="+hoehe+",toolbar=no,locationbar=no,directories=no,scrollbars=no,status=no,menubar=no,resizable=no"+fc_js_pos;
    }

    if (pop_name == ''){
        pop_name = 'Popup';
    }
    
    
    var newwindow = open(Ziel,pop_name,options);
    if (newwindow != null){
        newwindow.focus();
    }
}

function winOpenKalender() {
    window.open("http://www.adventskalender.mediastyle.de/user2007/books-ch/advent/adventskalender.asp","","width=700,height=600,top=20,left=20,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,toolbar=no");
}

function showElement( divid ) {
	var element = document.getElementById( divid );
	
	if ( element && element.style.display == 'none' ) {
		element.style.display = 'block';
	}
}

function setRating( value ) {
    var rating = document.getElementById( 'rating' );

    if ( rating ) {
        rating.value = value;
    }
    
    var ratingForm = document.getElementById( 'ratingForm' );
    if ( ratingForm ) {
        switch ( value ) {
            case 1:
            ratingForm.className = 'liRating liOnestar';
            break;
            case 2:
            ratingForm.className = 'liRating liTwostar';
            break;
            case 3:
            ratingForm.className = 'liRating liThreestar';
            break;
            case 4:
            ratingForm.className = 'liRating liFourstar';
            break;
            case 5:
            ratingForm.className = 'liRating liFivestar';
            break; 
        }
    }
        
}
    
function textCounter(field, countfield, fieldlength) {
    if (field.value.length > fieldlength) {
        alert('Ihr Text darf maximal '+fieldlength+' Zeichen lang sein.');
        field.value = field.value.substring(0, fieldlength);
        field.focus()
    }
    countfield.value = fieldlength - field.value.length;
}

function sendReview() {
    var form = document.getElementById( 'reviewForm' );
    var field = document.getElementById( 'reviewAction' );
    
    if ( form && field ) {
        field.value= 'save_login';
        form.submit();
    }
}

function initializeRating( rating ) {
            
    if ( rating && rating > 0 ) {
        setRating( rating );
    } 
}

function loadStyleSheet(filename){
          var stylesheet=document.createElement("link")
          stylesheet.setAttribute("rel", "stylesheet")
          stylesheet.setAttribute("type", "text/css")
          stylesheet.setAttribute("href", filename) 
          document.getElementsByTagName("head")[0].appendChild(stylesheet)
}
function loadScript(filename){
         var script=document.createElement('script')
          script.setAttribute("type","text/javascript")
          script.setAttribute("src", filename)
          document.getElementsByTagName("head")[0].appendChild(script)
}

function switchCategory(categoryTeaserId, index, numTabs){
	if(numTabs == null || numTabs == undefined) {
		numTabs = 3;
	}
	 for (var idx = 0; idx < numTabs ; idx++ ){
		 var categoryBox = document.getElementById( categoryTeaserId+'_'+idx);
		 var categoryHeader = document.getElementById( 'L'+categoryTeaserId+'_'+idx);
		 if (categoryHeader!=null){
			 if (idx==index){
				 //categoryHeader.setAttribute("class", "active");
				 categoryHeader.className = "active";
			 } else {
				 //categoryHeader.setAttribute("class", "inactive");
				 categoryHeader.className = "";
			 }
		 }
		 if (categoryBox!=null){
			 if (idx==index){
				 categoryBox.style.display = "block";
			 } else {
				 categoryBox.style.display = "none";
			 }
		 }
	 }
}


