$(window).load(function () {

	// info text
	infoBlock();

	// comenzi
	$('.linkCmd').hover(
		function() {
			$(this).parent().find('ul').show();
		},
		function() {
			$(this).parent().find('ul').hide();
		}
	);

	// fancybox
	$("a.fancyAjax").fancybox({
		frameWidth: 400,
		frameHeight: 400,
		hideOnContentClick: false
	});
	$('a.new').click(function(){
		$(this).removeClass('new');
	});
	$("a.view").fancybox();

});

function infoBlock() {

	var w = $(document).width();
	var h = $('body').height() < $(document).height() ? $(document).height() : $('body').height();

	$('.infoblock').css({
		width: w,
		height: h
	});

	var l = (parseInt(w)-300)/2;

	$('.infoblock_block').css({
		left: l+'px'
	});

}

function prgBlock() {

	var w = $(document).width();
	var h = $('body').height() < $(document).height() ? $(document).height() : $('body').height();

	$('#progress').css({
		width: w,
		height: h
	});

	var l = (parseInt(w)-300)/2;

	$('#progress_block').css({
		left: l+'px'
	});

}

function login() {

	var user = $("input[name=l_user]").val();
	var pass = $("input[name=l_pass]").val();

	$('.infoblock').show();
	$.post('ajax.php?a=login',
		{
			user: user,
			pass: pass
		},function(data) {

			if(data.length>0) {
				$('.infoblock_div').html(data);
				$('.infoblock_parent').fadeIn('slow');

				setTimeout(function(){
					$('.infoblock').fadeOut('slow',function(){
						$('.infoblock_div').html('');
						$('.infoblock_parent').hide();
					});
				},3000);
			} else {
				window.location.reload();
			}

		}
	);

}

function setariGenerale(){

	if($('#flashUploadList').children().size()<=0 && $('#UploadList').children().size()<=0) alert('Nu aveti fotografii adaugate.');
	else {

		var sg_buc = $('#sg_buc').val();
		var sg_mar = $('#sg_mar').val();
		var sg_hrt = $('#sg_hrt').val();

		if($('input[name=chkbox]:checked').size() > 0) {

			$('input[name=chkbox]:checked').each(function(){

				$('#'+$(this).val()+' input[name="opt_buc[]"]').val(sg_buc);
				$('#'+$(this).val()+' select[name="opt_mar[]"]').val(sg_mar);
				$('#'+$(this).val()+' select[name="opt_hrt[]"]').val(sg_hrt);

			});

		} else {

			$('input[name="opt_buc[]"]').val(sg_buc);
			$('select[name="opt_mar[]"]').val(sg_mar);
			$('select[name="opt_hrt[]"]').val(sg_hrt);

		}

	}

}

// flash check
function getFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}
var FlvVer = getFlashVersion().split(',').shift();
