﻿var client = function ($){
     var priv = {
        mouseX : 650,
        mouseY : 400
     };
     
     return{
     
        echo : function()
        {
            alert('echo');
        },
        
        switchCommentView : function(link_id)
        {
            if($("#divSingeComment_"+link_id).css('display') == 'none')
            {
                $("#divSingeComment_"+link_id).show();
                $("#divAllCommentsWrapper_"+link_id).hide();
            }
            else
            {
                $("#divSingeComment_"+link_id).hide();
                $("#divAllCommentsWrapper_"+link_id).show();
            }
        },
        
        toggleLightBox : function()
        {
            if($('.overlay').css('display') == 'none')
            {
                //set the height for the overlay to match height of the whole page (in this case #main)
                $('.overlay').css('height', $('#main').css('height'));
                $('.overlay').css('display', 'block');
           }
            else
            {
                $('.overlay').css('display', 'none');
            }
        },
        
        showPopup : function(link_id, vote_type)
        {
            $('.popup').hide();
        
            var y = priv.mouseY - 140;
            var x = priv.mouseX - 200;

            if(vote_type == "-1")
            {
                $('#popup_down_'+link_id).css('top', y);
                $('#popup_down_'+link_id).css('left', x);
                $('#popup_down_'+link_id).show();
            }
            else if(vote_type == "1")
            {
                $('#popup_up_'+link_id).css('top', y);
                $('#popup_up_'+link_id).css('left', x);
                $('#popup_up_'+link_id).show();
            }
        },
        
        hidePopup : function(link_id)
        {
            $('#popup_up_'+link_id).hide();
            $('#popup_down_'+link_id).hide();
        },
        
        showVoteExpl : function()
        {
            $('.popup').hide();
        
            var y = priv.mouseY - 140;
            var x = priv.mouseX - 200;        

            $('#popup_expl').css('top', y);
            $('#popup_expl').css('left', x);
            
            $('#popup_expl').show();
        },
        
        hideVoteExpl : function()
        {
             $('.popup').hide();
        },
    
        focusTextBox : function(id,order)
        {            
            if(order == 1)
            {
                if($('.txtPE' + id ).val()=='Vul uw e-mailadres in')
                {
                  $('.txtPE' + id ).val('');  
                  $('.txtPE' + id ).css('color','#31363E');    
                  $('.txtPE' + id ).css('font-style','normal');      
                }
            }
            else if(order == 2)
            {
                if($('.txtNE' + id ).val()=='Vul uw e-mailadres in')
                {
                  $('.txtNE' + id ).val('');  
                  $('.txtNE' + id ).css('color','#31363E');         
                  $('.txtNE' + id ).css('font-style','normal');  
                }            
            }
            else if(order == 3)
            {
                if($('.txtPC' + id ).val()=='Voeg eventueel een opmerking toe')
                {
                  $('.txtPC' + id ).val(''); 
                  $('.txtPC' + id ).css('color','#31363E');        
                  $('.txtPC' + id ).css('font-style','normal');              
                }              
            }
            else if(order == 4)
            {
                if($('.txtNC' + id ).val()=='Voeg eventueel een opmerking toe')
                {
                  $('.txtNC' + id ).val('');  
                  $('.txtNC' + id ).css('color','#31363E');    
                  $('.txtNC' + id ).css('font-style','normal');        
                }               
            }
        },
        
        
        blurTextBox : function(id,order)    
        {
            if(order == 1)
            {
                  if( $('.txtPE' + id).val()=='')
                  {
                      $('.txtPE' + id).val('Vul uw e-mailadres in');
                      $('.txtPE' + id ).css('color','#a5a5a5');   
                      $('.txtPE' + id ).css('font-style','italic');   
                  }
            }
            if(order == 2)
            {
                  if( $('.txtNE' + id).val()=='')
                  {
                      $('.txtNE' + id).val('Vul uw e-mailadres in');
                      $('.txtNE' + id ).css('color','#a5a5a5');   
                      $('.txtNE' + id ).css('font-style','italic'); 
                  }
            }
            if(order == 3)
            {
                  if( $('.txtPC' + id).val()=='')
                  {
                      $('.txtPC' + id).val('Voeg eventueel een opmerking toe');
                      $('.txtPC' + id ).css('color','#a5a5a5'); 
                      $('.txtPC' + id ).css('font-style','italic');   
                  }              
            }
            if(order == 4)
            {
                  if( $('.txtNC' + id).val()=='')
                  {
                      $('.txtNC' + id).val('Voeg eventueel een opmerking toe');
                      $('.txtNC' + id ).css('color','#a5a5a5'); 
                      $('.txtNC' + id ).css('font-style','italic');  
                  } 
            }
        },                
        
        setMousePos : function(x,y)
        {
            priv.mouseX = x;
            priv.mouseY = y;
        },
        
        showSuggestionBox : function()
        {
            $('#suggestion').hide();
            $('#makeSuggestion').show();
        },
        
        hideSuggestionBox : function()
        {
            $('#suggestion').show();
            $('#makeSuggestion').hide();
        },
        
        focusLicensePlateBox : function()
        {
            if ($('.txtLicensePlate').val() == 'Vul uw kenteken in')
            {
                $('.txtLicensePlate').val('');
                $('.txtLicensePlate_blur').val('');
                $('.txtLicensePlate').attr('maxlength', '8');
                
                $('.txtLicensePlate').addClass('txtLicensePlate-focus');
                $('.txtLicensePlate').removeClass('txtLicensePlate-blur');
            }
        },

        blurLicensePlateBox : function()
        {
            if ($('.txtLicensePlate').val() == '')
            {
                $('.txtLicensePlate').removeAttr('maxlength');
                $('.txtLicensePlate').val('Vul uw kenteken in');
                
                $('.txtLicensePlate').addClass('txtLicensePlate-blur');
                $('.txtLicensePlate').removeClass('txtLicensePlate-focus');
            }
            else
            {

            }
        },

		gotoCategory : function(friendlyUrl)
		{ 
		    window.location = friendlyUrl;		   
		},
		
		redirectToIndepender : function(base_url)
		{
		    var licensePl = $('#tbxPlateNo').val();
		    var url = base_url + licensePl;
		    
		    window.open(url) ;
		}
    }
}(jQuery);        
