/* Add PID to all links */ 
 function get() {
   var regexS = "[\\?&](.*)";
   var regex = new RegExp(regexS);
   var results = regex.exec(window.location.href);
   if (results === null) {
       return false;
   } else {
       return results[1];
   }
}
function addPid()
{
 getParam=get();
 if (getParam)
 {
     for (i=0; i < document.links.length; i++)
     {
       oldHref = document.links[i];
       if ( oldHref.href.match("http://www.boobfrog.com/") )
       {              
	       if ( oldHref.href.match("\\?") )
           { document.links[i].href = oldHref.href + "&" + getParam; }
           else { document.links[i].href = oldHref.href + "?" + getParam; }
       }
     } 
	 for (i=0;i<document.forms.length;i++)
	 {
	 	oldForm = document.forms[i];
		if ( oldForm.action.match("http://www.boobfrog.com/") )
        {              
	       if ( oldForm.action.match("\\?") ) { document.forms[i].action = oldForm.action + "&" + getParam; }
           else { document.forms[i].action = oldForm.action + "?" + getParam; }
       }
	 }
 }
}

/* PNG FIX */ 
jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};


$(document).ready( function()
{
	/* LOAD PID */
	addPid();
	/* LOAD PNG FIX */
	$('body').supersleight({shim: 'images/blank.gif'});
	/* LOAD Scrollbar */	

   
   $("div.scrollable").scrollable({
        vertical:true,
        size: 4
    }).circular().mousewheel().autoscroll({ 
    steps: 4, 
    interval: 6000         
}); 
    
	$("#login").tooltip({ 
		effect: 'slide',
		tip: '#login_box', 
		position: 'bottom center',
		offset: [10, 44],
		tooltip: 'mouseover'
	});  
	$("#register").tooltip({ 
		effect: 'slide',
		tip: '#register_box', 
		position: 'bottom center',
		offset: [10, 44],
		tooltip: 'mouseover'
	}); 

		$("li").mouseenter(function () 
			{ $(this).addClass('hover');}
		);
		$("li").mouseleave(function () 
			{$(this).removeClass('hover');}
		);
		
		$(".select_more").click(function () 
			{		  
				$('.select').fadeOut("fast");
				$(this).next().fadeIn("fast");
		  });
		
		$(".image").mouseenter(function() 
			{$(this).children(".tooltip").fadeIn("fast");});
		
		$(".image").mouseleave(function()
		{$(".tooltip").fadeOut("fast");});
		
		$("body").click(function () {
			/* Popunder */		
			  var myWidth = 0, myHeight = 0;
			  var myLeft = 0, myTop = 0;			  
			  if( typeof( window.innerWidth ) == 'number' ) {
			    //Non-IE
			    myWidth = window.innerWidth;
			    myHeight = window.innerHeight;
		        myTop = window.screenX;
		        myLeft = window.screenY;		        
			  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			    //IE 6+ in 'standards compliant mode'
			    myWidth = document.documentElement.clientWidth;
			    myHeight = document.documentElement.clientHeight;
		        myTop = window.screenTop;
		        myLeft = window.screenLeft;				    
			  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			    //IE 4 compatible
			    myWidth = document.body.clientWidth;
			    myHeight = document.body.clientHeight;
		        myTop = window.screenTop;
		        myLeft = window.screenLeft;	
			  }
		if ($("body").hasClass("click"))
			{
		   	var popdown = {
						'win': false,
						'url': 'http://www.babeclub.net',
						'width': myWidth + 'px',
						'height': myHeight + 'px',																
						'left': myLeft + 'px',
						'top': myTop + 'px'
						};  					
		    window.open(popdown.url, '', 'width='+popdown.width+',height='+popdown.height+',left='+popdown.left+',top='+popdown.top+',toolbar=yes,location=yes,menubar=no,scrollbars=yes').blur();
			parent.focus(); 
			/* Popunder */	
			 }
	        $("body").removeClass("click");
		});
	
});	