//Script para limpiar los inputs cuando se hace focus
$(function() {
	$.fn.clearInput = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	$(".clearField").clearInput();
});

$.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};


$(document).ready(function() {

	if ( ! $.cookie('disclaimer') || $.cookie('disclaimer') != 'accept')
	{
		$('div#disclaimer').show();
	}
	else if ( $.cookie('disclaimer') == 'accept' )
	{
		$('div.container_16').show();
	}
	
	$("a#disclaimerEnter").click(function () {
		$.cookie('disclaimer', 'accept', { expires: 7, path: '/', domain: 'sexgirlsibiza.com' });
		$('div#disclaimer').hide();
		$('div.container_16').show();
	});


	
	$('#myselectbox1,#myselectbox2,#myselectbox3,#myselectbox4,#myselectbox5,#myselectbox6').selectbox();
	$('#myselectbox7').selectbox({onChangeCallback:select_cities});

	if($('.popGrowl').length > 0)
	{
		$.jGrowl($('.popGrowl').html(), { 
		life: 5000,
		header: 'Error'
		});
	}

   $('.firstW').each(function(item){
	var mystring = $(this).html();
	var firstword = 
	mystring.replace(/(^\w+)/,'<span style="color:#6ba57f">$1</span>');
	$(this).html(firstword);
	});
	
   $('.firstL a').each(function(item){
	var mystring = $(this).html();
	var firstword = 
	mystring.replace(/(^\S{1})/,'<span style="color:#6ba57f">$1</span>');
	$(this).html(firstword);
	});
	
	$("a.pagination").click(
		function()
		{
			//alert($(this).attr("rel"));
			$('#page').val($(this).attr("rel"));
			$('#formSidebar').submit();
			return false;
		});
	
	$(".taglink").click(
		function()
		{
			console.log( $(this).html() );
			return false;
		}
	);
		
		
	
});

function select_cities(param) {
	for(i=0; i<cities.length; i++){
		if(cities[i][0] == param.selectedVal){
			$('#myselectbox6').empty();
			$('#myselectbox6_input').remove();
			var city = $('#myselectbox6_container > ul > li:first').html();
			$('#myselectbox6_container').remove();
			var data = '<option value="" selected="selected">'+city+'</option>';
			for(j=0; j<cities[i][1].length; j++){
				data += '<option value="'+cities[i][1][j][0]+'">'+cities[i][1][j][1]+'</option>';
			}
			$('#myselectbox6').html(data);
			$('#myselectbox6').selectbox();
		}
	};
}

$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});});

function time() {
    return Math.round(new Date().getTime()/1000);
}
	 
$.fn.selectOptionsLabel = function(value, clear)
{
	var v = value;
	var vT = typeof(value);
	var c = clear || false;
	// has to be a string or regular expression (object in IE, function in Firefox)
	if(vT != "string" && vT != "function" && vT != "object") return this;
	this.each(
		function()
		{
			if(this.nodeName.toLowerCase() != "select") return this;
			// get options
			var o = this.options;
			// get number of options
			var oL = o.length;
			for(var i = 0; i<oL; i++)
			{
			/*	if(v.constructor == RegExp)
				{ // no lo probe
					if(o[i].value.match(v))
					{
						o[i].selected = true;
					}
					else if(c)
					{
						o[i].selected = false;
					}
				}
				else
			*/	{
					if(o[i].text == v)
					{
						o[i].selected = true;
					}
					else if(c)
					{
						o[i].selected = false;
					}
				}
			}
		}
	);
	return this;
};

	 
	 
/***** GROWL *****/

(function($){
$.jGrowl=function(m,o){
if($("#jGrowl").size()==0){
$("<div id=\"jGrowl\"></div>").addClass($.jGrowl.defaults.position).appendTo("body");
}
$("#jGrowl").jGrowl(m,o);
};
$.fn.jGrowl=function(m,o){
if($.isFunction(this.each)){
var _6=arguments;
return this.each(function(){
var _7=this;
if($(this).data("jGrowl.instance")==undefined){
$(this).data("jGrowl.instance",new $.fn.jGrowl());
$(this).data("jGrowl.instance").startup(this);
}
if($.isFunction($(this).data("jGrowl.instance")[m])){
$(this).data("jGrowl.instance")[m].apply($(this).data("jGrowl.instance"),$.makeArray(_6).slice(1));
}else{
$(this).data("jGrowl.instance").notification(m,o);
}
});
}
};
$.extend($.fn.jGrowl.prototype,{defaults:{header:"",sticky:false,position:"top-right",glue:"after",theme:"default",corners:"10px",check:500,life:3000,speed:"normal",easing:"swing",closer:true,closerTemplate:"<div>[ close all ]</div>",log:function(e,m,o){
},beforeOpen:function(e,m,o){
},open:function(e,m,o){
},beforeClose:function(e,m,o){
},close:function(e,m,o){
},animateOpen:{opacity:"show"},animateClose:{opacity:"hide"}},element:null,interval:null,notification:function(_17,o){
var _19=this;
var o=$.extend({},this.defaults,o);
o.log.apply(this.element,[this.element,_17,o]);
var _1a=$("<div class=\"jGrowl-notification\"><div class=\"close\">&times;</div><div class=\"headerG\">"+o.header+"</div><div class=\"message\">"+_17+"</div></div>").data("jGrowl",o).addClass(o.theme).children("div.close").bind("click.jGrowl",function(){
$(this).unbind("click.jGrowl").parent().trigger("jGrowl.beforeClose").animate(o.animateClose,o.speed,o.easing,function(){
$(this).trigger("jGrowl.close").remove();
});
}).parent();
(o.glue=="after")?$("div.jGrowl-notification:last",this.element).after(_1a):$("div.jGrowl-notification:first",this.element).before(_1a);
$(_1a).bind("mouseover.jGrowl",function(){
$(this).data("jGrowl").pause=true;
}).bind("mouseout.jGrowl",function(){
$(this).data("jGrowl").pause=false;
}).bind("jGrowl.beforeOpen",function(){
o.beforeOpen.apply(_19.element,[_19.element,_17,o]);
}).bind("jGrowl.open",function(){
o.open.apply(_19.element,[_19.element,_17,o]);
}).bind("jGrowl.beforeClose",function(){
o.beforeClose.apply(_19.element,[_19.element,_17,o]);
}).bind("jGrowl.close",function(){
o.close.apply(_19.element,[_19.element,_17,o]);
}).trigger("jGrowl.beforeOpen").animate(o.animateOpen,o.speed,o.easing,function(){
$(this).data("jGrowl").created=new Date();
}).trigger("jGrowl.open");
if($.fn.corner!=undefined){
$(_1a).corner(o.corners);
}
if($("div.jGrowl-notification:parent",this.element).size()>1&&$("div.jGrowl-closer",this.element).size()==0&&this.defaults.closer!=false){
$(this.defaults.closerTemplate).addClass("jGrowl-closer").addClass(this.defaults.theme).appendTo(this.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.jGrowl",function(){
$(this).siblings().children("div.close").trigger("click.jGrowl");
if($.isFunction(_19.defaults.closer)){
_19.defaults.closer.apply($(this).parent()[0],[$(this).parent()[0]]);
}
});
}
},update:function(){
$(this.element).find("div.jGrowl-notification:parent").each(function(){
if($(this).data("jGrowl")!=undefined&&$(this).data("jGrowl").created!=undefined&&($(this).data("jGrowl").created.getTime()+$(this).data("jGrowl").life)<(new Date()).getTime()&&$(this).data("jGrowl").sticky!=true&&($(this).data("jGrowl").pause==undefined||$(this).data("jGrowl").pause!=true)){
$(this).children("div.close").trigger("click.jGrowl");
}
});
if($(this.element).find("div.jGrowl-notification:parent").size()<2){
$(this.element).find("div.jGrowl-closer").animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,function(){
$(this).remove();
});
}
},startup:function(e){
this.element=$(e).addClass("jGrowl").append("<div class=\"jGrowl-notification\"></div>");
this.interval=setInterval(function(){
jQuery(e).data("jGrowl.instance").update();
},this.defaults.check);
if($.browser.msie&&parseInt($.browser.version)<7){
$(this.element).addClass("ie6");
}
},shutdown:function(){
$(this.element).removeClass("jGrowl").find("div.jGrowl-notification").remove();
clearInterval(this.interval);
}});
$.jGrowl.defaults=$.fn.jGrowl.prototype.defaults;
})(jQuery);

/**** FIN GROWL ****/

