// JavaScript Document

(function($){
	var mainBase;
	var userShown;
	$.feverSlide = function(el,options){
		
		
	    var base = this;
		
        // Access to jQuery and DOM versions of element
        base.$el = jQuery(el);
        base.el = el;
		
		base.$el.data('feverSlide', base);
		
		
		
		base.init = function(){		
			  base.options = $.extend({}, $.feverSlide.defaultOptions, options);
			  base.options.currentWidth = base.options.width;
			  var uagent = navigator.userAgent.toLowerCase();
			  //var D = new webkit_draggable('image-scroll-list');
			 // var scrollNode = document.querySelector("#image-scroll-list");
			 // var scroller = new TouchScroll(scrollNode, {elastic:true});
			  base.$el
             .css({
                position : 'relative',
                left     : 0,
                top      : 0,
                width    :  base.options.currentWidth, // override css width
				height   : (base.options.imageheight + 15)
             })
			  .find('#content-viewer').css({
                overflow : 'hidden',
                width    : ( base.options.currentWidth - 32 *  2)
             });
			 
			base.panels = base.$el.find('.slide-item');
            base.panels.css({
                width  :  base.options.currentWidth * base.options.panelWidth, // default: panelWidth = 50% of entire width
                float  : 'left'
            });
			
			 base.totalPanels = base.panels.length;
			 var oldX = 0;
			 
			
			 base.container = base.$el.find('#image-scroll-list').css({
                position : 'relative',
                width    : (base.curWidth + 32) * base.totalPanels,
                height   : base.options.imageheight 
            });
			
			if((base.options.imagewidth * base.totalPanels) + (base.totalPanels * 20) < jQuery(window).width() - 64){
				  base.$el.find('.arrow').hide();
			  }
			
			base.$el.find('#left-arrow').click(function(){
                var imagePos =  jQuery("#image-scroll-list").css('left');
				imgPos = parseFloat(imagePos);
	   			imgPos += (base.options.imagewidth * 4);
				if(imgPos >= ( base.options.currentWidth - (base.options.imagewidth*.95))){
					imagePos = base.options.imagewidth/2;
					jQuery("#image-scroll-list").animate({left: imagePos});
				}
				else{
					jQuery("#image-scroll-list").animate({left: imgPos});
				}
            }).end().find('#right-arrow').click(function(){
                var imagePos =  jQuery("#image-scroll-list").css('left');
			    imgPos = parseFloat(imagePos);
	   		    imgPos -= (base.options.imagewidth * 4);
			  if(imgPos <=  ( base.totalPanels * base.options.imagewidth * -1)){
					imagePos = base.options.imagewidth/2;
					jQuery("#image-scroll-list").animate({left: imagePos});
				}
				else{
					jQuery("#image-scroll-list").animate({left: imgPos});
				}
            }).end().find('.slide-item').each(function(){
            		//jQuery(this).fevercontent();
            
            }).end().find('.boxgrid.captionfull').hover(function(){
				
					jQuery(".cover", this).stop().animate({top:'135px'},{queue:false,duration:260});
				}, function() {
					jQuery(".cover", this).stop().animate({top:base.options.imageheight},{queue:false,duration:260});
			}).end().find('#image-scroll-list').draggable({
							drag:function(event, ui) { 

	 			       },
					   axis: "x",
					   scroll: false,
					   disabled: false,
					   start:function(){
					   	jQuery('.boxgrid').addClass('dragging');
					   	jQuery('.boxgrid').unbind('click');
					   	jQuery('.boxgrid').removeClass('nd');
					   },
					   stop:function(){
					   		
						   var imagePos =  jQuery("#image-scroll-list").css('left');
						   imagePos = parseFloat(imagePos);
					   		if(imagePos >= ( base.options.currentWidth - (base.options.imagewidth*.95))){
								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
							}
							else if(imagePos <=  ( base.totalPanels * base.options.imagewidth * -1)){

								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
							}
							var timer;
							timer = setTimeout(function(){
								jQuery('.boxgrid').removeClass('dragging');
								jQuery('.boxgrid').addClass('nd');
					   			jQuery('.boxgrid').each(function(){
	  							jQuery(this).bind('click',function(){
	  									$.address.value(jQuery(this).attr('title'));
	  							});
	  
	  						});
							
							},100);
							
						}
					   }
					).end().find('#right-arrow').hover(function(){
						
						jQuery('#right-arrow').attr('src','images/arrowON.png');
					},
					function(){
						jQuery('#right-arrow').attr('src','images/arrow.png');
					
			}).end().find('#left-arrow').hover(function(){
					jQuery('#left-arrow').attr('src','images/arrowON_left.png');
			},
			function(){
					jQuery('#left-arrow').attr('src','images/arrow_left.png');
			}).end().find('#more-info-link').click(function(){
					//jQuery('#image-scroll-list').animate({left: 0 +"px"})
//
//				    base.$el.find('#image-scroll-list').draggable('option','disabled',true);
//					
//					base.options.currentWidth = jQuery(window).width();
//					
//					base.$el.find('.arrow').hide();
//					base.$el.find('.boxgrid').hide();
//					;
//					base.options.view = "profile";
//					var profileContainer = jQuery(this).parent().parent().parent().parent();
//					userShown = profileContainer;
//					base.options.displayedPanel = profileContainer;
//					//var  profileContainer = jQuery(".user-complete-view", profileContainer);
//					
//					jQuery(".user-complete-view", profileContainer).fadeIn(function(){
//					});
//					
//					
//					jQuery(".x").click(function(){
//						jQuery(".user-complete-view", profileContainer).fadeOut(400,function(){
//							base.$el.find('.boxgrid').fadeIn(400)
//							if((base.options.imagewidth * base.totalPanels) + (base.totalPanels * 20) > jQuery(window).width() - 64){
//				 				 base.$el.find('.arrow').fadeIn(400);
//			 			   }
//							base.$el.animate({
//				 					height: (base.options.imageheight + 15) + "px"
//							 },500);
//						    base.$el.find('#image-scroll-list').draggable('option','disabled',false);
//							jQuery(".x").unbind('click');
//							
//						});
//						
//						
//					});
//					/*jQuery(".x").click(function(){
//						profileContainer.fadeOut();
//						
//					});*/
//					base.$el.animate({
//				 					height: 500 + "px"
//			 },500,function(){});

			});
			
			
			
		
		base.resize();

		}
		 base.res = function(){
			 
			if(base.options.view != "about"){
				jQuery(".user-complete-view", base.options.displayedPanel).fadeOut(400,function(){
							base.$el.find('.boxgrid').fadeIn(400)
							base.$el.find('.arrow').fadeIn(400).css({'display':'inline'});
							base.$el.css({
				 					height: (base.options.imageheight + 15) + "px"
							 },500);
						    base.$el.find('#image-scroll-list').draggable('option','disabled',false);
							
						});	
			}
			 
		 }
		 
		 base.resize = function(){
			jQuery(window).resize(function(){
			jQuery('#mini-scroll-container').css({
				width: jQuery(window).width()
			},500);
			

			jQuery('.cv').css({
                overflow : 'hidden',
                width    : (jQuery(window).width() - 32 *  2 )
        	 });
				if((base.options.imagewidth * base.totalPanels) + (base.totalPanels * 20) < jQuery(window).width() - 64){
				  base.$el.find('.arrow').hide();
			  }else if(!jQuery('#popup-wrapper').hasClass('about')){
				   base.$el.find('.arrow').show();
				    base.$el.find('.arrow').css({'display':'inline'});
			  }
		    base.options.currentWidth = jQuery(window).width();
			base.$el.css({
				width: base.options.currentWidth
			}).find('#content-viewer').css({
                overflow : 'hidden',
                width    : ( base.options.currentWidth - 32 *  2)
             });
			 
			 base.panels.css({
                width  :  base.options.currentWidth * base.options.panelWidth, // default: panelWidth = 50% of entire width
                float  : 'left'
            });
			base.$el.find('#scroll-container').animate({
					width: jQuery(window).width()
			},200);
			
			
			base.$el.find('#left-arrow').click(function(){
				
                var imagePos =  jQuery("#image-scroll-list").css('left');
				imgPos = parseFloat(imagePos);
	   			imgPos += (base.options.imagewidth * 4 );
				if(imagePos >= ( base.options.currentWidth - (base.options.imagewidth*.95))){
								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
							}
				else if(imagePos <=  ( base.totalPanels * base.options.imagewidth * -1)){
								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
				}
            }).end().find('#right-arrow').click(function(){
                var imagePos =  jQuery("#image-scroll-list").css('left');
			    imgPos = parseFloat(imagePos);
	   		    imgPos -= (base.options.imagewidth * 4 );
			  if(imagePos >= ( base.options.currentWidth - (base.options.imagewidth*.95))){
					imagePos = base.options.imagewidth/2;
				   jQuery("#image-scroll-list").animate({left: imagePos});
			    }
				else if(imagePos <=  ( base.totalPanels * base.options.imagewidth * -1)){
					imagePos = base.options.imagewidth/2;
					jQuery("#image-scroll-list").animate({left: imagePos});
				}
            }).end().find('#image-scroll-list').draggable({
							drag:function(event, ui) { 

	 			       },
					   axis: "x",
					   disabled: false,
					   stop:function(){
						   var imagePos =  jQuery("#image-scroll-list").css('left');
						   imagePos = parseFloat(imagePos);
					   		if(imagePos >= ( (jQuery(window).width() - 64) - (base.options.imagewidth*.95))){
								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
							}
							else if(imagePos <=  ( base.totalPanels * base.options.imagewidth * -1)){
								imagePos = base.options.imagewidth/2;
								jQuery("#image-scroll-list").animate({left: imagePos});
							}
						}
					   }
					);
			
		});
		
		 }
		 base.init();
		 mainBase = base;
	}
	$.feverSlide.defaultOptions = {
        startPanel  : 1,   // start with this panel
        width       : 800,
		imageheight : 300,
		currentWidth : 800,
		view : "about",
		displayedPanel: 0,
		show: function(v){
			switch (v){
				case "about":
							jQuery(".user-complete-view").hide();
							jQuery('.boxgrid').show();
							jQuery('.arrow').show();
							jQuery('.arrow').css({'display':'inline'});

							jQuery('#scroll-container').css({
				 					height: (imageheight + 15) + "px"
							 },500);
						    jQuery('#image-scroll-list').draggable('option','disabled',false);
							
						
				break;
				
				case "profile":
				
				break;
				
			}
			
		}
	};
	
	
	var methods = {
		
		showAbout: function(){
			showAbout();
			controlTopNav();
		},
		hideAbout: function(){
			
			
		},
		showUser: function(user,c, o, pag,pn,ms){
			if(userShown && user != userShown){
				jQuery(".user-complete-view", userShown).fadeOut(400,function(){
			
			});	
				
			}
			if(jQuery('#popup-wrapper').hasClass('about')){
				jQuery('#popup-wrapper').removeClass('about');
			}
			if(jQuery('#popup-wrapper').hasClass('macro')){
			jQuery('#popup-wrapper').removeClass('macro');
		}
		if(!jQuery('#popup-wrapper').hasClass('micro')){
			jQuery('#popup-wrapper').addClass('micro');
		}
			if(jQuery('#popup-wrapper').hasClass('about')){
				jQuery('#popup-wrapper').removeClass('about');
			}
			
			setupBackgroundClick();
			setupMiniSlider(ms);
			jQuery('#popup-wrapper').addClass('about');
			jQuery('.user-complete-view').html("");
			jQuery('.user-complete-view.'+user).html(c);
			slideshow = jQuery('#slides').slides({
				preload: true,
				preloadImage: '../images/loading.gif',
				play: 5000,
				pagination: true,
				pause: false,
				hoverPause: true
			});
			
			
			jQuery("a[rel^='prettyPhoto']").prettyPhoto({
												slideshow: false,
												deeplinking: false,
												changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
												callback: function(){
													$.fn.slides.restart();
												}
											});
			jQuery("#vpop").click(function(){
				$.fn.slides.stop();
			});
			//doBump(".bx",850, 500, "34373c", "34373c", 0.7, 3, 1 ,"333", 9,"000", 1, Fx.Transitions.Bounce.easeOut, Fx.Transitions.Bounce.easeOut);
			jQuery('#slide-left').hover(function(){
					jQuery(this).attr('src','images/arrowON_left.png');
			},
			function(){
					jQuery(this).attr('src','images/arrow_left.png');
			});
			jQuery('#slide-right').hover(function(){
						
				    jQuery(this).attr('src','images/arrowON.png');
			},
			function(){
				    jQuery(this).attr('src','images/arrow.png');
					
			});
			
			sizeLayout();
			
			
			jQuery('#arrow-bck').css('display','none');
			if(pag){
				
				//jQuery('#l-arrow').html("<span  id='arrow-fwd'> <img class='arrow-page' src='images/arrow.png' /> </span>");
				//jQuery('#r-arrow').html("<span  id='arrow-bck' class='not-visible'> <img class='arrow-page' src='images/arrow_left.png' /> </span>");
				/*

				jQuery('#r-arrow').attr('title','{"pn":"'+pn+'","cur":"1"}');
				jQuery('#arrow-bck').css('display','none').addClass('not-visible');
				jQuery('#arrow-fwd').fadeIn(200,function(){
										jQuery(this).removeClass('not-visible');
										jQuery(this).addClass('visible');
								
								});
				//jQuery('#arrow-bck').css('display','none');
				
				
				
				jQuery('#arrow-fwd').click(function(){
						pageControl(user);
				
				
				
				});
				jQuery('#arrow-bck').click(function(){
						pageControlBck(user);
				
				
				
				});
*/
				jQuery('#arrow-fwd').css('display','none');
			}else{
				jQuery('#arrow-fwd').css('display','none');
			}
			
			
			if(!jQuery('#popup-wrapper').hasClass('visible')){
				
				jQuery('#popup-wrapper').fadeIn(function(){
					jQuery('#popup-wrapper').addClass('visible');
					jQuery("#background").css({"opacity" : "0.8"})
                            .fadeIn("slow");
                           
				});
				sizeLayout();
			}
			setupBackgroundClick();
			jQuery('#image-scroll-list').animate({left: 0 +"px"})

			mainBase.$el.find('#image-scroll-list').draggable('option','disabled',true);
					
			mainBase.options.currentWidth = jQuery(window).width();
					
			mainBase.$el.find('.boxgrid').hide();
					
					//base.options.view = "profile";
			var profileContainer = jQuery('#profile-'+user);
			userShown = profileContainer;
			mainBase.options.displayedPanel = profileContainer;
			//var  profileContainer = jQuery(".user-complete-view", profileContainer);
					
			jQuery(".user-complete-view", profileContainer).fadeIn(function(){
			});
			//		
					
			jQuery(".x").click(function(){ 
				$.address.value(mainBase.options.name);	
				jQuery('#mini-popup').remove();
				jQuery('.more-quick').remove();
			});
			jQuery(".x").hover(function(){jQuery(this).attr('src','../images/close_on.png');},function(){jQuery(this).attr('src','../images/close.png');});
					/*jQuery("cv").click(function(){
						profileContainer.fadeOut();
						
					});*/
			mainBase.$el.animate({
				 					height: 400 + "px"
			 },500,function(){sizeLayout(400);
			 });
			sizeLayout();
			if(jQuery('#topNavControl').hasClass('open')){
				var control = jQuery('#topNavControl');
			
			jQuery('#top-search').fadeOut();
				jQuery('#top-nav').animate({
					'height': '5px'
					},300,function(){
						jQuery('#top-links').fadeOut();
						control.removeClass('open').addClass('closed').attr('src','images/arrow_down.png').hover(function(){
						control.attr('src','images/arrowON_down.png');
					},function(){
						control.attr('src','images/arrow_down.png');
					});
			
		
				});
			
			}
			 if(typeof(o) != 'undefined'){
				jQuery('.scroll-pane').jScrollPane();
				//alert(c);
			}
			
			mainBase.$el.find('.arrow').hide();
		},
		hideUser: function(user){
			
		}
	}
	function hideGallery(){
		
		
	}
	function controlTopNav(){
	var control = jQuery('#topNavControl');
	if(control.hasClass('closed')){
		jQuery('#top-search').fadeIn();
		jQuery('#top-links').fadeIn();
		jQuery('#top-nav').animate({
			'height': '60px'
		},300,function(){
			control.removeClass('closed').addClass('open').attr('src','images/arrow_up.png').hover(function(){
				control.attr('src','images/arrowON_up.png');
			},function(){
				control.attr('src','images/arrow_up.png');
			});
			
		
		});
	}

}
	function isScrolledIntoView(elem)
	{
    	var docViewTop = jQuery(window).scrollTop();
   		var docViewBottom = docViewTop + jQuery(window).height();
 
    	var elemTop = jQuery(elem).offset().top;
   		var elemBottom = elemTop + jQuery(elem).height();
		alert(document.body.scrollHeight);
		alert(document.body.clientHeight);
   	    return ; 
	}
	
	function showMore(){
		if(window.pageYOffset < 25 && (document.body.scrollHeight != document.body.clientHeight)){
			jQuery('#scroll-container').after('<div class="more-quick"><img src="images/more.png" /></div>');
			jQuery(window).bind('scroll', function(){
				jQuery('.more-quick').fadeOut(250,function(){jQuery(this).remove();});
			});
			jQuery('.more-quick').click(function() {
 				 jQuery('html, body').animate({scrollTop: jQuery(document).height()}, 'slow');
 			 	jQuery(this).fadeOut(250,function(){jQuery(this).remove();});
 			 return false;
			});
		}
	
	}
	function setupMiniSlider(content){
		jQuery('.mini-popup').remove();
		jQuery('#popup-wrapper').after('<div id="mini-popup-wrapper" class="mini-popup"></div><div class="mini-clear"></div>');
		jQuery('#mini-popup-wrapper').html(content);
		setTimeout(function(){
			if(window.pageYOffset < 25 && (document.body.scrollHeight != document.body.clientHeight)){
				jQuery('#scroll-container').after('<div class="more-quick"><img src="images/more.png" /></div>');
				jQuery(window).bind('scroll', function(){
					jQuery('.more-quick').fadeOut(250,function(){jQuery(this).remove();});
				});
				jQuery('.more-quick').click(function() {
 					 jQuery('html, body').animate({scrollTop: jQuery(document).height()}, 'slow');
 			 		jQuery(this).fadeOut(250,function(){jQuery(this).remove();});
 			 		return false;
				});
			}
		
		}, 2000);
		
		
		jQuery('#mini-left-arrow').hover(function(){
					jQuery('#mini-left-arrow').attr('src','images/arrowON_left.png');
			},
			function(){
					jQuery('#mini-left-arrow').attr('src','images/arrow_left.png');
		});
		jQuery('#mini-right-arrow').hover(function(){
						
						jQuery('#mini-right-arrow').attr('src','images/arrowON.png');
					},
					function(){
						jQuery('#mini-right-arrow').attr('src','images/arrow.png');
					
			})
		jQuery('#mini-scroll-container').css({
			width: jQuery(window).width()
		},500);
		jQuery('#scroll-container').css({
			width: jQuery(window).width()
		},500);
		jQuery('.cv').css({
                overflow : 'hidden',
                width    : (jQuery(window).width() - 32 *  2)
         });
         
        jQuery('#mini-scroll-list').draggable({
					    drag:function(event, ui) { 

	 			       },
					   axis: "x",
					   scroll: false,
					   disabled: false,
					   start:function(){
					   	jQuery('.cover').addClass('dragging');
					   	jQuery('.cover').unbind('click');
					   	jQuery('.boxgrid').removeClass('nd');
					   },
					   stop:function(){
					   		
						   var imagePos =  jQuery("#mini-scroll-list").css('left');
						   imagePos = parseFloat(imagePos);
					   		if(imagePos >= ( jQuery(window).width() - (67*.95))){
								imagePos = 67/2;
								jQuery("#mini-scroll-list").animate({left: imagePos});
							}
							else if(imagePos <=  (jQuery('.slide-item').length * 67 * -1)){
								imagePos = 67/2;
								jQuery("#mini-scroll-list").animate({left: imagePos});
							}
							var timer;
							timer = setTimeout(function(){
								jQuery('.cover').removeClass('dragging');
								jQuery('.cover').addClass('nd');
					   			jQuery('.cover').each(function(){
	  							jQuery(this).bind('click',function(){
	  									$.address.value(jQuery(this).attr('title'));
	  							});
	  
	  						});
							
							},100);
							
						}
					   }
		);
		jQuery('#mini-left-arrow').click(function(){
				
                var imgPos =  jQuery("#mini-scroll-list").css('left');
				imgPos = parseFloat(imgPos);
	   			imgPos += (67 * 4 );
				if(imgPos >= ( jQuery(window).width() - (67*.95))){
								imgPos = 67/2;
								jQuery("#mini-scroll-list").animate({left: imgPos});
							}
				else {
								//imagePos = 67/2;
								jQuery("#mini-scroll-list").animate({left: imgPos});
				}
            });
            
            jQuery('#mini-right-arrow').click(function(){
                var imgPos =  jQuery("#mini-scroll-list").css('left');
			    imgPos = parseFloat(imgPos);
	   		    imgPos -= (67 * 4 );
			  if(imgPos <= (jQuery('.slide-item').length * 67 * -1)){
					imgPos = 67/2;
				   jQuery("#mini-scroll-list").animate({left: imgPos});
			    }
				else {
					//imagePos = 67/2;
					jQuery("#mini-scroll-list").animate({left: imgPos});
				}
            });/*
.end().find('#right-arrow').hover(function(){
						
						jQuery('#right-arrow').attr('src','images/arrowON.png');
					},
					function(){
						jQuery('#right-arrow').attr('src','images/arrow.png');
					
			}).end().find('#left-arrow').hover(function(){
					jQuery('#left-arrow').attr('src','images/arrowON_left.png');
			}
			)
*/
	}
	function setupBackgroundClick(){
		jQuery("#background").click(function(){
            jQuery("#background").fadeOut();
            sizeLayout();
            jQuery('#mini-popup-wrapper').fadeOut();
            jQuery("#popup-wrapper").fadeOut(function(){
				jQuery('#popup-wrapper').removeClass('visible');	
				
			});
			jQuery(".user-complete-view").hide();
			jQuery('.boxgrid').show();
			jQuery('.arrow').show();
			jQuery('#scroll-container').css({
				 	height: (250 + 15) + "px"
			 },500);
			jQuery('#image-scroll-list').draggable('option','disabled',false);
			$.address.value(""); 
			jQuery('#mini-popup').remove();
        });
	
	}
	function sizePopup(w,h){
	var headerHeight = jQuery('#main-wrap').height();
	var popupHeight  = jQuery('#popup-wrapper').height();
	var freeScreenSpace = h - 46;
	
	if(jQuery('#popup-wrapper').hasClass('micro')){
		if(h < 700 && h > 600){
			var remainder = (freeScreenSpace - popupHeight)/2;
			jQuery('#popup-wrapper').animate({'margin-top' : remainder + 'px'},100);
			jQuery('#popup-wrapper').animate({'margin-bottom':remainder + 'px'},100);
		}else if(h >= 700){
			var remainder = (h - 600)/2; 
			jQuery('#popup-wrapper').animate({'margin-top':remainder + 'px'},100);
			jQuery('#popup-wrapper').animate({'margin-bottom':remainder + 'px'},100);
		
		}else if( h < (headerHeight + popupHeight)){
			jQuery('#popup-wrapper').animate({'margin-top':'0px'},100);
			jQuery('#popup-wrapper').animate({'margin-bottom':'0px'},100);
		}
	}else{
		if(h >= (headerHeight + popupHeight)){
			var remainder = (freeScreenSpace - popupHeight)/2;
			jQuery('#popup-wrapper').animate({'margin-top':remainder + 'px'},100);
			jQuery('#popup-wrapper').animate({'margin-bottom':remainder + 'px'},100);
		}else if( h < (headerHeight + popupHeight)){
			jQuery('#popup-wrapper').animate({'margin-top':'0px'},100);
			jQuery('#popup-wrapper').animate({'margin-bottom':'0px'},100);
		}
	}
	}
	function sizeLayout(){
		var w = jQuery(window).width();
		var h = jQuery(window).height();
		var headerHeight = jQuery('#main-wrap').height();
		var popupHeight  = jQuery('#popup-wrapper').height();
		var searchWidth = jQuery('#top-search').width();
		var navWidth = w - 198 - searchWidth;
		var freeScreenSpace = h - 46;
		jQuery('#nav-top').css({'width': navWidth});
		jQuery('#mini-scroll-container').css({width: jQuery(window).width()},500);
		jQuery('#background').css({
					'height': h 		
		});
		var logoOffset = ((h/2) - (126/2));
		if(logoOffset > 0){ 
		  jQuery("#logo").css({
			 'padding-top': logoOffset + 'px'
		}
		);
		jQuery("#background-load").css({
					'padding-top': logoOffset + 'px'
		});
	}
		jQuery("#bg").css({
						'height': h  + "px",
						'width' : w + "px",
						'position' : 'fixed',
						'z-index'  : -1000
		});
		
		
		sizePopup(w,h);
		jQuery('#scroll-container').animate({
				width: jQuery(window).width()
			},200);
	
	}

	function pageControl(s){
		var j = jQuery('#r-arrow').attr('title');
		var json = JSON.parse(j);
		var cur = json['cur'];
		var total = json['pn'];
		
		if(cur >= total){
			return;
		}
		else{
			jQuery('#'+s+'-page-'+cur).fadeOut('300',function(){
				var next = ++cur;
				
				if(next >= total){
					jQuery('#arrow-fwd').fadeOut(200,function(){
						jQuery(this).addClass("not-visible");
						jQuery(this).removeClass("visible");
						
					});
				
				}
				jQuery('#'+s+'-page-'+next).fadeIn(200,function(){
						if(jQuery('#arrow-bck').hasClass('not-visible')){
								jQuery('#arrow-bck').fadeIn(200,function(){
										jQuery(this).removeClass('not-visible');
										jQuery(this).addClass('visible');
								
								});
						}
				
				});
				jQuery('#r-arrow').attr('title','{"pn":"'+total+'","cur":"'+next+'"}');
				
			
			});
		}
		
	}
	function pageControlBck(s){
		var j = jQuery('#r-arrow').attr('title');
		var json = JSON.parse(j);
		var cur = json['cur'];
		var total = json['pn'];
		
		if(cur <= 1){
			
			return;
		}
		else{
			jQuery('#'+s+'-page-'+cur).fadeOut('300',function(){
				var next = --cur;
				
				if(next <= 1){
					jQuery('#arrow-bck').fadeOut(200,function(){
						jQuery(this).addClass("not-visible");
						jQuery(this).removeClass("visible");
						
					});
				
				}
				jQuery('#'+s+'-page-'+next).fadeIn(200,function(){
						if(jQuery('#arrow-fwd').hasClass('not-visible')){
								jQuery('#arrow-fwd').fadeIn(200,function(){
										jQuery(this).removeClass('not-visible');
										jQuery(this).addClass('visible');
								
								});
						}
				
				});
				jQuery('#r-arrow').attr('title','{"pn":"'+total+'","cur":"'+next+'"}');
			});
		}
		
	}
	
	function showAbout(){
	if(jQuery('#popup-wrapper').hasClass('micro')){
			jQuery('#popup-wrapper').removeClass('micro');
		}
		if(!jQuery('#popup-wrapper').hasClass('macro')){
			jQuery('#popup-wrapper').addClass('macro');
		}
		if(userShown){
			jQuery('.mini-popup').remove();
			jQuery('.more-quick').remove();
			jQuery(".user-complete-view", userShown).fadeOut(400,function(){
							jQuery('.boxgrid').fadeIn(400)
							if((mainBase.options.imagewidth * mainBase.totalPanels) + (mainBase.totalPanels * 20) > jQuery(window).width() - 64){
				 				 mainBase.$el.find('.arrow').fadeIn(400);
			 			   }
							mainBase.$el.animate({
				 					height: (mainBase.options.imageheight + 15) + "px"
							 },500);
							sizeLayout(250);
						    mainBase.$el.find('#image-scroll-list').draggable('option','disabled',false);
							jQuery(".x").unbind('click');
						});	
				
			}
		  jQuery("#background").css({"opacity" : "0.8"})
                            .fadeIn("slow");

			if(!jQuery('#popup-wrapper').hasClass('visible')){
				jQuery('#popup-wrapper').fadeIn(function(){
					jQuery('#popup-wrapper').addClass('visible');	
				
				});
			}
			
			/*
			//putting border on top
jQuery('#scroll-container').css({
										'border-top-style': 'solid',
										'border-top-width': '1px',
										'border-top-color': jQuery('#menu-item-'+mainBase.options.name).css('color')
			});
*/
			
			jQuery('.page-head').css({'border-bottom': '2px solid '+jQuery('#menu-item-'+mainBase.options.name).css('background-color')});
	  
 	  jQuery('.cover').unbind('click');
	  jQuery('.cover').each(function(){
	  		jQuery(this).bind('click',function(){
	  				$.address.value(jQuery(this).attr('title'));
	  		});
	  
	  });
	setupBackgroundClick();
	}
	
	
	
	 $.fn.feverSlide = function(method){
	
		if ( methods[method] ) {
     		 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
   		 } else if ( typeof method === 'object' || ! method ) {
      		 return this.each(function(){
           		 (new $.feverSlide(this, method));
        	 });
  	    } 
       
    };
	$.fn.reset = function(){
		base.res();

		
	}
})(jQuery);
