	var bValidUserName = false;
	var bValidUserEmail = false;
	
	var lBoxes = new Array('shop_navbox_photos', 'shop_navbox_events', 'shop_navbox_specialoffers', 'shop_navbox_map');
	var lLinks = new Array('lnkPhotos', 'lnkEvents', 'lnkSpecialOffers', 'lnkMap');

	function initializeShoppingGuide(){
		//ChangeCaptcha(); // generate verificaiton image used in submitting comments
		/* toggle the available and not available tabs */
                var rdiv, rlnk;
		for(var i = 0 ; i < lBoxes.length ; i++){
			rdiv = document.getElementById(lBoxes[i]);
                        rlnk = document.getElementById(lLinks[i]); 
			if (rdiv != null){
                            rlnk.style.cursor = 'pointer';                            
                        }else{
                            rlnk.onclick = null;
                            rlnk.style.color = 'lightgray';
                            rlnk.style.cursor = 'text';    
                        }
		}
		
                
            /* add IndexOf support to arrays, for users running IE */
            if(!Array.indexOf){
                Array.prototype.indexOf = function(obj){
                    for(var i=0; i<this.length; i++){
                        if(this[i]==obj){
                            return i;
                        }
                    }
                    return -1;
                }
            }
            
            /* go directly to a certain tab */
                rlnk = null;
                var rViewType = window.top.location.pathname;
                rViewType = rViewType.substring(rViewType.lastIndexOf('/') + 1);
                if (rViewType == 'events') rlnk = document.getElementById('lnkEvents'); 
                if (rViewType == 'specialoffers') rlnk = document.getElementById('lnkSpecialOffers'); 
                if (rViewType == 'map') rlnk = document.getElementById('lnkMap'); 
                if (rlnk != null){            
                    var rposition = lLinks.indexOf(rlnk.id);
                    showBox(lBoxes[rposition], rlnk.offsetLeft);  
                    if (rViewType == 'map') {
                        var lkmap = document.getElementById("lnkMap");
                        lkmap.click();
                    }
                }
           
                
            
	}
             
	/* functions used in the hover effect in the landing page of the shopping guide */
	function SectionResult_MouseOver(Section){
		Section.style.border = "2px solid #707B5C";	
	}

	function SectionResult_MouseOut(Section){
		Section.style.border = "";
	}


        /*function validate(){
		var allValid 	= true;
		var email    	= document.getElementById('UserEmail');
		var name 		= document.getElementById('UserName');
		var comment    	= document.getElementById('UserReview');
		var code 		= document.getElementById("code");
        
		if( comment.value==''){
			document.getElementById(comment.id+'Error1').innerHTML	= "Please, enter your Comment";
			document.getElementById(comment.id+'Error1').style.display	= "block";
			comment.focus();
			allValid = false;
		}else{
			document.getElementById(comment.id+'Error1').innerHTML	= "";
			document.getElementById(comment.id+'Error1').style.display	= "none";
		}
		
		if( name.value==''){
			document.getElementById(name.id+'Error1').innerHTML	= "Please, enter your Display Name";
			document.getElementById(name.id+'Error1').style.display	= "block";
			name.focus();
			allValid = false;
		}else{
			document.getElementById(name.id+'Error1').innerHTML	= "";
			document.getElementById(name.id+'Error1').style.display	= "none";
		}
			
		if( email.value!='' && !isEmail(email.value)){
			document.getElementById(email.id+'Error1').style.display	= 'block';
			document.getElementById(email.id+'Error1').innerHTML		= 'Please, enter valid e-mail for e-mail field';
			email.focus();
			allValid = false;
		}else if( email.value==''){
			document.getElementById(email.id+'Error1').innerHTML	= "Please, enter your e-mail";
			document.getElementById(email.id+'Error1').style.display	= "block";
			email.focus();
			allValid = false;
		}else{
			document.getElementById(email.id+'Error1').innerHTML	= "";
			document.getElementById(email.id+'Error1').style.display	= "none";
		}
		
		if(code.value == ''){
			document.getElementById(code.id+'Error1').innerHTML	= "Please, enter the code shown above";
			document.getElementById(code.id+'Error1').style.display	= "block";
			code.focus();
			allValid = false;
		}else{
			document.getElementById(code.id+'Error1').innerHTML	= "";
			document.getElementById(code.id+'Error1').style.display	= "none";
		}
		
		if (!allValid){
			document.getElementById('commentsAddDiv').style.height	= "405px";
		}else{
			document.getElementById('commentsAddDiv').style.height	= "350px";
		}
		
		return allValid;
	}*/
        
    function validateEmail()  {
       
        var fvValid = document.getElementById('fvEmailValid');       
        var fvInValid = document.getElementById('fvEmailInvalid');
        var txtEmail = document.getElementById('UserEmail');
        var regEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
        
        if (txtEmail.value == null || (txtEmail.value == "") || !(regEmail.test(txtEmail.value))) { 
            fvInValid.style.display='inline';
            fvValid.style.display='none';   
            bValidUserEmail = false;
        }
        else {
            fvInValid.style.display='none';
            fvValid.style.display='inline';  
            bValidUserEmail = true;
            
        }        
      }
      
    function validateName(){
        
        var fvValid = document.getElementById('fvNameValid');       
        var fvInValid = document.getElementById('fvNameInvalid');
        var txtName = document.getElementById('UserName');
        
        if (txtName.value == null || (txtName.value == "") ) { 
            fvInValid.style.display='inline';
            fvValid.style.display='none';    
            bValidUserName = false;
        }
        else {
            fvInValid.style.display='none';
            fvValid.style.display='inline';  
            bValidUserName = true;
            
        }                  
        
    }

	function ValidateAndSubmitReview(shopID) {
		
		if (bValidUserName && bValidUserEmail){
			ajaxAddShopReview(shopID, document.formAddReview.UserReview.value,
                                              document.formAddReview.UserName.value,                               
                                              document.formAddReview.UserEmail.value,
					      document.formAddReview.VerificationCode.value);	
		}
	}
	
	function showBox(BoxID, offsetLeft){
		
		var rdiv;
		for(var i = 0 ; i < lBoxes.length ; i++){
			rdiv = document.getElementById(lBoxes[i]);			
                        if (rdiv != null) rdiv.style.display = "none";
		}
		rdiv = document.getElementById(BoxID);										
		rdiv.style.display = "block";
		
		var dvArrow = document.getElementById('shop_navbox_arrow');	
		if (!(dvArrow == null)) dvArrow.style.left = offsetLeft + "px" ;
	}
	
	function showImage(ImagePath){
		
		var rimg = document.getElementById('shop_image_img');
		rimg.src = ImagePath;
		
	}
	
	function changeFont(SizeChange){
                var textContent	= document.getElementById('shop_textcontent');
                var currentSize;

                if(textContent != null){
                        currentSize = textContent.style.fontSize;
                        if (currentSize){
                                currentSize =  parseInt(currentSize.replace('px',''));
                        }else currentSize = 12;
                        if (SizeChange == 'l') currentSize = currentSize + 2;
                        else currentSize = currentSize - 2;
                        textContent.style.fontSize = currentSize + 'px';
                }
			
			 
	}
        
	
        /* Special Offers Ajax */

        var req;

        function ajxRequest(URL, Parameters, callBackFunction) {

           if (window.XMLHttpRequest) {
               req = new XMLHttpRequest();
           } else if (window.ActiveXObject) {
               req = new ActiveXObject("Microsoft.XMLHTTP");
           }

           req.open("POST", URL, true);
           req.onreadystatechange = callback;
           req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
           req.setRequestHeader("Content-length", Parameters.length);
           req.setRequestHeader("Connection", "close");
           req.send(Parameters);
        }

        function callback() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                    // update the HTML DOM based on whether or not message is valid
                    parseMessage();
                }
            }
        }

        function parseMessage() {
            var message = req.responseText;
            setMessage(message);
        }

        function setMessage(message) {
            var rdiv = document.getElementById("special_offer_loading");
            rdiv.style.display = 'none' ;            
            rdiv = document.getElementById("specialOffers_content");
            rdiv.innerHTML = message;
        }

        
        
        function getajx_SpecialOffers(rOffset, OffersScope) {
            var rdiv = document.getElementById("special_offer_loading");
            rdiv.style.display = 'block' ;
            rdiv = document.getElementById("specialOffers_content");
            rdiv.innerHTML = "";           
            ajxRequest("/shopping_guide/ajx_SpecialOffers", "offset=" + rOffset + "&scope=" + OffersScope, null);      
            //return AJAXRequest("POST", "/shopping_guide/ajx_SpecialOffers", "offset" + rOffset);     
        }
        
        function cbajx_SpecialOffers(){
           //var rdiv = document.getElementById("specialOffers_content");
           //rdiv.innerHTML = "";
           //rdiv.innerHTML = 
            
        }
        
        /* Google Maps  */
        
        var map = null;
	var geocoder = null;
	
	function loadMap() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("directionsMAP"));
			map.addControl(new GSmallMapControl());
                        map.addControl(new GMapTypeControl());
			geocoder = new GClientGeocoder();
		}
	}
	
	function showAddress(address) {
	  if (geocoder) {
		geocoder.getLatLng(
		  address,
		  function(point) {
			if (!point) {
			  alert(address + " not found");
			} else {
				var baseIcon = new GIcon();
				//baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
				//baseIcon.iconSize = new GSize(20, 34);
				//baseIcon.shadowSize = new GSize(37, 34);
				baseIcon.iconAnchor = new GPoint(9, 34);
				//baseIcon.infoWindowAnchor = new GPoint(9, 2);
				//baseIcon.infoShadowAnchor = new GPoint(18, 25);
				var icon = new GIcon(baseIcon);  
				icon.image = "http://www.google.com/mapfiles/marker.png";
				var marker = new GMarker(point, icon); 
				map.setCenter(point, 14);   
				map.addOverlay(marker);
			}
		  }
		);
	  }
	}
