//moved to individual pages
//var currentQuantity = 1;
//var lastQuantity = 0;
var currentProductId;


function changeAddProductId(sku) {
    document.addform.add_product_id.value = sku;
    
    currentProductId = sku;
}

function setAddProductId(name) {
    document.addform.add_product_id.value = name;
}


var waiting_for_response = false;
var queued_request = false;

function setQuantity() {

	
	
    var numtest = /^\d+$/;
    var blanktest = /^$/;
    var maxBookQuantity=999999;
    
    if (blanktest.test(val)) {
        document.getElementById('quantity').value = lastQuantity;
        alert("in blanktest - quantity is: " + document.getElementById('quantity').value);
        
    } else {
    	
        if (numtest.test(document.getElementById('quantity').value)) {
        	
           var val = parseInt(document.getElementById('quantity').value);
           
        	
                /* if count has been set down to 1, then clear the promo code field
			so that 241 codes don't force it back up to */

               if (((lastQuantity < 0) || (val < lastQuantity)) && (val < 2)) {
                	
	                document.getElementById('productPromoCodeId').value='';
                }
    		
            	if(val <= maxBookQuantity)
            		lastQuantity = val;
            	else
            		document.getElementById('quantity').value = lastQuantity;
            	
            	   
                addToCartJSON(document.addform);

        } else {

            document.getElementById('quantity').value = lastQuantity;
        }
    }
    
}



//sg- 05/02/08 mypublisher cards and calendars 3.0
//set the maximum quantity for greeting and post cards.
function setCardsQuantity(product) {
    var numtest = /^\d+$/;
    var blanktest = /^$/;
	var maxPostCardQuantity=2000;
	var maxGreetingCardQuantity=1000;
	var grgCardMsg='The maximum number of greeting cards you can order is 1000.';
	var pstCardMsg='The maximum number of postcards you can order is 2000.';
	var val=document.getElementById('quantity').value;
	
	

	
    if (blanktest.test(val)) {
    	document.getElementById('quantity').value = lastQuantity;
    } else {
    	
        if (numtest.test(val)) {
           /* if (val != lastQuantity) {*/
            	var greater=false;
	            if(product=="pstcrdH1" ||product=="pstcrdV1"  ){
	            	if(val <= maxPostCardQuantity)
	            		lastQuantity = val;
	            	else
	            		greater=true;
	            }
	            else if(product=="grtgcrdH1" ||product=="grtgcrdV1"  ){
	            	if(val <= maxGreetingCardQuantity)
	            		lastQuantity = val;
	            	else
	            		greater=true;
	            		
	            }
                        
                
                document.getElementById('quantity').className = undefined;
                //Error message for max greeting card and postcard quantity.                
                if(greater){
                	if(product=="pstcrdH1" ||product=="pstcrdV1"  ){
                		document.getElementById('quantityMsg').innerHTML =pstCardMsg;            			
                	}
                	else if(product=="grtgcrdH1" ||product=="grtgcrdV1"  ){
                		document.getElementById('quantityMsg').innerHTML =grgCardMsg;	
                	}
                	document.getElementById('quantityValueDiv').style.display = '';
                	               	            	
                }
                else{
                	document.getElementById('quantityValueDiv').style.display = 'none';
        			document.getElementById('quantityMsg').innerHTML='';
              		  	
                }
              	document.getElementById('quantity').value = lastQuantity;
                addToCartJSON(document.addform);
      /*      } else {
                document.getElementById('quantity').className = undefined;
            }*/

        } else {

            document.getElementById('quantity').value = lastQuantity;
        }
    }
   
}




function addToCartJSON(formEl) {
    if(waiting_for_response) {
        queued_request = true;
        return;
    }

    waiting_for_response = true;
    document.addform.display_total.value = '--';

    new Ajax.Request(addItemJsonUrl, {
        method:'post',
        onSuccess: function(transport, json) {
            processAddToCartJSONResp(json);
            },
        parameters: $('addform').serialize(true)
    });
}


function processAddToCartJSONResp(responseObj) {

    if(responseObj) {
    	
        currencySymbol = getCurrencySymbol(responseObj.currency);
        displaySubtotal = currencySymbol + responseObj.subtotal;

        document.addform.display_total.value = displaySubtotal;
        //document.addform.logo_remove.value = responseObj.logoRemovePrice;

        if('false' == responseObj.couponValid) {
            //document.getElementById('switchedToDefaultPromo').innerHTML = '';
            document.getElementById('adjustmentAmount').innerHTML = responseObj.errorMessage;
            document.getElementById('couponValueDiv').style.display = '';
            document.getElementById('quantity').value = responseObj.quantity; 
            document.getElementById('discountMessageDiv').innerHTML = '';
            if(responseObj.productIsABook){
            	document.getElementById('promoSubtotal').style.display = 'none';
            	document.getElementById('promoDescription').style.display = 'none'; 
            }
        } 
        else  {

              if(responseObj.promoValue) {
            	
                if(responseObj.productIsABook) {
                    document.getElementById('promoSubtotal').style.display = '';
                    document.getElementById('promoDescription').style.display = ''; 
                    document.getElementById('promoSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.promoValue+'</div>'; 
            	}

                document.getElementById('adjustmentAmount').innerHTML = responseObj.promoValue; 
                if(responseObj._DEFAULT_PROMO_SWITCH_MESSAGE_)
                	document.getElementById('switchedToDefaultPromo').innerHTML = responseObj._DEFAULT_PROMO_SWITCH_MESSAGE_;
                
                document.getElementById('couponValueDiv').style.display = '';
                
                
                if(responseObj.discountMessage){
                	document.getElementById('discountMessageDiv').innerHTML = responseObj.discountMessage;  
                }
                else{
                	document.getElementById('discountMessageDiv').innerHTML = '';
                }
        	  }             
       		else {
                document.getElementById('adjustmentAmount').innerHTML = '';
                document.getElementById('couponValueDiv').style.display = 'none';
                if(responseObj.productIsABook){
                	document.getElementById('promoSubtotal').style.display = 'none';
                	document.getElementById('promoDescription').style.display = 'none';
                }
                //document.getElementById('switchedToDefaultPromo').innerHTML = '';
                //if(responseObj._DEFAULT_PROMO_SWITCH_MESSAGE_)
                // document.getElementById('switchedToDefaultPromo').innerHTML = responseObj._DEFAULT_PROMO_SWITCH_MESSAGE_;
                if(responseObj.discountMessage){
                	document.getElementById('couponValueDiv').style.display = '';
                	document.getElementById('discountMessageDiv').innerHTML = responseObj.discountMessage;  
                }
                else{
                	document.getElementById('discountMessageDiv').innerHTML = '';
                }
            }
//            waiting_for_response = false;
         }
        
        if(responseObj.productIsABook) { //means it's a book product, though the number might be zero
        	
            document.getElementById('quantity').value = responseObj.quantity; //responseObj.extraPagePrice; //
            document.getElementById('productDescription').innerHTML = responseObj.product_description;
            document.getElementById('productQty').innerHTML = responseObj.quantity; 
            document.getElementById('baseUnitPrice').innerHTML = responseObj.basePrice;
            document.getElementById('baseSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.baseSubtotal+'</div>';
        
            if(parseInt(responseObj.extraPageNum) > 0) {
        	    document.getElementById('extraPageRow').style.display = '';
        	    document.getElementById('extraPageDescription').innerHTML = 'Additional pages over 20 (' + responseObj.extraPageNumPerBook + ' pages/book)';
        	    document.getElementById('extraPageQty').innerHTML = responseObj.quantity;
        	    document.getElementById('extraPageUnitPrice').innerHTML = responseObj.extraPageTotalPricePerBook;
        	    document.getElementById('extraPageSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.extraPageSubtotal+'</div>';
            }
            else {
        	    document.getElementById('extraPageRow').style.display = 'none';
        	}
        
            if(responseObj.logoRemovePrice) {
        	    document.getElementById('logoRemoveRow').style.display = '';
                document.getElementById('removeLogoQty').innerHTML = responseObj.quantity;
                document.getElementById('removeLogoUnitPrice').innerHTML = responseObj.logoRemovePrice;
                document.getElementById('removeLogoSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.logoRemoveSubtotal+'</div>';
             }
             else{
        		document.getElementById('logoRemoveRow').style.display = 'none';
    		 }
            
            if(responseObj.paperTypeOptionPrice) {
        	    document.getElementById('paperTypeOptionRow').style.display = '';
                document.getElementById('paperTypeOptionQty').innerHTML = responseObj.quantity;
                document.getElementById('paperTypeOptionUnitPrice').innerHTML = responseObj.paperOptionPrice;
                document.getElementById('paperTypeOptionSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.paperOptionSubtotal+'</div>';
             }
             else{
            	 if(document.getElementById('paperTypeOptionRow'))
            		 document.getElementById('paperTypeOptionRow').style.display = 'none';
    		 }
            
            if(responseObj.photoFinishCoverOption){
            	
            	if(responseObj.photoFinishCoverOption == 'matte')
            		document.getElementById('productDescription').innerHTML = responseObj.product_description + ' (Matte)';
            	else
            		document.getElementById('productDescription').innerHTML = responseObj.product_description + ' (Gloss)';
            }
            
            
    	  }
        
          // add all the layflat options here
          if ( responseObj.isLayFlatPaperSelected == 'true' && document.getElementById('paperOptionRow') ) {
        	  document.getElementById('paperOptionRow').style.display = '';
       	      // need to update the order total
       	      document.getElementById('paperOptionDescription').innerHTML = 'Lay-Flat Paper';
       	      document.getElementById('paperOptionQty').innerHTML = responseObj.quantity;
       	      document.getElementById('paperOptionUnitPrice').innerHTML = responseObj.layFlatPagePrice;
       	      document.getElementById('lay_flat_text').innerHTML = 'Add ' +  responseObj.layFlatMsgPrice + ' per book.';
       	      document.getElementById('paperOptionSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.layFlatPageSubtotal+'</div>';
       	      
          }
          else {
        	  if (document.getElementById('paperOptionRow')){
        		  document.getElementById('paperOptionRow').style.display = 'none';
           	      document.getElementById('lay_flat_text').innerHTML = 'Add ' +  responseObj.layFlatMsgPrice + ' per book.';
        	  }
        	  
          }
          
          if(responseObj.paperTypeOptionPrice) {
      	    document.getElementById('paperTypeOptionRow').style.display = '';
              document.getElementById('paperTypeOptionQty').innerHTML = responseObj.quantity;
              document.getElementById('paperTypeOptionDescription').innerHTML = responseObj.paperTypeOptionDescription;
              document.getElementById('paperTypeOptionUnitPrice').innerHTML = responseObj.paperTypeOptionPrice;
              document.getElementById('deluxePaper_text').innerHTML = 'Add ' +  responseObj.deluxePaperOptionPrice + ' per book.';
              document.getElementById('paperTypeOptionSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.paperTypeOptionSubtotal+'</div>';
           }
           else{
        	   if(document.getElementById('paperTypeOptionRow')){
        		   document.getElementById('paperTypeOptionRow').style.display = 'none';
        	   }
  		 }
          
          
          
          
          
          // add all the layflat options here
          if ( responseObj.isSuperGlossPrintingSelected == 'true' && document.getElementById('printingOptionRow') ) {
        	  document.getElementById('printingOptionRow').style.display = '';
       	      // need to update the order total
       	      document.getElementById('printingOptionDescription').innerHTML = 'Super Gloss Paper';
       	      document.getElementById('printingOptionQty').innerHTML = responseObj.quantity;
       	      document.getElementById('printingOptionUnitPrice').innerHTML = responseObj.superGlossPrintingPrice;
       	      document.getElementById('superGloss_text').innerHTML = 'Add ' +  responseObj.superGlossMsgPrice + ' per book.';
       	      document.getElementById('printingOptionSubtotal').innerHTML = '<div style="margin-right: 5px;">'+responseObj.superGlossPrintingSubtotal+'</div>';
       	      
          }
          else {
        	  if (document.getElementById('printingOptionRow')){
        		  document.getElementById('printingOptionRow').style.display = 'none';
           	      document.getElementById('superGloss_text').innerHTML = 'Add ' +  responseObj.superGlossMsgPrice + ' per book.';
        	  }
        	  
          }
          
          // for cards add the following info;
          
          if(responseObj.envelopeTypeUnitPrice){
        	  
        	  if(responseObj.envelopeTypeUnitPrice == "$0.00")
        		  document.getElementById('envelopeTypeUnitPrice').innerHTML = "Free";
        	  else
        		  document.getElementById('envelopeTypeUnitPrice').innerHTML = responseObj.envelopeTypeUnitPrice;
        	  
        	  if(responseObj.envelopeTypeTotalPrice == "$0.00")
        		  document.getElementById('envelopeTypeTotalPrice').innerHTML = "Free";
        	  else        	  
        		  document.getElementById('envelopeTypeTotalPrice').innerHTML = responseObj.envelopeTypeTotalPrice;
        	  
        	  
        	  
        	  document.getElementById('envelopeQuantity').innerHTML = responseObj.quantity;
        	  
        	  if(document.getElementById('linerQuantity'))
        		  document.getElementById('linerQuantity').innerHTML = responseObj.quantity;
        	  if(document.getElementById('returnAddressQuantity'))
        		  document.getElementById('returnAddressQuantity').innerHTML = responseObj.quantity;        	  
        	 
        	  if(responseObj.itemPrice == "$0.00")
        		  document.getElementById('cardUnitPrice').innerHTML = "Free";
        	  else
        		  document.getElementById('cardUnitPrice').innerHTML = responseObj.itemPrice;
        	  
        	  if(responseObj.itemPriceSubtotal == "$0.00")
        		  document.getElementById('cardTotalPrice').innerHTML = "Free";
        	  else        	  
        		  document.getElementById('cardTotalPrice').innerHTML = responseObj.itemPriceSubtotal;
        	  
        	  document.getElementById('envelopeTypeDescription').innerHTML = responseObj.envelopeTypeDescription;
          }
          
          
          

        if('false' != responseObj.couponValid && responseObj.promoKeyDisplay){
            document.addform.productPromoCodeId.value = responseObj.promoKeyDisplay;
        }

       //sg,ik-05-13-08  Mypublisher 3.0 - max quantity check.
        if('false' == responseObj.quantityValid) {
            document.getElementById('quantityMsg').innerHTML = responseObj.quantityErrorMessage;
            document.getElementById('quantity').value = responseObj.quantity ;
            document.getElementById('quantityValueDiv').style.display = '';
        }
        waiting_for_response = false;
        
    }

    if(queued_request) {
        queued_request = false;
        addToCartJSON(document.addform);
    }
}


function getCurrencySymbol(currencyCode) {
    if(currencyCode == 'USD') {
        return '$';
    }
    if(currencyCode == 'GBP') {
        return '\u00A3';
    }
    if(currencyCode == 'EUR') {
        return '\u20AC';
    }
    return '';
}


function verifyCoupon() {
	 var numtest = /^\d+$/;
	var blanktest = /^$/;
	var val=document.getElementById('quantity').value;
    if (blanktest.test(val) || !numtest.test(val)) {
        document.getElementById('quantity').value = lastQuantity;
    }
    
    coupnCode = document.addform.productPromoCodeId.value;
    document.addform.productPromoCodeId.value = trim(coupnCode);
    addToCartJSON(document.addform);
    // lastQuantity = -1
}


// Removes leading whitespaces
function LTrim( value ) {

	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim( value ) {

	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function trim( value ) {

	return LTrim(RTrim(value));

}

function chooseDDValue(ddOptions, valSel) {
    if(!valSel) {
        return;
    }
    for(pq = 0; pq < ddOptions.length; pq++) {
        if(ddOptions[pq].value == valSel) {
            ddOptions[pq].selected = 'true';
            break;
        }
    }
}




//hidden div functions

function getStyleObject(objectId) {
    if (document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
        return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
        return document.layers[objectId];
    } else {
        return false;
    }
}
function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId);
    if (styleObject) {
        styleObject.visibility = newVisibility;
        return true;
    } else {
        return false;
    }
}



function submitFormTest() {
    if (document.addform.add_product_id.value == 'NULL') {
        alert("Please select the required amount.");
        return;
    } else {
    	if(ValidateEmail()==true){
	        if (isVirtual(document.addform.add_product_id.value)) {
	            document.location = '<@ofbizUrl>product?category_id=${categoryId?if_exists}&product_id=</@ofbizUrl>' + document.addform.add_product_id.value;
	            return;
	        } else {
	            document.addform.submit();
	        }
    	}
    	else
        	return;
    }
 }

function choosePaperType(type, addprod) {
    if ( type == 'layflat') {
        document.getElementById('rdBtnStandardPaper').checked=false;
    }
    else {
        document.getElementById('rdBtnLayFlatPaper').checked=false;
    }        
    
    if(addprod) {
        addToCartJSON(document.addform);
    }
    
}

function choosePrintingType(type, addprod) {
    if ( type == 'superGloss') {
        document.getElementById('rdBtnStandardPrinting').checked=false;
    }
    else {
        document.getElementById('rdBtnSuperGlossPrinting').checked=false;
    }        
    
    if(addprod) {
        addToCartJSON(document.addform);
    }
    
}


function chooseCoverType(type, addprod) {
    if ( type == 'gloss') {
        document.getElementById('cover_matte').checked=false;
    }
    else {
        document.getElementById('cover_gloss').checked=false;
    }        
    
    if(addprod) {
        addToCartJSON(document.addform);
    }
    
}


function choosePaperQuality(type, addprod) {
    if ( type == 'superior') {
        document.getElementById('rdBtnDeluxePaper').checked=false;
    }
    else {
        document.getElementById('rdBtnSuperiorPaper').checked=false;
    }        
    
    if(addprod) {
        addToCartJSON(document.addform);
    }
    
}


function choosePaperFinish(type, addprod) {
    if ( type == 'matte') {
        document.getElementById('rdBtnSatinPaperFinish').checked=false;
    }
    else {
        document.getElementById('rdBtnMattePaperFinish').checked=false;
    }        
    
    if(addprod) {
        addToCartJSON(document.addform);
    }
    
}



function openWindow(anchor, options) {
	 
	var args = '';
 
	if (typeof(options) == 'undefined') { var options = new Object(); }
	if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }
 
	if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "height=" + options.height + ",";
	}
 
	if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		args += "width=" + options.width + ",";
	}
 
	if (typeof(options.fullscreen) != 'undefined') {
		args += "width=" + screen.availWidth + ",";
		args += "height=" + screen.availHeight + ",";
	}
 
	if (typeof(options.center) == 'undefined') {
		options.x = 0;
		options.y = 0;
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
		options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
		options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
		args += "screenx=" + options.x + ",";
		args += "screeny=" + options.y + ",";
		args += "left=" + options.x + ",";
		args += "top=" + options.y + ",";
	}
 
	if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
	if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }
	if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }
	if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }
 
	var win = window.open(anchor, options.name, args);
	return false;
 
}

function swapImage(productId, imgName ) {
	
	var bkgrndTxt = new Array(3);
	bkgrndTxt[0] = '3.5"X2.75"';
	bkgrndTxt[1] = '7.75"X5.75"';
	bkgrndTxt[2] = '11.25"X8.75"';
	
	// if the imgNum is 0 = scmin, 1 = hcpb, 2 = clha
	// position the image
	if (productId == 'scmini' ){
		
		// set the text below the thumbnail
		document.getElementById('bkgrndTxt').innerHTML=bkgrndTxt[parseInt(0)];
		
		// set the height and width of the background image
		document.getElementById("thumbNailBackGroundDiv").style.height='114'+'px';
		document.getElementById("thumbNailBackGroundDiv").style.width='147'+'px';
		
		// thumbnail reposition
		document.getElementById("thumbNailImage").style.height='95'+'px';
		document.getElementById("thumbNailImage").style.width='129'+'px';
		document.getElementById("thumbNailDiv").style.paddingLeft='10'+'px';
		document.getElementById("thumbNailDiv").style.paddingTop='10'+'px';
		
	}
	else if ( productId == 'hcpb') {
		
		document.getElementById('bkgrndTxt').innerHTML=bkgrndTxt[parseInt(1)];
		
		// set the height and width of the background image
		document.getElementById("thumbNailBackGroundDiv").style.height='156'+'px';
		document.getElementById("thumbNailBackGroundDiv").style.width='196'+'px';
		
		// thumbnail reposition
		document.getElementById("thumbNailImage").style.height='136'+'px';
		document.getElementById("thumbNailImage").style.width='181'+'px';
		document.getElementById("thumbNailDiv").style.paddingLeft='9'+'px';
		document.getElementById("thumbNailDiv").style.paddingTop='10'+'px';
		
	}
	else if ( productId == 'clha'){
		
		document.getElementById('bkgrndTxt').innerHTML=bkgrndTxt[parseInt(2)];
		
		// set the height and width of the background image
		document.getElementById("thumbNailBackGroundDiv").style.height='170'+'px';
		document.getElementById("thumbNailBackGroundDiv").style.width='219'+'px';
		
		// thumbnail reposition
		document.getElementById("thumbNailImage").style.height='153'+'px';
		document.getElementById("thumbNailImage").style.width='205'+'px';
		document.getElementById("thumbNailDiv").style.paddingLeft='9'+'px';
		document.getElementById("thumbNailDiv").style.paddingTop='10'+'px';
	}
	else {
		// TODO: this should not happen but if there is no product sent then just
		//       set the background image as the classic size and do not resize 
		//       the thumbnail
		document.getElementById('bkgrndTxt').innerHTML=bkgrndTxt[parseInt(2)];
		
		// set the height and width of the background image
		document.getElementById("thumbNailBackGroundDiv").style.height='170'+'px';
		document.getElementById("thumbNailBackGroundDiv").style.width='219'+'px';
		
	}
}

function setUpSizeProduct(defaultUpsizeProduct, form) {
	
	// display the correct product pricing
    form.elements["product_id"].value=defaultUpsizeProduct;
    form.elements["add_product_id"].value=defaultUpsizeProduct;
	
	if ( defaultUpsizeProduct == 'scmini' ){
		document.getElementById("scmini").checked = true;
		swapImage('scmini', '/media/img/common_new/upsize_mini.jpg');
		
	}
	else if (defaultUpsizeProduct == 'hcpb' ){
		document.getElementById("hcpb").checked = true;
		swapImage('hcpb', '/media/img/common_new/upsize_mini_pocket_book.jpg');
		
	}
	else if (defaultUpsizeProduct.startsWith('clha') ){
		form.elements["add_product_id"].value='clhaSiwMnaCna';
		document.getElementById("clha").checked = true;
		swapImage('clha', '/media/img/common_new/upsize_mini_classic.jpg');
		
	}
	
	addToCartJSON(form);
	
}

function openResolutionDiv(id) {
	 var e = document.getElementById(id);
	    if(e.style.display == 'block')
	       e.style.display = 'none';
	    else
	       e.style.display = 'block';
}
    

