// JavaScript Document
function filter_vd(value){
	document.getElementById("product_layout").innerHTML = "<iframe src='video_analys?album="+value+"' style='width: 560px; height: 800px; overflow: hidden;'></iframe>";		
	}
	
function load_filter_foto_panel(){
	YAHOO.namespace("foto_filt");
	
	YAHOO.foto_filt.panel1 = new YAHOO.widget.Panel("foto_filter_wnd", { width:"400px",xy:[5,150], visible:true, close:false } );
	YAHOO.foto_filt.panel1.render();
		if(per_fotos == ''){
			document.getElementById('show_x').value = '50';
		}
		if(alb_filt == ''){
			document.getElementById('alb_filter').value = '56';
		}
}

function show_users(s_box){
	var sel_box = document.getElementById(s_box);
	var users= document.getElementById('select_user');

	if(sel_box.checked){
		users.style.display = 'block'; 
	}
	else{
		users.style.display = 'none';
	}
};
// Valdimarus //////////   foto_analys functions /// 

function get_albums_values(obj){
	alb_filt = '';
	var i;
	for(i=0;i< obj.options.length;i++){
		if(obj.options[i].selected == true){
			alb_filt +=obj.options[i].value + "---";
		}
	}
	
	/*for(opt in obj.options){
		if(obj.options[opt].selected == true){
			//alert(tag_filter[k_tag]);
			alb_filt += obj.options[opt].value + "---";
		}
	}*/
	
	//alert(alb_filt);
	filter_fotos(alb_filt, 2, 'alboms')
}

function get_albums_values_geo(obj){
	alb_filt = '';
	var i;
	for(i=0;i< obj.options.length;i++){
		if(obj.options[i].selected == true){
			alb_filt +=obj.options[i].value + "---";
		}
	}
	
	/*for(opt in obj.options){
		if(obj.options[opt].selected == true){
			//alert(tag_filter[k_tag]);
			alb_filt += obj.options[opt].value + "---";
		}
	}*/
	
	//alert(alb_filt);
	filter_fotos(alb_filt, 0, 'alboms')
}


function hide_show(){
	var but = document.getElementById('hide_show');
	var wnd = document.getElementById('foto_filter_body');
	var und = document.getElementById('underlay');
	if(wnd.style.display!='none'){
		wnd.style.display = 'none';
		but.className='maximized';
		und.style.display = 'none';
	}
	else{
		wnd.style.display = 'block';
		but.className='minimized';
		//und.style.display = 'block';
	}
}


function show_small_foto(dateCreateFoto, description, imageUrl, albom, user_name, albumDescr, url, id,num){
	
	imageUrl = "http://"+main_domen+"/pic_resize.php?src="+imageUrl;
	title=""; 
	
	dateCreateFoto = dateCreateFoto.substr( 0, dateCreateFoto.indexOf(' '));
	
	var text = ""+
	"<div id=\"haha\" class=\"people_small_photo\">"+
		"<div class=\"ptitle\">"+
			"<h4>"+
				dateCreateFoto + ' - ' + albom +
				"<span><b>Author: </b>" +
					user_name +
				"</span>" +
			"</h4>"+
		"</div>"+
		//"<div class=\"titlesmy\" style=\"padding: 2px;\">&nbsp;&nbsp;"+dateCreateFoto+"&nbsp;"+albom+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author:&nbsp;"+user_name+"&nbsp;</div>"+
		"<div class='container' style=\"display:block\">"+
			"<img src='"+imageUrl+"' />"+
		"</div>"+
	"</div>";
	
	
//	text = '<span id="haha">123</span>';

//text = "<table id=haha cellspacing=0 cellpadding=0 class='hint'><tr><td class='top'><table cellspacing=0 cellpadding=0 class='bottom' style=\"margin-top: 2px; margin-right: 6px;	margin-bottom: 2px;	margin-left: 6px;\" align='center'><tr><td align='left'><b>Date created:</b></td><td align='left'><b>"+dateCreateFoto+"</b></td></tr><tr><td align='left'><b>Author:</b></td><td align='left'><b>"+user_name+"</b></td></tr><tr><td align='left'><b>Albom:</b></td><td align='left'><b>"+albom+"</b></td></tr><tr><td class='right' colspan='2'><img src='"+imageUrl+"' border='0'></td></tr></table></td></tr></table>";	
   	
	dtc(1,text,title);
}

function getNeighbourImg(curr, dir){
	dir = (dir == -1 )?'prev':'next';
	jQuery.ajax(
	{
		type: "GET",
		url: "/foto_analys/usr/extensions/getQueuedImage.php",
		data: "curr="+curr+"&type="+dir,
		success: function( o ) {
			var resp = eval ( '(' + o + ')' );
			if (resp.length == 0){
				alert('No more images');
				return;
			}
			show_orig_foto(resp.date_create, resp.description, resp.scr, resp.name_albom, resp.fullName, resp.descr, resp.src, resp.id, resp.num );
		}
	});
}

function show_orig_foto(dateCreateFoto, description, imageUrl, albom, user_name, albumDescr, url, id,num){
	
	div_wnd = document.getElementById('win_full');
	div_cont = document.getElementById('prv_content');
	preload = document.getElementById('img_preload');
	info = document.getElementById('img_info');
	//text = "<div class=\"modal-window\" style=\"top:52px; left:104px; width:466px\"><div class=\"title\"><h4>"+dateCreateFoto+"<span><b>Author:"+user_name+"</b><b>Albom:"+albom+"</b></span></h4></div></div>";
	text = ""+
	"<div class=\"modal\" style=\"position: static\">"+
		"<div class=\"title\" style=\"margin: 0px;\">"+
			"<h4 style='text-align: left'>"+dateCreateFoto+"&nbsp;&nbsp;"+albom+"<span><b>Author:"+user_name+"</b></span></h4>"+
		"</div>"+
	"</div>";
	
    info.innerHTML = text;
	if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)|| (navigator.userAgent.indexOf('MSIE 7') > 0)) {
	
	}
	else{
		img_f = document.getElementById('img_f');
	}
	
	
	// reset wnd css to defaults
	

	
	img_cont = document.getElementById('img_full');
	
	w = getWindowSize();
	w.width = getClientWidth();
	
//	div_cont.style.width  = '100px';
//	div_cont.style.height = '60px';
	
	jQuery('#img_f').attr('src', '');
	
	jQuery(div_wnd).css({'width': 600, 'left': (w.width - 600) / 2 }).show();
	
	var www = 0;
	
	if(div_wnd.name=="geomap")
		www = -48;
	else{
		www = (w.width - div_wnd.clientWidth) / 2;
	}
	
	//div_wnd.style.left = www + 'px';
	
	var o_left = www;
	var o_width = div_wnd.clientWidth;
	var o_height = div_wnd
	
	
	img_cont.style.display = 'none';
	preload.style.display = 'block';
	
	imgPreloader = new Image();
	imgPreloader.onload=function(){
			w = getWindowSize();
			w.width  = getClientWidth()
			preload.style.display = 'none';
			img_f.src = imageUrl;
			var n_width = 0,
				n_height = 0,
				n_left = 0;
			
			if(imgPreloader.width + 20 >= w.width ){
				n_width = w.width;
			}
			else{
				n_width = imgPreloader.width + 20;
			}
			
			if(div_wnd.name=="geomap")
					n_left = -48;
			else{
				n_left = (w.width - n_width)/2;
			}
			
			//div_wnd.style.left =  n_left + 'px';
			//div_wnd.style.width = (n_width) + 'px';
			
			jQuery(div_wnd).animate({
				'left': n_left,
				'width': n_width 
			});
			
			jQuery('#img_full').css('width', n_width - 20);
			
			img_cont.style.display = 'block';
			
			
			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 

			var container = jQuery('#prv_content');
			if (!jQuery('#prv_content>#navMask')[0]){
				container.append('<div id="navMask" style="position:absolute; bottom:30px; left:20px;" ></div>');
			}
			var navMask = jQuery('#prv_content>#navMask');
			navMask.html('<img style="cursor:pointer" onclick="close_orig_foto(); getNeighbourImg(\''+this.src+'\', -1)" src="/prev.png" />'+'<img style="cursor:pointer" onclick="close_orig_foto(); getNeighbourImg(\''+this.src+'\', +1)" src="/next.png"/>');
		}
	imgPreloader.src = imageUrl;
}

function close_orig_foto(){
	
	div_wnd = document.getElementById('win_full');
	//div_cont = document.getElementById('prv_content');
	preload = document.getElementById('img_preload');
	info = document.getElementById('img_info');
	info.innerHTML = '';
	preload.style.display = 'block';
	div_wnd.style.display = 'none';
}

// end ////////////////////////////////////////////

