
var cur_file=window.location.href;
cur_file=cur_file.replace(/#(.*)/,"")+"#videos";

function get_the_image(imid,extra_url){
  
  
  	
  __$.ajax({
  url: "videos/?a=1&id="+imid+extra_url,
  cache: false,
  beforeSend: function (req){
  	 
	show_loader(); 
	
	return req;
  },
  complete: function (req,status){
  	
	
	return req;
  },
  success: function(html){
    __$("#ajx_resp").html(html);
	
	imgid=__$("#avideo_id").html();
	imgurl=__$("#avideo_own_url").html();
	
	if (__$("#avideo_anonymous").html()!="yes"){
		__$("#video_user").html("<a href='http://www.danzarinas.com/" + __$("#avideo_user").html()+"'>"+__$("#avideo_user").html()+"</a>");
	}else{
		__$("#video_user").html(__$("#avideo_user").html());
	}

	
	im_lnk=__$("#avideo_url").html();
	im_ttl=__$("#avideo_url_title").html();
	
	__$("#video_url").html(im_ttl);
	__$("#video_url").attr({href:__$("#avideo_url").html(), title:  im_ttl});

	im_ttl=__$("#avideo_text_title").html();
	
	if (im_ttl){
		__$("#video_title").html(im_ttl);
		__$("#video_title").show();
	}else{
		__$("#video_title").hide();
	}
	
	if (!im_lnk || im_lnk=="#"){
		__$("#video_url_p").hide();
	}else{
		__$("#video_url_p").show();
	}
	__$("#video_comments").html(__$("#avideo_comments").html());
	__$("#video_visits").html(__$("#avideo_visits").html());
	__$("#video_date").html(__$("#avideo_date").html());

	__$("#video_desc").html(__$("#avideo_desc").html());
	
	__$("#galeria-imagen").html(__$("#avideo_video_obj").html());
	
	__$("#comment_section").html(__$("#avideo_comment").html());

	__$("#form_img_id").attr({ value: imgid });

	__$(".img_pagin_class").removeClass("img_pagin_class");
	__$(".img_pagin_class").addClass("img_pagin_class");
	
	__$("#img_pagin_num_"+imgid).removeClass("img_pagin_class img_selected");
	__$("#img_pagin_num_"+imgid).addClass("img_pagin_class img_selected");


	
	
	__$("#commsg").html("");
	window.location=cur_file;
	__$("#ajx_resp").html("");
	hide_loader();
  }
  });

}

function get_the_page(pid,extra_url){
	
  __$.ajax({
  url: "videos/?a=1&pi="+pid+extra_url,
  cache: false,
  beforeSend: function (req){

	show_loader(); 
	
	return req;
  },
  complete: function (req,status){

	return req;
  },  
  success: function(html){

	__$("#ajx_resp").html(html);

	
	__$("#galeria-imagenes-izq").html(  __$("#ajx-galeria-imagenes-izq").html()  );
	__$("#galeria-imagenes-der").html(  __$("#ajx-galeria-imagenes-der").html() );
	__$("#paging_div").html(  __$("#ajx-paging_div").html()  );

	__$("#form_page").attr({value:__$("#cur_page").html()});	
	
	hide_loader();
	
	
	if (__$("#ajx-dir").html()  == "r" ){

		__$("#galeria-med2").html(  __$("#ajx-galeria-med").html()  );
		__$("#galeria-med1").animate ({left:"-880px"},1500);
		__$("#galeria-med0").animate ({left:"-880px"},1500);


		__$("#galeria-med2").animate ({left:"0px"},1500,"swing", function() { __$("#galeria-med1").attr({ id: "temp_galeria-med1" } ); __$("#galeria-med2").attr({ id: "galeria-med1" } ); __$("#temp_galeria-med1").attr({ id: "galeria-med2" } );  __$("#galeria-med2").css({ left: "880px" } );	});		
		

	}else{
		__$("#galeria-med0").html(  __$("#ajx-galeria-med").html()  );
		__$("#galeria-med1").animate ({left:"880px"},1500);
		__$("#galeria-med2").animate ({left:"880px"},1500);
		
		__$("#galeria-med0").animate ({left:"0px"},1500,"swing", function() { __$("#galeria-med1").attr({ id: "temp_galeria-med1" } ); __$("#galeria-med0").attr({ id: "galeria-med1" } ); __$("#temp_galeria-med1").attr({ id: "galeria-med0" } ); __$("#galeria-med0").css({ left: "-880px" } );	});
		
		

	}
	__$(".img_pagin_class").removeClass("img_pagin_class");
	__$(".img_pagin_class").addClass("img_pagin_class");

	__$("#img_pagin_num_"+imgid).removeClass("img_pagin_class img_selected");
	__$("#img_pagin_num_"+imgid).addClass("img_pagin_class img_selected");

 	__$("#ajx_resp").html(""); 
	
  }
  });

}

function show_loader(){
	
	__$('body').append("<div id='ajax_loader_wait'></div>");

}

function hide_loader(){
	__$('#ajax_loader_wait').remove();
}

function album_sel(alb_id){

	__$(".album_lnk").removeClass("album_lnk");
	__$(".album_lnk").addClass("album_lnk");
	
	__$("#album_lnk_"+alb_id).removeClass("album_lnk selected_album");
	__$("#album_lnk_"+alb_id).addClass("album_lnk selected_album");
	
}

 function prompt_exact_login(){
 	if (!imgurl){
		return login_window();
	}else{
		return login_window_url("/"+imgurl+"#videos");
	}
	
 }
 
 var __$ = jQuery.noConflict();
 

 
 
