function inputFocus(input, value){
	(input.value == value) ? input.value = "":void(0);
}
function inputBlur(input, value){
	(input.value == "") ? input.value = value:void(0);
}
var myTabs = new Class({
	Implements: [Options, Events],
	options: {
		tabsOptions: [],
		tabsContent: [],
		defaultOpen: 0
	},
	initialize: function(options){
		this.setOptions(options);
		this.options.tabsOptions.each(function(button, i){
			button.addEvent('click', function(event){
				event.stop();
				this.showHidde(i);
			}.bind(this));
		}.bind(this));
		this.showHidde(this.options.defaultOpen);
	},
	showHidde: function(index){
		this.options.tabsContent.each(function(aTabContent){
			aTabContent.setStyle('display', 'none');
		});
		if(index >= 0){
			this.options.tabsContent[index].setStyle('display', 'block');
		}
	}
});
var smallImgTip = new Class({
	Implements: [Options, Events],
	options: {
		titles: new Array(),
		descriptions: new Array(),
		cT: 0,
		cD: 0,
		lis: []
	},
	initialize: function(options){
		this.setOptions(options);
		if($$(this.options.lis).length > 0){
			this.makeTooltips();
		}
	},
	makeTooltips: function(){
		$$(this.options.lis).each(function(aLi){
			var aTagsList = $$("#"+$(aLi).get('id')+" a");
			if(aTagsList.length > 0){
				this.options.titles[this.options.cT] = aTagsList[0].get('title');
				//store titles and text
				aLi.store('tip:title', this.options.titles[this.options.cT]);
				aLi.store('tip:text', '');
				aTagsList.each(function(unA){
					unA.set('title', '');
				});
				this.options.cT++;
			}
		}, this);
		//create the tooltips
		if(this.options.titles.length > 0){
			var tipz = new Tips(this.options.lis,{
				fixed: true,
				hideDelay: 100,
				showDelay: 100,
				//offset: {x: -25, y: 190},
				offset: {x: -47, y: -70},
				'show': function(tip) {
					tip.fade('in');
				},
				'hide': function(tip) {
					tip.fade('out');
				}
			});
		}
	}
});
var addBlank = new Class({
	Implements: [Options],
	options: {
		links: []
	},
	initialize: function(options){
		this.setOptions(options);
		this.modifyLink();
	},
	modifyLink: function(){
		this.options.links.each(function(alink){
			alink.setProperty('target','_blank');
		}.bind(this));
	}
});
function changeShadow(){
	var fxo = new Fx.Morph($("oscuridad"), {duration: 0, wait: true})
	if($("oscuridad").getStyle('opacity') == 0){
		fxo.start({opacity : 0.8});
		//$("offS").removeClass('link_ligth_off').addClass('link_ligth_on');
	}else{
		fxo.start({opacity :  0});
		//$("offS").removeClass('link_ligth_on').addClass('link_ligth_off');
	}
}
function showSwf(codes){
	var flashvars = {};
	for(x=0; x<codes.length; x++){
		flashvars = {movie: codes[x]};
		swfobject.embedSWF(codes[x],"swf"+x, "640", "480", "9.0.0", "expressInstall.swf", flashvars);
	}
}
function CreateBookmarkLink(url) {
	title = "Allmoviegirls"; 
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	}else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}
window.addEvent('domready', function(){
	if($$('.reproductor').length > 0){
		showSwf(codes);
	}
	//search form redirection
	if($('searchForm')){
		$('searchForm').addEvent('submit', function(event){
			event = new Event(event).stop();
			if($('q').value.length > 0){
				window.location = 'http://www.allmoviegirls.com/search/'+escape($('q').value)+'/';
			}
		});
	}
	var clipsTips = new smallImgTip({lis:$$('.clipimage')});
	if($('swfContent')){
		if($('downloadU')){
			var defaultO = searchDefaultTab();
			var videoTabs = new myTabs({
				tabsOptions: [$('downloadU'), $('downloadH'), $('downloadM'), $('information'), $('share')],
				tabsContent: [$('downloadContentU'), $('downloadContentH'), $('downloadContentM'), $('videoInformation'), $('shareContent')],
				defaultOpen: defaultO
			});
		}
		//ligth
		var wh = window.getScrollHeight();
		if($$('.reproductor').length >= 1){
			wh += ($$('.reproductor').length * 480);
		}

		new Element('div').setProperty('id', 'oscuridad').injectInside(document.body);
		$("oscuridad").setStyles({height : (wh+0)+'px', opacity : 0, top: 0+'px', 'position':'absolute', 'width':'100%', 'z-index':100, 'background-color':'#242324', 'cursor':'pointer'});
		$('Lightoff').addEvent('click', function(event) {
			changeShadow();
			event = new Event(event).stop();
		});
		$("oscuridad").addEvent('click', function(event) {
			event = new Event(event).stop();
			changeShadow();
		});
	}else if($('directDownloadContent')){
		var defaultO = searchDefaultTab();
		var videoTabs = new myTabs({
			tabsOptions: [$('downloadU'), $('downloadH'), $('downloadM'), $('share')],
			tabsContent: [$('downloadContentU'), $('downloadContentH'), $('downloadContentM'), $('shareContent')],
				defaultOpen: defaultO
		});
	}
	var blank_links = new addBlank({links:$$('.blank')});
});
function searchDefaultTab(){
	var defaultO = 3;
	if($$('#downloadContentU a').length > 0){
		defaultO = 0;
	}else if($$('#downloadContentH a').length > 0){
		defaultO = 1;
	}else if($$('#downloadContentM a').length > 0){
		defaultO = 2;
	}
	return defaultO;
}