(function(){
	
	var common = window.common = {
			
		options: {},
		 
		init: function(){
			common.contact();
			common.clients();
		},
		 
		// modals
		contact: function(){
	
        	//select all a tags named modal
      		$('a[name=modal]').click(function(link){
			
				// override link behavior
				link.preventDefault();
				
				// modal identifier
				var id = $(this).attr('href');
	
				// get the screen height and width
				var overlayHeight = $(document).height();
				var overlayWidth = $(window).width();
	
					// set overlay height and width to fill up whole screen
					$('.overlay').css({
						'width': overlayWidth,
						'height': overlayHeight,
						'position': 'absolute',
						'z-index': 10000,
						'top': 0
					});
	
						// transition
						$('.overlay').fadeIn("slow");
						
						// set the popup window to center
						var windowHeight = $(window).height() / 2;
						var windowWidth = $(window).width();
						var modalHeight = $(id).height() / 2;
						
						$(id).css('left', windowWidth / 2 - $(id).width() / 2 - 5);
	
						positionBox = function(event){
							var scrollTop = $(window).scrollTop();
							var yPosition = windowHeight - modalHeight + scrollTop - 82;
							$(id).css('top', yPosition);
						}
					
                    // $(window).bind('scroll', positionBox);
                    	positionBox();

                    // transition effect
                    	$(id).fadeIn("fast");

             });

                // if close button is clicked
                $('.window .close').click(function(link){
                    link.preventDefault();
                    $('.overlay, .window').hide();
                    $(window).unbind('scroll', positionBox);				
                });

                // if overlay is clicked
                $('.overlay').click(function(){
                    $(this).hide();
                    $('.window').hide();
                    $(window).unbind('scroll', positionBox);
                });
                
  		},
  		
  		clients: function(){

            $('.client-list-logo, .client-list-logo-last, .client-index-logo').mouseover(
            	//function(){
            		//$(this).css({"backgroundImage":"url(images/brands/" + $(this).attr('title') + ".jpg)"});
            	//}
            );
            
            $('.client-list-logo, .client-list-logo-last, .client-index-logo').mouseout(
	            //function(){
	        		//$(this).css({"backgroundImage":"url(images/brands/" + $(this).attr('title') + "-.jpg)"});
	        	//}
            );

  		},
  		
  		param: function(param)
		{
			param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			
				var regexS = "[\\?&]" + param + "=([^&#]*)";
				var regex = new RegExp( regexS );
				var results = regex.exec( window.location.href );
			
			if( results == null )
				return "";
			else
				return results[1];
		}
  		
	};
	
})();

