var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

function is_integer(value){
	for (i=0;i<value.length;i++){
		if (value[i]<'0' || value[i]>'9'){
			return false;
		}
	}
	return true;
}

function open_radio(width, height) {
   radio = window.open (url_base+"radio","radio","location=no,status=no,scrollbars=no,width="+width+",height="+height);
   radio.moveTo((screen.width-width)/2,(screen.height-height)/2);
} 

function search_for(what) {
	$('#search_tabs li').removeClass();
	$('#search_'+what).addClass('selected');
	$('#search_for').val(what);
}

function check_boxes() {
	for(i=1;i<=ipp;i++)	{
		if(document.getElementById('ids'+i)) {
			if(document.getElementById('all_ids').checked==true) {
				if(document.getElementById('ids'+i).disabled==false) {
					document.getElementById('ids'+i).checked=true;
				}
			} else if(document.getElementById('ids'+i).disabled==false) {
				document.getElementById('ids'+i).checked=false;
			}
		}
	}
}

function check_box() {
	gasit=0;
	for(i=1;i<=ipp;i++)	{
		if(document.getElementById('ids'+i)) {
			if(document.getElementById('ids'+i).checked==false) {	
				gasit=1;
			}
		}
	}
	if(gasit==1) {
		document.getElementById('all_ids').checked=false;
	}else{
		document.getElementById('all_ids').checked=true;
	}
}

function faq(id) {
	for(i=1;i<=10;i++) {
		$('#faq'+id).hide();
	}
	$('#faq'+id).show();
}

function update_file(variabila){
	var file_field = document.getElementById('my_file_element');
	file_field.value = variabila;
}

function update_fake(variabila){
	var file_field = document.getElementById('fake_element');
	file_field.value = variabila;
}

function download_file(id,act,password,code,album,download_host,use_domain){
	if(use_domain!=1) {
		download_host = "http://www.dump.ro";
	}
	var download_type = $('#type').val();
	
	if(code==1){
		vf_captcha($('#captcha_download').val());//$('#activation').val(), 
		if(response_captcha!=1) {alert('Cod invalid. Scrie textul din imagine corect!');return false;}
	}
	
	if(password == 'yes'){
		var pass = prompt("Parola","");
		if (pass!=null && pass.length!=0)
		{	
			response_captcha=0;
			if(album!='' && album!=0) {
				document.download.action=download_host+'/download.php?action=download&album='+album+'&type=' + $('#type').val() + '&id='+ id +'&act='+ act +'&password=' + pass;
			}else{
				document.download.action=download_host+'/download.php?action=download&type=' + $('#type').val() + '&id='+ id +'&act='+ act +'&password=' + pass;
			}
			document.download.submit();
			
			//myWindowHandle = window.open("http://www.dump.ro/video/top-rated",'_new','scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,fullscreen=1');
			//myWindowHandle.blur();
			//window.focus();
		}
	}else{
		response_captcha=0;
		//document.download.action=document.location;
		document.download.action=download_host+'/download.php?action=download&type=' + $('#type').val() + '&id='+ id +'&act='+ act;
		document.download.submit();
		
		//myWindowHandle = window.open("http://www.dump.ro/video/top-rated",'_new','scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,fullscreen=1');
		//myWindowHandle.blur();
		//window.focus();
	}
	response_captcha = 0;
}

function sleep(naptime){
      naptime = naptime * 1000;
      var sleeping = true;
      var now = new Date();
      var alarm;
      var startingMSeconds = now.getTime();
      while(sleeping){
         alarm = new Date();
         alarmMSeconds = alarm.getTime();
         if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
      }
}

function show_file(id, nr) {
	for(i=1;i<=nr;i++) {
		if(i!=id) {
			$('#view'+i).hide();
		}
		$('#edit'+i).hide();
	}
	if($('#view'+id).css("display")=="none"){
		$('#view'+id).show();
		$('tr.view-info').addClass("tbody").removeClass("view-info");
		$('#view'+id).prev().addClass("view-info").removeClass("tbody");
	}else{
		$('#view'+id).hide();
		$('tr.view-info').addClass("tbody").removeClass("view-info");
	}
}

function edit_file(id, nr) {
	for(i=1;i<=nr;i++) {
		if(i!=id) {
			$('#edit'+i).hide();
		}
		$('#view'+i).hide();
	}
	if($('#edit'+id).css("display")=="none"){
		$('#edit'+id).show();
		$('tr.view-info').addClass("tbody").removeClass("view-info");
		$('#edit'+id).prev().prev().addClass("view-info").removeClass("tbody");
	}else{
		$('#edit'+id).hide();
		$('tr.view-info').addClass("tbody").removeClass("view-info");
	}
}

function CreateBookmarkLink(url, title) {
	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; 
	}
}


/* AJAX */
function vf_field(id,val){
    if(id=="repassword") {
		val+="&val2="+$('#password').val();  
    }
    if(id=="reemail") {
		val+="&val2="+$('#email').val();  
    }
	$.ajax({
		url: url_base+'ajax/vf_field.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'tip='+id+'&val='+val,
		success: function(responseText){
			$('#span-'+id).html(responseText);
		}
	});
}

function update_download(id, table){
	$.ajax({
		url: url_base+'ajax/update_download.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'id='+id+'&table='+table
	});
}

function latest(what){
	$('#right .center h3').removeClass();
	$('#latest_'+what).addClass('selected');
	$('#latest').html('<div align="center"><br /><br /><br /><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br /><br /><br /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/latest.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'what='+what,
		success: function(responseText){
			$('#latest').html(responseText);
			$('.scroll-up').bind('click', function(){
				if( $.browser.msie ) {
					$('.scroll').scrollTo( '-=280px', 800 );
				} else {
					$('.scroll').scrollTo( '-=280px', 800 );
				}
				
			});
			$('.scroll-down').bind('click', function(){
				if( $.browser.msie ) {
					$('.scroll').scrollTo( '+=280px', 800 );
				} else {
					$('.scroll').scrollTo( '+=280px', 800 );
				}
				
			});
		}
	});
}

function similare(id, what, type) {
	$('#right .center h3').removeClass();
	$('#latest_'+type).addClass('selected');
	$('#latest').html('<div align="center"><br /><br /><br /><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br /><br /><br /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/similare.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'what='+what+'&id='+id+'&type='+type,
		success: function(responseText){
			$('#latest').html(responseText);
			$('.scroll-up').bind('click', function(){
				if( $.browser.msie ) {
					$('.scroll').scrollTo( '-=280px', 800 );
				} else {
					$('.scroll').scrollTo( '-=280px', 800 );
				}
				
			});
			$('.scroll-down').bind('click', function(){
				if( $.browser.msie ) {
					$('.scroll').scrollTo( '+=280px', 800 );
				} else {
					$('.scroll').scrollTo( '+=280px', 800 );
				}
				
			});
		}
	});
}

function send_invite() {
	$('#invited').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
	$.ajax({
		url: url_base+'ajax/send_invite.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'emails='+$('#email_list').val(),
		success: function(responseText){
			$('#invited').html(responseText);
		}
	});
}

function recover_pass(){
	$('#result').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
	$.ajax({
		url: url_base+'ajax/recover_pass.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'email='+$('#email_recover').val(),
		success: function(responseText){
			$('#result').html(responseText);
		}
	});
}

function my_files(what, nr){
	if(what=="image") type_lnk="poze";
	else if(type=="album") type_lnk="poze";
	else if(what=="audio") type_lnk="audio";
	else if(what=="video") type_lnk="video";
	else if(what=="file") type_lnk="fisiere";
	else if(what=="playlist") type_lnk="playlist";
	else if(what=="slideshow") type_lnk="slideshow";

	if(nr!=""){
		pag="/pag"+nr;
	}else{
		pag="";
	}

	$('#my_files_ul li a').removeClass();
	$('#my_files_ul li a').addClass('normal');
	$('#my_files_'+what+' a').addClass('selected');
	$('#div-files').html('<div align="center" style="height:500px"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src="'+url_base+'css/images/loading.gif" /></div>');
	$.ajax({
		url: url_base+'ajax/my_files.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'what='+what,
		success: function(responseText){
			//$('#div-files').html(responseText);
			location.href=url_base+"fisierele-mele/"+type_lnk+pag;
		}
	});
}

function details(what){
	$('.box').removeClass('collapse');
	$('.link2').removeClass('current');
	$('#'+what+'_a').addClass('current');
	$('#div-download').hide();
	$('#div-files').hide();
	$('#div-comments').hide();
	$('#div-report').hide();
	$('#div-send').hide();
	$('#div-'+what).show();
}

var response_captcha = 0;
function vf_captcha(captcha) {  
	$.ajax({
		url: url_base+'ajax/vf_captcha.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		async: false,
		data: 'val='+captcha,//+'&id='+id
		success: function(responseText){
			response_captcha=responseText;
		}
	});
}

function vf_register_form(){
  if($('#agree').is(":checked")) {
	getstr = "username=" + encodeURI( $("#username").val() ) +
		"&password=" + encodeURI( $("#password").val() ) +
		"&repassword=" + encodeURI( $("#repassword").val() ) +
		"&captcha=" + encodeURI( $("#captcha").val() ) +
		"&name=" + encodeURI( $("#name").val() ) +
		"&country=" + encodeURI( $("#country").val() ) +
		"&day=" + encodeURI( $("#day").val() ) +
		"&month=" + encodeURI( $("#month").val() ) +
		"&year=" + encodeURI( $("#year").val() ) +
		"&email=" + encodeURI( $("#email").val() ) +
		"&reemail=" + encodeURI( $("#reemail").val() ) +
		"&judet=" + encodeURI( $("#judet").val() ) ;
	if($("#cod").val()!="" && $("#usr").val()!="") {
		getstr+="&cod=" + encodeURI( $("#cod").val() ) +
		"&usr=" + encodeURI( $("#usr").val() ) ;
	}
	$('#div-register').html("<div style='height:420px;margin:0px auto;' align='center'><br /><br /><br /><br /><br /><br /><br /><br /><img src='"+url_base+"css/images/loading.gif' border='0'><br /><br />Te rugam asteapta</div>");
	$.ajax({
		url: url_base+'ajax/vf_form.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: getstr,
		success: function(responseText){
			$('#div-register').html(responseText);
		}
	});
  } else {
	  $('#span-agree').html("<div class='red'>&nbsp;&nbsp;&nbsp;<img src='"+url_base+"css/images/cross.gif' align='absmiddle'>&nbsp;&nbsp;Trebuie sa fii de acord cu Termenii si Conditiile</div>");
  }
}

function vf_register_form_edit(){
    getstr = "password=" + encodeURI( $("#password").val() ) +
			"&repassword=" + encodeURI( $("#repassword").val() ) +
			"&captcha=" + encodeURI( $("#captcha").val() ) +
			"&name=" + encodeURI( $("#name").val() ) +
			"&country=" + encodeURI( $("#country").val() ) +
			"&judet=" + encodeURI( $("#judet").val() ) +
			"&day=" + encodeURI( $("#day").val() ) +
			"&month=" + encodeURI( $("#month").val() ) +
			"&year=" + encodeURI( $("#year").val() ) ;
	$('#div-register').html("<div style='height:400px;margin:0px auto;' align='center'><br /><br /><br /><br /><br /><br /><br /><br /><img src='"+url_base+"css/images/loading.gif' border='0'><br /><br />Te rugam asteapta</div>");
	$.ajax({
		url: url_base+'ajax/vf_form_edit.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: getstr,
		success: function(responseText){
			$('#div-register').html(responseText);
		}
	});
}

function report_file(id, table) {
	if($('#reptype').val()!="" && $('#reptype').val()!="0" && $('#repmsg').val()!="" && $('#repname').val()!=""){
		$.ajax({
			url: url_base+'ajax/report_file.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'id='+id+'&name='+$('#repname').val()+'&type_rep='+$('#reptype').val()+'&type='+$('#type').val()+'&table='+table+'&msg='+$('#repmsg').val(),
			success: function(responseText){
				$('#div-report').html(responseText);
			}
		});
	}else{
		alert("Completeaza toate campurile corect!");
	}
}

function add_comment(id, table){
	if($('#desc').val()!=""){
		val=$('#nr2').html();
		$.ajax({
			url: url_base+'ajax/add_comm.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'id='+id+'&desc='+encodeURI( $("#desc").val() )+'&table='+table,
			success: function(responseText){
				$('#nr2').html(parseInt(val)+1);
				$('#comment').hide();
				$('#comments').prepend(responseText);
			}
		});
	}
}

function newsletter() {
	if($('#email_subscribe').val()!=""){
		email=$('#email_subscribe').val();
		$('div#abonare').hide();
		$('div.newsletter div.preloader').show();
		$.ajax({
			url: url_base+'ajax/newsletter.php',
			type: 'GET',
			cache: false,
			data: '&email='+email,
			success: function(msg){
				$('div.newsletter div.preloader').hide();
				$('#abonare').show();
				$('#abonare span').html(msg);
			}
		});
	}
}


function save_pass(id, type) {
	if($('#pass'+id).val()!=""){
		$.ajax({
			url: url_base+'ajax/save_pass.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: '&id='+id+'&type='+type+'&pass='+$('#pass'+id).val(),
			success: function(responseText){
				$('#show_pass'+id).hide();
				$('#details'+id).html(responseText);
				$('#details'+id).show("slow");
			}
		});
	}
}

function save_file(id,what){
	name=$('#file'+id).val();
	desc=$('#descr'+id).val();
	pass=$('#newpass'+id).val();
	if(what!="file") {
		public=$('#public'+id+' option:selected');
	}else{
		public=0;	
	}
	if(name!="") {
		$('#save'+id).html('<p align="center" style="height:200px"><br /><br /><br /><br /><br /><img src="'+url_base+'css/images/loading.gif" /></p>');
		$.ajax({
			url: url_base+'ajax/save_file.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'id='+id+'&what='+what+'&name='+name+'&pass='+pass+'&desc='+desc+'&public'+public,
			success: function(responseText){
				texte=responseText.split("_____");
				$('#file_name'+id).html(texte[0]);
				$('#name_file'+id).html(texte[0]);
				$('#save'+id).html(texte[1]);
			}
		});
	}
}

function send_mail(id, type) {
	if($('#your_name').val()!="" && $('#your_email').val()!="" && $('#friends_email').val()!="" && $('#friends_message').val()!=""){
		$('#email').hide();
		$('#loading_mail').show();
		$.ajax({
			url: url_base+'ajax/send_mail.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: '&id='+id+'&type='+type+'&your_name='+$('#your_name').val()+'&your_email='+$('#your_email').val()+'&friends_email='+$('#friends_email').val()+'&friends_message='+$('#friends_message').val(),
			success: function(responseText){
				$('#email').html(responseText);
				$('#loading_mail').hide();
				$('#email').show();
			}
		});
	}else{
		alert("Completeaza toate campurile corect");	
	}
}

function add_playlist(id) {
	$('#playlist').html('<div align="center"><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=add&id='+id,
		success: function(responseText){
			$('#playlist').html(responseText.split("___")[0]);
			$('#player_options').html(responseText.split("___")[1]);
			$('#player_options').show();
		}
	});
	$.scrollTo(0,500);
}

function load_playlist(id) {
	$('#playlist').html('<div align="center"><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=load&id='+id,
		success: function(responseText){
			$('#playlist').html(responseText.split("___")[0]);
			$('#player_options').html(responseText.split("___")[1]);
			$('#player_options').show();
		}
	});
	$.scrollTo(0,500);
}

function load_album(id) {
	$('#playlist').html('<div align="center"><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=load_album&id='+id,
		success: function(responseText){
			$('#playlist').html(responseText.split("___")[0]);
			$('#player_options').html(responseText.split("___")[1]);
			$('#player_options').show();
		}
	});
	$.scrollTo(0,500);
}

function del_item(id) {
	$('#playlist').html('<div align="center"><br /><br /><img src="'+url_base+'css/images/loading.gif" /><br /><br style="line-height:6px" /></div>');
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=delete&id='+id,
		success: function(responseText){
			if(responseText.split("___")[0]==0) {
				$('#player_options').hide();
			}
			$('#playlist').html(responseText.split("___")[1]);
			$('#player_options').html(responseText.split("___")[2]);
			if(reinrdgf==1){
				location.href=url_base+"muzica/download";
			}
		}
	});
}

function stop_playlist(){
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=stop',
		success: function(responseText){
			$('#play').html(responseText);
		}
	});
}

function save_playlist(){
	$('#save_form').show();
	$('#saved').hide();
	$('#title_sl').val("");
	$("input.salveaza").click(function(){
		if($('#title_sl').val()!="") {							 
			$.ajax({
				url: url_base+'ajax/playlist.php',
				type: 'GET',
				cache: false,
				dataType: 'html',
				data: 'action=save&title='+$('#title_sl').val(),
				success: function(responseText){
					$('#saved').html(responseText);
					$('#saved').show();
				}
			});
		}
	});
}

function empty_playlist(){
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=empty',
		success: function(responseText){
			$('#player_options').hide();
			$('#playlist').html(responseText);
			if(reinrdgf==1){
				location.reload();
			}
		}
	});
}

function shuffle(type){
	$.ajax({
		url: url_base+'ajax/playlist.php',
		type: 'GET',
		cache: false,
		dataType: 'html',
		data: 'action=shuffle&type='+type,
		success: function(responseText){
			$('#shuffle').html(responseText);
		}
	});
}

function create_album(){
	$('#album').show();
	$("input.create_alb").click(function(){
		$('#album_done').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /><br /></div>');
		if($('#public_alb').is(":checked")) {
			public=1;
		}else{
			public=0;	
		}
		$.ajax({
			url: url_base+'ajax/create_album.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'public='+public+'&title='+$('#title_album').val(),
			success: function(responseText){
				$('#albume_create').html(responseText);
				location.href=url_base+"fisierele-mele/poze";
			}
		});
	});
}

function login() {
	if($('#pass').val()!="" && $('#user').val()!=""){
		user=$('#user').val();
		pass=$('#pass').val();
		$('#login').html("<img src='"+url_base+"css/images/loadlogin.gif' border='0' />");
		$.ajax({
			url: url_base+'ajax/login.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'user='+user+'&pass='+pass,
			success: function(responseText){
				texte=responseText.split("___");
				if(texte[0]==1) {
					$('div.menubox div#login').css({ 'display': 'none'});
					$('div.menubox div#search').css({ 'display': 'block'});
					$('div.submenu').show();
					$('div.submenu div:visible').hide();
					$('div.submenu div.menu_cont').show();
					$('a#menu_cont').show();
					$('a#menu_cont').parent().addClass("selected");
					$('a#showlogin').hide();
					$('#login').append(texte[2]);
					$('#F1Upload').append('<input type="hidden" name="usr" value="' + texte[1] + '" />');
					location.reload();
				}else{
					$('#login').html(texte[1]);
				}
			}
		});
	}
}

function delete_usrfile(id, type, nr) {
	if(type=="album") {
		text="acest album";	
	}else if(type=="slideshow") {
		text="acest slideshow";	
	}else if(type=="playlist") {
		text="acest playlist";	
	}else if(type=="image") {
		text="acesata imagine";	
	}else{
		text="acest fisier";	
	}

	if(nr!=""){
		pag="/pag"+nr;
	}else{
		pag="";
	}

	if(type=="image") type_lnk="poze";
	else if(type=="album") type_lnk="poze";
	else if(type=="audio") type_lnk="audio";
	else if(type=="video") type_lnk="video";
	else if(type=="file") type_lnk="fisiere";
	else if(type=="playlist") type_lnk="playlist";
	else if(type=="slideshow") type_lnk="slideshow";

	okdelete=confirm("Esti sigur ca doresti sa stergi "+text+"?");
	if (okdelete==true) {
		$('#album_done').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /><br /></div>');
		$.ajax({
			url: url_base+'ajax/delete_file.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'id='+id+'&what='+type,
			success: function(responseText){
				$('#tr'+id).hide();
				if(type=="album"){
					$('#albume_create').html(responseText);
					elSel = document.getElementById('with_selected');
					for (k = elSel.length - 1; k>=0; k--) {
						if (elSel.options[k].value=="album_"+id) {
							elSel.remove(k);
						}
					}	
				}
				$('#album_done').html('');
				location.href=url_base+"fisierele-mele/"+type_lnk+pag;
			}
		});
	}
}

function delete_file(id, type, password) {
	if(type=="image") {
		text="acesata imagine";	
	}else{
		text="acest fisier";	
	}
	okdelete=confirm("Esti sigur ca vrei sa stergi "+text+"?");
	if (okdelete==true) {
		if(password == 'yes') {
			var pass = prompt("Parola","");
			if (pass!=null && pass.length!=0) {	
				use_pass=1;
			}
		} else {
			use_pass=0;
		}
		$.ajax({
			url: url_base+'ajax/delete_single_file.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'id='+id+'&what='+type+'&use_pass='+use_pass+'&pass='+pass,
			success: function(responseText){
				texte=responseText.split("___");
				if(texte[0]==0) {
					$('#error').html(texte[1]);
				}
				else if(texte[0]==1) {
					$('#cont_fis').html(texte[1]);
					$('#error').hide();
				}
			}
		});
	}
}

function do_with(value, type, nr) {
	if(type=="slideshow") {
		text="aceste slideshow-uri";	
	}else if(type=="playlist") {
		text="aceste playlist-uri";	
	}else if(type=="image") {
		text="aceste poze";	
	}else{
		text="aceste fisiere";	
	}

	found=0;
	var checkboxes = new Array();

	$('#invited').html();
	$('#slideshow').html();
	$('#select_audio').hide();
	$('#send_email').html();

	if(value!=0) {
		for(i=1;i<=ipp;i++) {
			if($('#ids'+i).is(":checked")) {
				checkboxes[i]=true;
			}
		}
		for(i=1;i<=ipp;i++)	{
			if(checkboxes[i]==true)	{
				found=1;
				break;
			}
		}
		if(found==1) {
			all_vars="";
			for(i=1;i<=ipp;i++)	{
				if($('#ids'+i).is(":checked")) {
					all_vars+=$('#ids'+i).val()+"_";
				}
			}
			
			if(value=="delete") {
				okdelete=confirm("Esti sigur ca vrei sa stergi "+text+"?");
				if (okdelete==true)	{
					$.ajax({
						url: url_base+'ajax/delete_file.php',
						type: 'GET',
						cache: false,
						dataType: 'html',
						data: 'what='+type+'&ids='+all_vars,
						success: function(responseText){
							for(i=1;i<=ipp;i++)	{
								if(checkboxes[i]==true)	{
									$('#tr'+$('#ids'+i).val()).hide();
								}
							}
							document.getElementById('all_ids').checked=false;
							my_files(type, nr);
						}
					});
				}
			}
			else if(value=="public") {
				$.ajax({
					url: url_base+'ajax/switch.php',
					type: 'GET',
					cache: false,
					dataType: 'html',
					data: 'what='+type+'&ids='+all_vars+'&act=1',
					success: function(responseText){
						for(i=1;i<=ipp;i++)	{
							if(checkboxes[i]==true)	{
								$('#td'+$('#ids'+i).val()).html("Da");
								$('#tc'+$('#ids'+i).val()).html("Da");
								document.getElementById('ids'+i).checked=false;
							}
						}
						document.getElementById('all_ids').checked=false;
						my_files(type, nr);
					}
				});
			}
			else if(value=="privat") {
				$.ajax({
					url: url_base+'ajax/switch.php',
					type: 'GET',
					cache: false,
					dataType: 'html',
					data: 'what='+type+'&ids='+all_vars+'&act=0',
					success: function(responseText){
						for(i=1;i<=ipp;i++)	{
							if(checkboxes[i]==true)	{
								$('#td'+$('#ids'+i).val()).html("Nu");
								$('#tc'+$('#ids'+i).val()).html("Nu");
								document.getElementById('ids'+i).checked=false;
							}
						}
						document.getElementById('all_ids').checked=false;
						my_files(type, nr);
					}
				});
			}
			else if(value=="slideshow") {
				$('#select_audio').show();
				$("input.creaza").click(function(){
					if($('#title_sl').val()!="") {	
						if($('#public_slide').is(":checked")) {
							public=1;
						}else{
							public=0;	
						}
						$.ajax({
							url: url_base+'ajax/slideshow.php',
							type: 'GET',
							cache: false,
							dataType: 'html',
							data: 'ids='+all_vars+'&id_audio='+$('#id_audio').val()+'&public='+public+'&title='+$('#title_sl').val(),
							success: function(responseText){
								$('#slideshow').html(responseText);
							}
						});
					}else{
						alert("Da un titlu slideshow-ului tau!");	
					}
				});
			}
			else if(value=="email") {
				$('#send_email').show();
				$("input.trimite").click(function(){
					$('#invited').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
					$.ajax({
						url: url_base+'ajax/send_files.php',
						type: 'GET',
						cache: false,
						dataType: 'html',
						data: 'what='+type+'&ids='+all_vars+'&emails='+$('#email_list').val(),
						success: function(responseText){
							$('#invited').html(responseText);
						}
					});
				});
			}
			else if(value=="zip") {
				$('#invited').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
				$.ajax({
					url: url_base+'ajax/zip_files.php',
					type: 'GET',
					cache: false,
					dataType: 'html',
					data: '&ids='+all_vars,
					success: function(responseText){
						$('#invited').html('');
						location.href=url_base+'zip.php?zip='+responseText;
					}
				});
			}else if(value.split("_")[0]=="album") {
				$('#invited').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
				$.ajax({
					url: url_base+'ajax/add_to_album.php',
					type: 'GET',
					cache: false,
					dataType: 'html',
					data: 'id='+value.split("_")[1]+'&ids='+all_vars,
					success: function(responseText){
						$('#counter'+value.split("_")[1]).html(responseText.split("___")[0]);
						$('#invited').html(responseText.split("___")[1]);
					}
				});
			}else if(value.split("_")[0]=="slide") {
				$('#invited').html('<div align="center"><img src="'+url_base+'css/images/loading.gif" /></div>');
				$.ajax({
					url: url_base+'ajax/add_to_slideshow.php',
					type: 'GET',
					cache: false,
					dataType: 'html',
					data: 'id='+value.split("_")[1]+'&ids='+all_vars,
					success: function(responseText){
						//$('#counter'+value.split("_")[1]).html(responseText.split("___")[0]);
						$('#invited').html(responseText.split("___")[1]);
					}
				});
			}
		}
		else alert("Nu ai selectat nimic");
	}
	document.getElementById('with_selected').options[0].selected="selected";
}
/* END OF AJAX */

function payment(val, usr){
	if(val!="" && val!=0){
		$.ajax({
			url: url_base+'ajax/payment.php',
			type: 'GET',
			cache: false,
			dataType: 'html',
			data: 'val='+val+'&usr='+usr,
			success: function(responseText){
				$('#payment').html(responseText);
			}
		});
	}else{
		$('#payment').html("");
	}
}

/* YAHOO */
$(document).ready(function() {
	var checkUser = function (username) {
		var username = $('#yahoo_username').val();
		var myRand = parseInt(Math.random()*99999999);
		if(username!="") {
			$("#yahoo").html('<br style="line-height:8px;" /><img src="'+url_base+'css/images/loading.gif" alt="Yahoo Friend Finder" />').fadeIn("slow");		
			$.ajax({
				url: url_base+'ajax/checkUser.php',
				type: 'POST',
				cache: false,
				dataType: 'html',
				data: 'nick='+username+'&rnd='+myRand,
				success: function(responseText){
					$("#yahoo").html('<img src="'+url_base+'css/images/yahoo.jpg" alt="Yahoo Friend Finder" />').fadeIn("slow");
					$("#response_yahoo").fadeTo(200,0.1,function() { 
						$(this).html(responseText).fadeTo(900,1);
					});		
				}
			});
		}
	}
	$("#checkUser").click(checkUser);
});
/* END OF YAHOO */

/* PNG FIX */
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}));
/* END OF PNG FIX */

/* FLASH OBJECT */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5(J 8=="R"){7 8=u F()}5(J 8.l=="R"){8.l=u F()}5(J 8.l.K=="R"){8.l.K=u F()}5(J 8.l.S=="R"){8.l.S=u F()}8.l.T=t(a,b,w,h,d,c,e,f,g,i,j){5(!B.1q||!B.1r){m}4.1s=j?j:"1J";4.1t=8.l.K.1c(4.1s);4.1d=u F();4.U=u F();4.1e=u V();4.1u=e;5(a){4.y("1f",a)}5(b){4.y("G",b)}5(w){4.y("L",w)}5(h){4.y("M",h)}5(d){4.y("N",u 8.l.D(d.1K().W(".")))}4.X=8.l.S.1v(4.o("N"),e);5(c){4.1g("1L",c)}7 q=f?f:"1M";4.1g("1N",q);7 k=(g)?g:1O.Y;4.y("1w",k);4.y("10","");5(i){4.y("10",i)}};8.l.T.11={y:t(a,b){4.1e[a]=b},o:t(a){m 4.1e[a]},1g:t(a,b){4.1d[a]=b},1h:t(){m 4.1d},O:t(a,b){4.U[a]=b},1P:t(a){m 4.U[a]},1x:t(){m 4.U},1Q:t(n,v){7 p=B.1q("12");p.y("P",n);p.y("13",v);m p},1i:t(){7 a=u V();7 b;7 c=4.1x();14(b 1j c){a.1k(b+"="+c[b])}m a},1y:t(){7 a="";5(H.1l&&H.1m&&H.1m.E){5(4.o("Q")){4.O("1z","1R")}a="<1S 1T=\\"1U/x-1V-1W\\" 1X=\\""+4.o("1f")+"\\" L=\\""+4.o("L")+"\\" M=\\""+4.o("M")+"\\"";a+=" G=\\""+4.o("G")+"\\" P=\\""+4.o("G")+"\\" ";7 b=4.1h();14(7 c 1j b){a+=[c]+"=\\""+b[c]+"\\" "}7 d=4.1i().1A("&");5(d.E>0){a+="1B=\\""+d+"\\""}a+="/>"}15{5(4.o("Q")){4.O("1z","1Y")}a="<1C G=\\""+4.o("G")+"\\" 1Z=\\"20:21-22-23-24-25\\" L=\\""+4.o("L")+"\\" M=\\""+4.o("M")+"\\">";a+="<12 P=\\"26\\" 13=\\""+4.o("1f")+"\\" />";7 e=4.1h();14(7 c 1j e){a+="<12 P=\\""+c+"\\" 13=\\""+e[c]+"\\" />"}7 f=4.1i().1A("&");5(f.E>0){a+="<12 P=\\"1B\\" 13=\\""+f+"\\" />"}a+="</1C>"}m a},27:t(a){5(4.1u){7 b=u 8.l.D([6,0,28]);5(4.X.16(b)&&!4.X.16(4.o("N"))){4.y("Q",17);4.O("29",2a(4.o("1w")));B.1n=B.1n.2b(0,2c)+" - 1D 2d 2e";4.O("2f",B.1n)}}15{4.y("Q",18)}5(4.1t||4.o("Q")||4.X.16(4.o("N"))){7 n=(J a=="2g")?B.1r(a):a;n.2h=4.1y()}15{5(4.o("10")!=""){B.Y.1o(4.o("10"))}}}};8.l.S.1v=t(a,b){7 c=u 8.l.D(0,0,0);5(H.1l&&H.1m.E){7 x=H.1l["2i 1D"];5(x&&x.1E){c=u 8.l.D(x.1E.1o(/([a-z]|[A-Z]|\\s)+/,"").1o(/(\\s+r|\\s+b[0-9]+)/,".").W("."))}}15{1F{7 d=u 1G("19.19");14(7 i=3;d!=1H;i++){d=u 1G("19.19."+i);c=u 8.l.D([i,0,0])}}1I(e){}5(a&&c.C>a.C){m c}5(!a||((a.I!=0||a.1a!=0)&&c.C==a.C)||c.C!=6||b){1F{c=u 8.l.D(d.2j("$N").W(" ")[1].W(","))}1I(e){}}}m c};8.l.D=t(a){4.C=1p(a[0])||0;4.I=1p(a[1])||0;4.1a=1p(a[2])||0};8.l.D.11.16=t(a){5(4.C<a.C){m 18}5(4.C>a.C){m 17}5(4.I<a.I){m 18}5(4.I>a.I){m 17}5(4.1a<a.1a){m 18}m 17};8.l.K={1c:t(a){7 q=B.Y.2k||B.Y.2l;5(q){7 b=q.1b(a+"=");7 c=(q.1b("&",b)>-1)?q.1b("&",b):q.E;5(q.E>1&&b>-1){m q.2m(q.1b("=",b)+1,c)}}m""},2n:t(n){2o(n.2p()){n.2q(n.2r)}}};5(V.11.1k==1H){V.11.1k=t(a){4[4.E]=a;m 4.E}}7 2s=8.l.K.1c;7 T=8.l.T;',62,153,'||||this|if||var|com|||||||||||||deconcept|return||getAttribute|||||function|new||||setAttribute|||document|major|PlayerVersion|length|Object|id|navigator|minor|typeof|util|width|height|version|addVariable|name|doExpressInstall|undefined|FlashObjectUtil|FlashObject|variables|Array|split|installedVer|location||redirectUrl|prototype|param|value|for|else|versionIsValid|true|false|ShockwaveFlash|rev|indexOf|getRequestParameter|params|attributes|swf|addParam|getParams|getVariablePairs|in|push|plugins|mimeTypes|title|replace|parseInt|createElement|getElementById|DETECT_KEY|skipDetect|useExpressInstall|getPlayerVersion|xiRedirectUrl|getVariables|getFlashHTML|MMplayerType|join|flashvars|object|Flash|description|try|ActiveXObject|null|catch|detectflash|toString|bgcolor|high|quality|window|getVariable|createParamTag|PlugIn|embed|type|application|shockwave|flash|src|ActiveX|classid|clsid|D27CDB6E|AE6D|11cf|96B8|444553540000|movie|write|65|MMredirectURL|escape|slice|47|Player|Installation|MMdoctitle|string|innerHTML|Shockwave|GetVariable|search|hash|substring|removeChildren|while|hasChildNodes|removeChild|firstChild|getQueryParamValue'.split('|'),0,{}));
/* END OF FLASH OBJECT */

/* SCROLL TO */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/* END OF SCROLL TO */

/* jQuery TIMERS */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3.I.B({J:6(a,b,c,d,e){j 4.o(6(){3.7.t(4,a,b,c,d,e)})},K:6(a,b,c){j 4.o(6(){3.7.t(4,a,b,c,1)})},L:6(a,b){j 4.o(6(){3.7.m(4,a,b)})}});3.M.N;3.B({7:{u:[],C:1,n:"3.7",D:/^([0-9]+(?:\\.[0-9]*)?)\\s*(.*s)?$/,E:{\'O\':1,\'P\':10,\'Q\':R,\'s\':S,\'T\':U,\'V\':W,\'X\':Y},F:6(a){5(a==Z||a==v)j v;k b=4.D.11(3.12(a.13()));5(b[2]){k c=14(b[1]);k d=4.E[b[2]]||1;j c*d}w{j a}},t:6(a,b,c,d,e,f){k g=0;5(3.15(c)){5(!e)e=d;d=c;c=b}b=3.7.F(b);5(16 b!=\'17\'||18(b)||b<=0)j;5(e&&e.19!=1a){f=!!e;e=0}e=e||0;f=f||x;k h=3.y(a,4.n)||3.y(a,4.n,{});5(!h[c])h[c]={};d.8=d.8||4.C++;k i=6(){5(f&&4.z)j;4.z=1b;5((++g>e&&e!==0)||d.1c(a,g)===x)3.7.m(a,c,d);4.z=x};i.8=d.8;5(!h[c][d.8])h[c][d.8]=p.1d(i,b);4.u.1e(a)},m:6(a,b,c){k d=3.y(a,4.n),l;5(d){5(!b){q(b r d)4.m(a,b,c)}w 5(d[b]){5(c){5(c.8){p.G(d[b][c.8]);A d[b][c.8]}}w{q(k c r d[b]){p.G(d[b][c]);A d[b][c]}}q(l r d[b])H;5(!l){l=v;A d[b]}}q(l r d)H;5(!l)3.1f(a,4.n)}}}});3(p).1g("1h",6(){3.o(3.7.u,6(a,b){3.7.m(b)})});',62,80,'|||jQuery|this|if|function|timer|timerID|||||||||||return|var|ret|remove|dataKey|each|window|for|in||add|global|null|else|false|data|inProgress|delete|extend|guid|regex|powers|timeParse|clearInterval|break|fn|everyTime|oneTime|stopTime|event|special|ms|cs|ds|100|1000|das|10000|hs|100000|ks|1000000|undefined||exec|trim|toString|parseFloat|isFunction|typeof|number|isNaN|constructor|Number|true|call|setInterval|push|removeData|bind|unload'.split('|'),0,{}));
/* END OF TIMERS */

/* jQUERY EASING */
jQuery.easing={easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var a=t-d/2;return-2*c*a*a/(d*d)+2*c*a/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}if(t<d/2)return a*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return a*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}};
/* END OF JQUERY EASING */

/* RATING */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6(V.C)(7($){$.3={D:\'W X\',Y:\'\',h:0,E:16,4:{},8:{s:7(n,a,b,c){5.k(n);$(a).F(\'.o\'+n).G().l(\'Z\'+(c||\'H\'));g d=$(a).p(\'a\');9=d.q();6(b.I)b.I.t($.3.4[n].e[0],[9,d[0]])},k:7(n,a,b){$.3.4[n].e.10(\'.o\'+n).J(\'K\').J(\'11\')},r:7(n,a,b){6(!$($.3.4[n].m).12(\'.D\'))$($.3.4[n].m).F(\'.o\'+n).G().l(\'K\');g c=$(a).p(\'a\');9=c.q();6(b.L)b.L.t($.3.4[n].e[0],[9,c[0]])},u:7(n,a,b){$.3.4[n].m=a;g c=$(a).p(\'a\');9=c.q();$.3.4[n].e.9(9);$.3.8.k(n,a,b);$.3.8.r(n,a,b);6(b.M)b.M.t($.3.4[n].e[0],[9,c[0]])}}};$.N.3=7(d){6(5.O==0)w 5;d=$.P({},$.3,d||{});5.13(7(i){g a=$.P({},d||{},($.Q?$(5).Q():($.14?$(5).15():17))||{});g n=(5.R||\'18-3\').19(/\\[|\\]/,"1a");6(!$.3.4[n])$.3.4[n]={x:0};i=$.3.4[n].x;$.3.4[n].x++;$.3.4[n].j=$.3.4[n].j||a.j||$(5).1b(\'y\');6(i==0){$.3.4[n].e=$(\'<1c 1d="1e" R="\'+n+\'" z=""\'+(a.j?\' y="y"\':\'\')+\'/>\');$(5).1f($.3.4[n].e);6($.3.4[n].j||a.1g){}S{}};f=$(\'<T 1h="1i"><a U="\'+(5.U||5.z)+\'">\'+5.z+\'</a></T>\');$(5).1j(f);6(a.1k)a.h=2;6(1l a.h==\'1m\'&&a.h>0){g b=($.N.A?$(f).A():0)||a.E;g c=(i%a.h),B=1n.1o(b/a.h);$(f).A(B).1p(\'a\').1q({\'1r-1s\':\'-\'+(c*B)+\'1t\'})};$(f).l(\'o\'+n);6($.3.4[n].j)$(f).l(\'1u\');S $(f).l(\'1v\').1w(7(){$.3.8.k(n,5,a);$.3.8.s(n,5,a,\'H\')}).1x(7(){$.3.8.k(n,5,a);$.3.8.r(n,5,a)}).u(7(){$.3.8.u(n,5,a)});6(5.1y)$.3.4[n].m=f;$(5).1z();6(i+1==5.O)$.3.8.r(n,5,a)});1A(n 1B $.3.4)(7(c,v,n){6(!c)w;$.3.8.s(n,c,d||{},\'1C\');$(v).9($(c).p(\'a\').q())})($.3.4[n].m,$.3.4[n].e,n);w 5}})(C);',62,101,'|||rating|groups|this|if|function|event|val|||||valueElem|eStar|var|split||readOnly|drain|addClass|current||star_group_|children|text|reset|fill|apply|click||return|count|disabled|value|width|spw|jQuery|cancel|starWidth|prevAll|andSelf|hover|focus|removeClass|star_on|blur|callback|fn|length|extend|metadata|name|else|div|title|window|Cancel|Rating|cancelValue|star_|siblings|star_hover|is|each|meta|data||null|unnamed|replace|_|attr|input|type|hidden|before|required|class|star|after|half|typeof|number|Math|floor|find|css|margin|left|px|star_readonly|star_live|mouseover|mouseout|checked|remove|for|in|on'.split('|'),0,{}));

/* METADATA */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.i({3:{7:{8:\'j\',9:\'3\',k:/({.*})/,4:\'3\'},s:6(a,b){g.7.8=a;g.7.9=b},l:6(a,b){5 c=$.i({},g.7,b);2(!c.4.n)c.4=\'3\';5 d=$.o(a,c.4);2(d)h d;d="{}";2(c.8=="j"){5 m=c.k.t(a.u);2(m)d=m[1]}p 2(c.8=="v"){2(!a.q)h;5 e=a.q(c.9);2(e.n)d=$.w(e[0].x)}p 2(a.r!=y){5 f=a.r(c.9);2(f)d=f}2(d.z(\'{\')<0)d="{"+d+"}";d=A("("+d+")");$.o(a,c.4,d);h d}}});$.B.3=6(a){h $.3.l(g[0],a)}})(C);',39,39,'||if|metadata|single|var|function|defaults|type|name|||||||this|return|extend|class|cre|get||length|data|else|getElementsByTagName|getAttribute|setType|exec|className|elem|trim|innerHTML|undefined|indexOf|eval|fn|jQuery'.split('|'),0,{}));
/* END OF METADATA */

//rating funtion
$(document).ready(function(){
	tip_html = $('#hover-rating').html();
	$('.hover-star').rating({
		focus: function(value, link){
			var tip = $('#hover-rating');
			if(link.title!=""){ tip.html(link.title);}
		},
		blur: function(value, link){
			var tip = $('#hover-rating');
			$('#hover-rating').html(tip_html);
		},
		callback: function(value, link){
			$("#ratings").fadeOut("slow");
			$.ajax({
				url: url_base+'ajax/rate.php',
				type: 'GET',
				cache: false,
				dataType: 'html',
				data: 'type='+$('#type').val()+'&val='+value+'&id='+$('#fileid').val(),
				success: function(responseText){
					$("#ratings_new").append(responseText);
					$('.hover-stars').rating();
					$("#ratings").hide();
					$("#ratings_new").fadeIn("slow");
				}
			});
		}
	});
	$("#ratings").show();
});
/* END OF RATING */

/* LIGHTBOX */
(function($){
	var opts;

	$.fn.lightbox = function(options){
		// build main options
		opts = $.extend({}, $.fn.lightbox.defaults, options);

		// initalize the lightbox
		$.fn.lightbox.initialize();
		return this.each(function(){
			$(this).click(function(){
				$(this).lightbox.start(this);
				return false;
			});
		});
	};

	// lightbox functions
	$.fn.lightbox.initialize = function(){
		$('#overlay').remove();
		$('#lightbox').remove();
		opts.inprogress = false;
		var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><img src="'+opts.fileLoadingImage+'"></a></div></div></div>';
		var imageData = '<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">'

		if (opts.displayHelp)
			imageData += '<span id="helpDisplay">' + opts.strings.help + '</span>';

		imageData += '<a href="javascript://" id="bottomNavClose" title="' + opts.strings.closeTitle + '"><img src="'+opts.fileBottomNavCloseImage+'"></a></div></div></div>';

		var string;

		if (opts.navbarOnTop) {
		  string = '<div id="overlay"></div><div id="lightbox">' + imageData + outerImage + '</div>';
		  $("body").append(string);
		  $("#imageDataContainer").addClass('ontop');
		} else {
		  string = '<div id="overlay"></div><div id="lightbox">' + outerImage + imageData + '</div>';
		  $("body").append(string);
		}

		$("#overlay").click(function(){ $.fn.lightbox.end(); }).hide();
		$("#lightbox").click(function(){ $.fn.lightbox.end();}).hide();
		$("#loadingLink").click(function(){ $.fn.lightbox.end(); return false;});
		$("#bottomNavClose").click(function(){ $.fn.lightbox.end(); return false; });
		$('#outerImageContainer').width(opts.widthCurrent).height(opts.heightCurrent);
		$('#imageDataContainer').width(opts.widthCurrent);
	};

	$.fn.lightbox.getPageSize = function(){
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight) { // all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth;
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}


		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = xScroll;
		} else {
			pageWidth = windowWidth;
		}

		var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};


	$.fn.lightbox.getPageScroll = function(){
		var xScroll, yScroll;

		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;
		}

		var arrayPageScroll = new Array(xScroll,yScroll);
		return arrayPageScroll;
	};

	$.fn.lightbox.pause = function(ms){
		var date = new Date();
		var curDate = null;
		do{curDate = new Date();}
		while( curDate - date < ms);
	};

	$.fn.lightbox.start = function(imageLink){

		$("select, embed, object").hide();
		var arrayPageSize = $.fn.lightbox.getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : opts.overlayOpacity}).fadeIn();
		opts.imageArray = [];
		imageNum = 0;

		var anchors = document.getElementsByTagName( imageLink.tagName);

		// if image is NOT part of a set..
		if(!imageLink.rel || (imageLink.rel == '')){
			// add single image to Lightbox.imageArray
			opts.imageArray.push(new Array(imageLink.href, opts.displayTitle ? imageLink.title : ''));
		} else {
		// if image is part of a set..
			$("a").each(function(){
				if(this.href && (this.rel == imageLink.rel)){
					opts.imageArray.push(new Array(this.href, opts.displayTitle ? this.title : ''));
				}
			})


			for(i = 0; i < opts.imageArray.length; i++){
				for(j = opts.imageArray.length-1; j>i; j--){
					if(opts.imageArray[i][0] == opts.imageArray[j][0]){
						opts.imageArray.splice(j,1);
					}
				}
			}
			while(opts.imageArray[imageNum][0] != imageLink.href) { imageNum++;}
		}

		// calculate top and left offset for the lightbox
		var arrayPageScroll = $.fn.lightbox.getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		$('#lightbox').css({top: lightboxTop+'px', left: lightboxLeft+'px'}).show();


		if (!opts.slideNavBar)
			$('#imageData').hide();

		$.fn.lightbox.changeImage(imageNum);

	};

	$.fn.lightbox.changeImage = function(imageNum){
		if(opts.inprogress == false){
			opts.inprogress = true;
			opts.activeImage = imageNum;	// update global var

			// hide elements during transition
			$('#loading').show();
			$('#lightboxImage').hide();
			$('#hoverNav').hide();
			$('#prevLink').hide();
			$('#nextLink').hide();

			if (opts.slideNavBar) { // delay preloading image until navbar will slide up
				// $('#imageDataContainer').slideUp(opts.navBarSlideSpeed, $.fn.doChangeImage);
				$('#imageDataContainer').hide();
				$('#imageData').hide();
				$.fn.doChangeImage();
			} else {
			    $.fn.doChangeImage();
			}
		}
	};

	$.fn.doChangeImage = function(){

		imgPreloader = new Image();

		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
		    var newWidth = imgPreloader.width;
		    var newHeight = imgPreloader.height;


			if (opts.fitToScreen) {
		        var arrayPageSize = $.fn.lightbox.getPageSize();
				var ratio;
				var initialPageWidth = arrayPageSize[2] - 2 * opts.borderSize;
				var initialPageHeight = arrayPageSize[3] - 200;

				if (imgPreloader.height > initialPageHeight)
				{
					newWidth = parseInt((initialPageHeight/imgPreloader.height) * imgPreloader.width);
					newHeight = initialPageHeight;
				}
				else if (imgPreloader.width > initialPageWidth)
				{
					newHeight = parseInt((initialPageWidth/imgPreloader.width) * imgPreloader.height);
					newWidth = initialPageWidth;
				}
			}

			$('#lightboxImage').attr('src', opts.imageArray[opts.activeImage][0])
							   .width(newWidth).height(newHeight);
			$.fn.lightbox.resizeImageContainer(newWidth, newHeight);
		}

		imgPreloader.src = opts.imageArray[opts.activeImage][0];
	}
	
	$.fn.lightbox.end = function(){
		$.fn.lightbox.disableKeyboardNav();
		$('#lightbox').hide();
		$('#overlay').fadeOut();
		$('select, object, embed').show();
	};

	$.fn.lightbox.preloadNeighborImages = function(){
		if((opts.imageArray.length - 1) > opts.activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = opts.imageArray[opts.activeImage + 1][0];
		}
		if(opts.activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = opts.imageArray[opts.activeImage - 1][0];
		}
	};

	$.fn.lightbox.keyboardAction = function(e){
		if (e == null) { // ie
			var keycode = event.keyCode;
			var escapeKey = 27;
		} else { // mozilla
			var keycode = e.keyCode;
			var escapeKey = e.DOM_VK_ESCAPE;
		}

		var key = String.fromCharCode(keycode).toLowerCase();

		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){ // close lightbox
			$.fn.lightbox.end();
		} else if((key == 'p') || (keycode == 37)){ // display previous image
			if(opts.activeImage != 0){
				$.fn.lightbox.disableKeyboardNav();
				$.fn.lightbox.changeImage(opts.activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){ // display next image
			if(opts.activeImage != (opts.imageArray.length - 1)){
				$.fn.lightbox.disableKeyboardNav();
				$.fn.lightbox.changeImage(opts.activeImage + 1);
			}
		}
	};

	$.fn.lightbox.resizeImageContainer = function(imgWidth, imgHeight){
		// get current width and height
		opts.widthCurrent = document.getElementById('outerImageContainer').offsetWidth;
		opts.heightCurrent = document.getElementById('outerImageContainer').offsetHeight;

		// get new width and height
		var widthNew = (imgWidth  + (opts.borderSize * 2));
		var heightNew = (imgHeight  + (opts.borderSize * 2));

		// scalars based on change from old to new
		opts.xScale = ( widthNew / opts.widthCurrent) * 100;
		opts.yScale = ( heightNew / opts.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = opts.widthCurrent - widthNew;
		hDiff = opts.heightCurrent - heightNew;

		$('#imageDataContainer').animate({width: widthNew},opts.resizeSpeed,'linear');
		$('#outerImageContainer').animate({width: widthNew},opts.resizeSpeed,'linear',function(){
			$('#outerImageContainer').animate({height: heightNew},opts.resizeSpeed,'linear',function(){
				$.fn.lightbox.showImage();
			});
		});


		// if new and old image are same size and no scaling transition is necessary,
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (jQuery.browser.msie){ $.fn.lightbox.pause(250); } else { $.fn.lightbox.pause(100);}
		}

		$('#prevLink').height(imgHeight);
		$('#nextLink').height(imgHeight);
	};

	$.fn.lightbox.showImage = function(){
		$('#loading').hide();
		$('#lightboxImage').fadeIn("fast");
		$.fn.lightbox.updateDetails();
		$.fn.lightbox.preloadNeighborImages();

		opts.inprogress = false;
	};

	$.fn.lightbox.updateDetails = function(){

		if(opts.imageArray[opts.activeImage][1]){
			$('#caption').html(opts.imageArray[opts.activeImage][1]).show();
		}

		// if image is part of set display 'Image x of x'
		if(opts.imageArray.length > 1){
			var nav_html;

			nav_html = opts.strings.image + (opts.activeImage + 1) + opts.strings.of + opts.imageArray.length;

			// display previous / next text links
			if ((opts.activeImage) > 0) {
				nav_html = '<a title="' + opts.strings.prevLinkTitle + '" href="#" id="prevLinkText">' + opts.strings.prevLinkText + "</a>" + nav_html;
			}

			if ((opts.activeImage + 1) < opts.imageArray.length) {
				nav_html += '<a title="' + opts.strings.nextLinkTitle + '" href="#" id="nextLinkText">' + opts.strings.nextLinkText + "</a>";
			}

			$('#numberDisplay').html(nav_html).show();
		}

		if (opts.slideNavBar) {
		    $("#imageData").slideDown(opts.navBarSlideSpeed);
		} else {
			$("#imageData").show();
		}

		var arrayPageSize = $.fn.lightbox.getPageSize();
		$('#overlay').height(arrayPageSize[1]);
		$.fn.lightbox.updateNav();
	};

	$.fn.lightbox.updateNav = function(){
		$('#hoverNav').show();

		// if not first image in set, display prev image button
		if(opts.activeImage != 0){
			$('#prevLink,#prevLinkText').show().click(function(){
				$.fn.lightbox.changeImage(opts.activeImage - 1); return false;
			});
		}

		// if not last image in set, display next image button
		if(opts.activeImage != (opts.imageArray.length - 1)){
			$('#nextLink,#nextLinkText').show().click(function(){

				$.fn.lightbox.changeImage(opts.activeImage +1); return false;
			});
		}

		$.fn.lightbox.enableKeyboardNav();
	};


	$.fn.lightbox.enableKeyboardNav = function(){
		document.onkeydown = $.fn.lightbox.keyboardAction;
	};

	$.fn.lightbox.disableKeyboardNav = function(){
		document.onkeydown = '';
	};

	$.fn.lightbox.defaults = {
		fileLoadingImage : url_base+'css/images/loading.gif',
		fileBottomNavCloseImage : url_base+'css/images/closelabel.gif',
		overlayOpacity : 0.8,
		borderSize : 10,
		imageArray : new Array,
		activeImage : null,
		inprogress : false,
		resizeSpeed : 350,
		widthCurrent: 250,
		heightCurrent: 250,
		xScale : 1,
		yScale : 1,
		displayTitle: true,
		navbarOnTop: false,
		slideNavBar: false, // slide nav bar up/down between image resizing transitions
		navBarSlideSpeed: 350,
		displayHelp: false,
		strings : {
			help: ' \u2190 / P - previous image\u00a0\u00a0\u00a0\u00a0\u2192 / N - next image\u00a0\u00a0\u00a0\u00a0ESC / X - close image gallery',
			prevLinkTitle: var_prevLinkTitle,
			nextLinkTitle: var_nextLinkTitle,
			prevLinkText:  var_prevLinkText,
			nextLinkText:  var_nextLinkText,
			closeTitle: var_closeTitle,
			image: var_image,
			of: var_of
		},
		fitToScreen: false		// resize images if they are bigger than window
	};
})(jQuery);
/* END OF LIGHTBOX */

$(document).ready(function(){
	$(".lightbox").lightbox();

	// menu
	/*
	$("ul.menu li").bind('click', function(){
		$id = $(this).find('a').attr('id');
		$("ul.menu li.current").removeClass('current');
		$(this).addClass('current');
		if($id!="showlogin" && $id!=""){
			$submenu_opened = $('div.submenu div.'+ $id +':visible').size();
			
			if( $submenu_opened ){
				$('div.submenu').hide();
				$('div.submenu div.'+ $id).hide();
			} else {
				$('div.submenu').show();
				$('div.submenu div:visible').hide();
				$('div.submenu div.'+ $id).show();
			}
		}
	});
	*/
	
	// login
	$('a#showlogin').bind('click', function(){
		$('div.submenu').hide();
		$('ul.menu li').removeClass('current');
		$(this).parent().addClass('current');
		if( $('div.menubox div#search:visible').size() ){
			$('div.menubox div#search').css({ 'display': 'none'});
			$('div.menubox div#login').css({ 'display': 'block'});
		} else {
			$('div.menubox div#login').css({ 'display': 'none'});
			$('div.menubox div#search').css({ 'display': 'block'});
		}
	});
	$('a#showlogin_footer').bind('click', function(){
		$('div.submenu').hide();
		$('ul.menu li').removeClass('current');
		$('a#showlogin').parent().addClass('current');
		if( $('div.menubox div#search:visible').size() ){
			$('div.menubox div#search').css({ 'display': 'none'});
			$('div.menubox div#login').css({ 'display': 'block'});
		} else {
			$('div.menubox div#login').css({ 'display': 'none'});
			$('div.menubox div#search').css({ 'display': 'block'});
		}
		$.scrollTo(0,500);
	});
	
	// scroll
	$index=0;
	$('ul.smallpreview li:first img').addClass('selected');
	$('ul.smallpreview li').bind('click', function(){
		$index = $('ul.smallpreview li').index(this);
		
		$(this).parent().find('img.selected').removeClass('selected');
		$(this).find('img').addClass('selected');
		
		$('div.scroller div.preview').scrollTo( $('ul.bigpreview li:eq('+$index+')'), 500 );
	});

	// auto scroll
	$(document).everyTime(5000, function() {
		if( $index==$('ul.smallpreview li').size() ){
			$index=0;
		} else {
			$('ul.smallpreview li:eq('+  $index  +')').trigger('click');
			$index++;
		}
	});
	
	//recent-audio hover
	$('ul.recent-audio li').bind('mouseover mouseout', function(){
		$(this).toggleClass('hover');
	});
	
	//recent audio
	$('div.box.music a.go-down').bind('click', function(){
		$('div.box.music div.preview').scrollTo({ top:'+=216px', left:'' }, 400 );
	});
	$('div.box.music a.go-up').bind('click', function(){
		$('div.box.music div.preview').scrollTo({ top:'-=216px', left:'' }, 400 );
	});
	
	
	$('.scroll-up').bind('click', function(){
		if( $.browser.msie ) {
			$('.scroll').scrollTo( '-=280px', 400 );
		} else {
			$('.scroll').scrollTo( '-=280px', 400 );
		}
	});
	$('.scroll-down').bind('click', function(){
		if( $.browser.msie ) {
			$('.scroll').scrollTo( '+=280px', 400 );
		} else {
			$('.scroll').scrollTo( '+=280px', 400 );
		}
	});
	
});
