function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
function refobj(object)
{
	if (document.getElementById)
	{   
	    if (document.getElementById(object))
	    {
		    return document.getElementById(object);
		} else {
		    return false;
		}
	}
	else if (document.all)
	{
		return eval('document.all.' + object);
	}
	else if (document.layers)
	{
		return eval('document.layers[' + object+']');
	}
	else
	{
		return false;
	}
}

function toggle(object)
{
	object = refobj(object);
	if ( !object.style )
	{
		return false;
	}
	
	if( object.style.display == 'none' )
	{
		object.style.display = '';
	}
	else
	{
		object.style.display = 'none';
	}
}

function toggle_hide(object)
{
	object = refobj(object);
	if ( !object.style )
	{
		return false;
	}
	//setTimeout("object.style.display = none", 1);
	object.style.display = 'none';
}

function hide(object)
{
	object = refobj(object);
	object.style.display = 'none';
}

function toggle_show(object)
{
	object = refobj(object);
	if ( !object.style )
	{
		return false;
	}
	
	object.style.display = '';
	
}


function toggle2(object, aTag)
{
	object = refobj(object);
	if ( !object.style )
	{
		return false;
	}
	
	if( object.style.display == 'none' )
	{
		object.style.display = '';
	}
	else
	{
		object.style.display = 'none';
	}
	if( aTag.style.backgroundImage == 'none' )
	{
		aTag.style.backgroundImage = 'url(images/bg-red-act.gif)';
		aTag.style.backgroundRepeat = 'no-repeat';
		aTag.style.backgroundPosition = '0px 7px';
		aTag.style.color = '#D6A19F';
		aTag.style.textDecoration = 'none';
	}
	else
	{
		aTag.style.backgroundImage = 'none';
		aTag.style.color = '#FFF';
		aTag.style.textDecoration = 'underline';
	}
}

function toggle3(object, object2)
{
	object = refobj(object);
	object2 = refobj(object2);
	if ( !object.style )
	{
		return false;
	}
	
	if( object.style.display == 'none' )
	{
		object.style.display = '';
		object2.style.display = 'none';
	}
	else
	{
		object.style.display = 'none';
		object2.style.display = '';
	}

var height = $(".MyHeight").height();
$(".transparentBG").css("height",height+20);
	
}


jQuery(document).ready(
  function() {



var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}



  
	jQuery(".BlockDiv").click(function(){
		jQuery(".BlockDiv").css("display","none");	
		jQuery(".LoaderDiv").css("display","none");	
		jQuery(".LoadFile").css("display","none");	
		jQuery(".FileAddRezult").css("display","none");	
		jQuery(".CommentList").css("display","none");	
		
		jQuery(".SendFriend").css("display","none");	
		jQuery(".HideDiv").css("display","block");	
		jQuery("#SendCommentButton").unbind("click");
	})


if(document.getElementById("MyHeight")){	
	var height = jQuery(".MyHeight").height();
	$(".transparentBG").css("height",height+20);
}


	
	var options = {
	  beforeSubmit:function(form_data){
		var load_file_name = document.getElementById("load_file_name").value;
		var load_file_mail = document.getElementById("load_file_mail").value;
		var load_file_title = document.getElementById("load_file_title").value;
		var load_file_describe = document.getElementById("load_file_describe").value;
		var load_file_code = document.getElementById("load_file_code").value;
		var error_code = 0;
		//провери ввёл ли пользователь своё имя
		if(load_file_name.length == 0){
			error_code = 1;
			jQuery("#load_file_name").css("border","1px solid red");
		}else{
			jQuery("#load_file_name").css("border-top","1px solid #a4836b");
			jQuery("#load_file_name").css("border-left","1px solid #c9b6a8");
			jQuery("#load_file_name").css("border-right","none");
			jQuery("#load_file_name").css("border-bottom","none");

		}
		//провери ввёл ли пользователь mail
		if(load_file_mail.length == 0){
			error_code = 1;
			jQuery("#load_file_mail").css("border","1px solid red");
		}else{
			jQuery("#load_file_mail").css("border-top","1px solid #a4836b");
			jQuery("#load_file_mail").css("border-left","1px solid #c9b6a8");
			jQuery("#load_file_mail").css("border-right","none");
			jQuery("#load_file_mail").css("border-bottom","none");

		}
		
		//провери ввёл ли пользователь заголовок
		if(load_file_title.length == 0){
			error_code = 1;
			jQuery("#load_file_title").css("border","1px solid red");
		}else{
			jQuery("#load_file_title").css("border-top","1px solid #a4836b");
			jQuery("#load_file_title").css("border-left","1px solid #c9b6a8");
			jQuery("#load_file_title").css("border-right","none");
			jQuery("#load_file_title").css("border-bottom","none");
		}		
		//провери ввёл ли пользователь описание
		if(load_file_describe.length == 0){
			error_code = 1;
			jQuery("#load_file_describe").css("border","1px solid red");
		}else{
			jQuery("#load_file_describe").css("border-top","1px solid #a4836b");
			jQuery("#load_file_describe").css("border-left","1px solid #c9b6a8");
			jQuery("#load_file_describe").css("border-right","none");
			jQuery("#load_file_describe").css("border-bottom","none");
		}		
		//провери ввёл ли пользователь защитный код
		if(load_file_code.length == 0){
			error_code = 1;
			jQuery("#load_file_code").css("border","1px solid red");
		}else{
			jQuery("#load_file_code").css("border-top","1px solid #a4836b");
			jQuery("#load_file_code").css("border-left","1px solid #c9b6a8");
			jQuery("#load_file_code").css("border-right","none");
			jQuery("#load_file_code").css("border-bottom","none");
		}				
		
		if(error_code > 0){
			return false;
		}else{
			jQuery("#FileAddRezultText").html("Пожалуйста,подождите, идёт загрузка фото ...");
			FileAddRezult();
		}
		
	  },
	  success: function(data) {
	        if(data == 'secure_error'){
				error_code = 1;
				jQuery("#load_file_code").css("border","1px solid red");			
			}else{
				jQuery("#load_file_code").css("border-top","1px solid #a4836b");
				jQuery("#load_file_code").css("border-left","1px solid #c9b6a8");
				jQuery("#load_file_code").css("border-right","none");
				jQuery("#load_file_code").css("border-bottom","none");			
			}
			if(data == "ok"){
				jQuery("#FileAddRezultText").html("Ваша фотография добавлена для конкурса. После модерации она появится на сайте");
			}else{
				jQuery("#FileAddRezultText").html("Произошла ошибка. Попробуйте перезагрузить фотографию позже. В случае неудачи свяжитесь с администратором сайта.");			
			}
			FileAddRezult();

	  }
	}; 	
	
   $("#LoadFile").ajaxForm(options);	
	
  });
	
function ViewWindowLoadFile(){
	jQuery(".BlockDiv").css("height",jQuery(document).height());
	jQuery(".BlockDiv").css("width",jQuery(document).width()-2);

	jQuery(".BlockDiv").css("top","0");
	jQuery(".BlockDiv").css("left","0");
	jQuery(".BlockDiv").css("display","block");
	
	var top = jQuery(window).height()/2 - 250+jQuery(window).scrollTop();
	var left = jQuery(window).width()/2 - 250;

	jQuery(".LoadFile").css("top",top);
	jQuery(".LoadFile").css("left",left);	
	jQuery(".LoadFile").css("display","block");

}

function FileAddRezult(){
	jQuery(".LoadFile").css("display","none");
	
	var top = jQuery(window).height()/2 - 250+jQuery(window).scrollTop();
	var left = jQuery(window).width()/2 - 250;

	jQuery(".FileAddRezult").css("top",top);
	jQuery(".FileAddRezult").css("left",left);	
	jQuery(".FileAddRezult").css("display","block");

}


function CloseWindowLoadFile(){
	jQuery(".BlockDiv").css("display","none");	
	jQuery(".LoadFile").css("display","none");	
}

function CloseWindowFileAddRezult(){
	jQuery(".BlockDiv").css("display","none");	
	jQuery(".FileAddRezult").css("display","none");	
	jQuery(".HideDiv").css("display","block");	
}

function AddImageFile(){
	jQuery("#LoadFile").submit();

}

  function ViewMaskWindow(){
		jQuery(".BlockDiv").css("height",jQuery(document).height());
		jQuery(".BlockDiv").css("width",jQuery(document).width()-2);

		jQuery(".BlockDiv").css("top","0");
		jQuery(".BlockDiv").css("left","0");
		jQuery(".BlockDiv").css("display","block");	
	
		var top = jQuery(window).height()/2 - 100+jQuery(window).scrollTop();
		var left = jQuery(window).width()/2 - 50;

		jQuery(".LoaderDiv").css("top",top);
		jQuery(".LoaderDiv").css("left",left);	
		jQuery(".LoaderDiv").css("display","block");

  }
  
  function UnViewMaskWindow(){
	jQuery(".BlockDiv").css("display","none");	
	jQuery(".LoaderDiv").css("display","none");	
  }

function AddVoise(id){
	ViewMaskWindow();
		jQuery.post(
			'step1.php',
			{
				add_votes: "1",
				foto_id:id
			},
			onSuccessAddVotes
		);	
}

  function onSuccessAddVotes(data){

	if(data.substr(0,2) == "ok"){
		var data = data.replace("ok","");
		var data_mas = data.split(",");
		jQuery("#rating"+data_mas[0]).html(data_mas[1]);
		jQuery("#FileAddRezultTitle").html("Голосование");
		jQuery("#FileAddRezultText").html("Спасибо что приняли участие в голосовании. Ваш голос учтён.");
	}else{
		jQuery("#FileAddRezultTitle").html("Голосование");
		jQuery("#FileAddRezultText").html("Ваш голос не был учтён. Скорее всего Вы уже голосовали за эту фотографию");
	}
	
	jQuery(".LoaderDiv").css("display","none");	
	FileAddRezult();
  }
  
  function ViewComment(id){
	ViewMaskWindow();
	jQuery("#SendCommentButton").click(function(){
		
		var name = document.getElementById("AddCommentUserName").value;
		var text = document.getElementById("AddCommentText").value;
		var code = document.getElementById("AddCommentUserCode").value;
		
		//проверим ввёл ли пользователь заголовок
		error_code = 0;
		if(name.length == 0){
			error_code = 1;
			jQuery("#AddCommentUserName").css("border","1px solid red");
		}else{
			jQuery("#AddCommentUserName").css("border-top","1px solid #a4836b");
			jQuery("#AddCommentUserName").css("border-left","1px solid #c9b6a8");
			jQuery("#AddCommentUserName").css("border-right","none");
			jQuery("#AddCommentUserName").css("border-bottom","none");
		}
		if(text.length == 0){
			error_code = 1;
			jQuery("#AddCommentText").css("border","1px solid red");
		}else{
			jQuery("#AddCommentText").css("border-top","1px solid #a4836b");
			jQuery("#AddCommentText").css("border-left","1px solid #c9b6a8");
			jQuery("#AddCommentText").css("border-right","none");
			jQuery("#AddCommentText").css("border-bottom","none");
		}
		if(code.length == 0){
			error_code = 1;
			jQuery("#AddCommentUserCode").css("border","1px solid red");
		}else{
			jQuery("#AddCommentUserCode").css("border-top","1px solid #a4836b");
			jQuery("#AddCommentUserCode").css("border-left","1px solid #c9b6a8");
			jQuery("#AddCommentUserCode").css("border-right","none");
			jQuery("#AddCommentUserCode").css("border-bottom","none");
		}		
		if(error_code == 0){
			jQuery(".CommentList").css("display","none");	
			jQuery.post(
				'step1.php',
				{
					add_comment: "1",
					foto_id:id,
					name:name,
					text:text,
					code:code
				},
				SuccessAddComment
			);	  			
		}
	});	
		jQuery.post(
			'step1.php',
			{
				list_comment: "1",
				foto_id:id
			},
			ViewCommentListWindow
		);	  
  
	
  }
  
  function SuccessAddComment(data){
  
	if(data == "count_error"){
		jQuery("#AddCommentRez").html("Вы сегодня оставляли комментарий для данной фотографии.");
	}else if(data == "secure_error"){
		jQuery("#AddCommentRez").html("Вы не правильно ввели проверочный код.");		
	}else if(data == "ok"){
		jQuery("#AddCommentRez").html("Ваш комментарий добавлен. После модерации он появится на сайте.");
	}else{
		jQuery("#AddCommentRez").html("При добавлении комментария произошла ошибка.");
	}
	jQuery(".CommentList").css("display","block");
  }
  
  function ViewCommentListWindow(data){
	data = unescape(data);
	UnViewMaskWindow();
	jQuery(".BlockDiv").css("height",jQuery(document).height());
	jQuery(".BlockDiv").css("width",jQuery(document).width()-2);

	jQuery(".BlockDiv").css("top","0");
	jQuery(".BlockDiv").css("left","0");
	jQuery(".BlockDiv").css("display","block");	
		
	var top = 100+jQuery(window).scrollTop();
	var left = jQuery(window).width()/2 - 250;
	jQuery("#CommentListText").html(data);
	jQuery("#AddCommentRez").html("&nbsp;");
	
	jQuery(".CommentList").css("top",top);
	jQuery(".CommentList").css("left",left);	
	jQuery(".CommentList").css("display","block");  
  
  }
  
  function CloseWindowCommentList(){
	jQuery(".BlockDiv").css("display","none");	
	jQuery(".CommentList").css("display","none");	  
	jQuery("#SendCommentButton").unbind("click");
  }
  
  
  function ViewCommentBlock(){
	jQuery("#CommentBlock").slideToggle("slow");
  }
  
  
function opendocs(id,width, height)
{
	window.open('flash_card.html?id='+id, "_blank", "toolbar=0,status=1,location=0,menubar=0,directories=0,scrollbars,resizeable,width="+width+",height="+height);
}

function SendMail(){
		var name = document.getElementById("name").value;
		var mail = document.getElementById("mail").value;
		var phone = document.getElementById("phone").value;
		var text = document.getElementById("text").value;
		var code = document.getElementById("code").value;

		
		var error_code = 0;

		if(name.length == 0){
			error_code = 1;
			jQuery("#name").css("border","1px solid red");
		}else{
			jQuery("#name").css("border-top","1px solid #a4836b");
			jQuery("#name").css("border-left","1px solid #c9b6a8");
			jQuery("#name").css("border-right","none");
			jQuery("#name").css("border-bottom","none");
		}
		if(mail.length == 0){
			error_code = 1;
			jQuery("#mail").css("border","1px solid red");
		}else{
			jQuery("#mail").css("border-top","1px solid #a4836b");
			jQuery("#mail").css("border-left","1px solid #c9b6a8");
			jQuery("#mail").css("border-right","none");
			jQuery("#mail").css("border-bottom","none");
		}		
		if(text.length == 0){
			error_code = 1;
			jQuery("#text").css("border","1px solid red");
		}else{
			jQuery("#text").css("border-top","1px solid #a4836b");
			jQuery("#text").css("border-left","1px solid #c9b6a8");
			jQuery("#text").css("border-right","none");
			jQuery("#text").css("border-bottom","none");
		}				
		if(code.length == 0){
			error_code = 1;
			jQuery("#code").css("border","1px solid red");
		}else{
			jQuery("#code").css("border-top","1px solid #a4836b");
			jQuery("#code").css("border-left","1px solid #c9b6a8");
			jQuery("#code").css("border-right","none");
			jQuery("#code").css("border-bottom","none");
		}
		if(error_code == 0){
			ViewMaskWindow();
			jQuery.post(
				'step1.php',
				{
					send_mail: "1",
					name:name,
					mail:mail,
					phone:phone,
					text:text,
					code:code
				},
				SuccessSendMail
			);
		}
}

function SuccessSendMail(data){
	if(data == "ok"){
		jQuery("#rez").html("<br><font color='green'>ВАШЕ ПИСЬМО ОТПРАВЛЕНО</font><br><br>");
	}else{
		jQuery("#rez").html("<br><font color='red'>ПРИ ОТПРАВКЕ ПИСЬМА ПРОИЗОШЛА ОШИБКА</font><br><br>");
	}
	UnViewMaskWindow()
}

function ViewSendFriendWindow(id){
	jQuery(".BlockDiv").css("height",jQuery(document).height());
	jQuery(".BlockDiv").css("width",jQuery(document).width()-2);

	jQuery(".BlockDiv").css("top","0");
	jQuery(".BlockDiv").css("left","0");
	jQuery(".BlockDiv").css("display","block");	
		
	var top = 100+jQuery(window).scrollTop();
	var left = jQuery(window).width()/2 - 250;
	document.getElementById("SendFriendId").value = id;
	
	jQuery(".SendFriend").css("top",top);
	jQuery(".SendFriend").css("left",left);	
	jQuery(".SendFriend").css("display","block");  
	jQuery(".HideDiv").css("display","none");
}

function CloseSendFriendWindow(){
	jQuery(".BlockDiv").css("display","none");	
	jQuery(".SendFriend").css("display","none");
	jQuery(".HideDiv").css("display","block");	
}

function SendFriend(){

	var SendFriendNameTo = document.getElementById("SendFriendNameTo").value;
	var SendFriendMailTo = document.getElementById("SendFriendMailTo").value;
	var SendFriendNameFrom = document.getElementById("SendFriendNameFrom").value;
	var SendFriendMailFrom = document.getElementById("SendFriendMailFrom").value;
	var SendFriendDay = document.getElementById("SendFriendDay").value;
	var SendFriendMonth = document.getElementById("SendFriendMonth").value;
	var SendFriendYear = document.getElementById("SendFriendYear").value;
	var SendFriendText = document.getElementById("SendFriendText").value;
	var SendFriendCode = document.getElementById("SendFriendCode").value;
	var SendFriendId = document.getElementById("SendFriendId").value;
	var SendFriendPageName = document.getElementById("SendFriendPageName").value;
	var SendFriendDopParametr = document.getElementById("SendFriendDopParametr").value;
	
	jQuery("input[type=checkbox]").each(function(){
		if(this.checked){
			var val = this.value;
			if (SendFriendDopParametr == ''){
				SendFriendDopParametr = val;
			}else{
				SendFriendDopParametr += ";"+val;
			}
		}
	});
	
	var error_code = 0;

	if(SendFriendNameTo.length == 0){
		error_code = 1;
		jQuery("#SendFriendNameTo").css("border","1px solid red");
	}else{
		jQuery("#SendFriendNameTo").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendNameTo").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendNameTo").css("border-right","none");
		jQuery("#SendFriendNameTo").css("border-bottom","none");
	}
	if(SendFriendMailTo.length == 0){
		error_code = 1;
		jQuery("#SendFriendMailTo").css("border","1px solid red");
	}else{
		jQuery("#SendFriendMailTo").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendMailTo").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendMailTo").css("border-right","none");
		jQuery("#SendFriendMailTo").css("border-bottom","none");
	}	
	
	if(SendFriendNameFrom.length == 0){
		error_code = 1;
		jQuery("#SendFriendNameFrom").css("border","1px solid red");
	}else{
		jQuery("#SendFriendNameFrom").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendNameFrom").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendNameFrom").css("border-right","none");
		jQuery("#SendFriendNameFrom").css("border-bottom","none");
	}		
	if(SendFriendMailFrom.length == 0){
		error_code = 1;
		jQuery("#SendFriendMailFrom").css("border","1px solid red");
	}else{
		jQuery("#SendFriendMailFrom").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendMailFrom").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendMailFrom").css("border-right","none");
		jQuery("#SendFriendMailFrom").css("border-bottom","none");
	}			
	
	if(SendFriendText.length == 0){
		error_code = 1;
		jQuery("#SendFriendText").css("border","1px solid red");
	}else{
		jQuery("#SendFriendText").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendText").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendText").css("border-right","none");
		jQuery("#SendFriendText").css("border-bottom","none");
	}				
	if(SendFriendCode.length == 0){
		error_code = 1;
		jQuery("#SendFriendCode").css("border","1px solid red");
	}else{
		jQuery("#SendFriendCode").css("border-top","1px solid #a4836b");
		jQuery("#SendFriendCode").css("border-left","1px solid #c9b6a8");
		jQuery("#SendFriendCode").css("border-right","none");
		jQuery("#SendFriendCode").css("border-bottom","none");
	}					

	if(error_code == 0){
	
			jQuery(".SendFriend").css("display","none");		
			jQuery.post(
				'step1.php',
				{
					send_friend: "1",
					SendFriendNameTo:SendFriendNameTo,
					SendFriendMailTo:SendFriendMailTo,
					SendFriendNameFrom:SendFriendNameFrom,
					SendFriendMailFrom:SendFriendMailFrom,
					SendFriendDay:SendFriendDay,
					SendFriendMonth:SendFriendMonth,
					SendFriendYear:SendFriendYear,
					SendFriendText:SendFriendText,
					SendFriendCode:SendFriendCode,
					SendFriendId:SendFriendId,
					SendFriendPageName:SendFriendPageName,
					SendFriendDopParametr:SendFriendDopParametr

				},
				SuccessSendFriend
			);	
	}
}

function SuccessSendFriend(data){
	if(data == "ok"){
		jQuery("#FileAddRezultTitle").html("Отправить другу");
		jQuery("#FileAddRezultText").html("Ваше письмо отправлено.");
	}else{
		jQuery("#FileAddRezultTitle").html("Отправить другу");
		jQuery("#FileAddRezultText").html("Письмо небыло отправлено");
	}
	jQuery(".LoaderDiv").css("display","none");	
	FileAddRezult();

}