﻿//不知道起了什么作用（可能没起作用）。
$(function(){
	$(".Submit").hover(function(){$(this).addClass("SubmitActive").removeClass('Submit');},function(){$(this).removeClass('SubmitActive').addClass("Submit");  });
	DrawImage('#Wiki_Show img' , 400 , 600); 		
	setTimeout("DrawImage('#Wiki_Show img' , 450 , 600)" , 2000);
	setTimeout("DrawImage('#description img' , 450 , 600)" , 2000);		
});



//复制网址 
$(document).ready(function()
{
	$("#Copy_URL").val( window.location.href );					
	$("#Copy_URL_Title").click(function Copy_URL()
	{copy_clip($("#Copy_URL").val()  );openAWindow( lang_copy_url , false);setTimeout("disablePopup()" , 1800 );return false;});
	$("#Copy_URL").click(function Copy_URL()
	{copy_clip($("#Copy_URL").val()  );openAWindow( lang_copy_url , false);setTimeout("disablePopup()" , 1800 );return false;});				
});			

//发表评论
$(function(){

	var sBasePath = jslab_path+"/FCK_Editor/";

	$(".Height_UP").click(function(){ FCKeditor_Height('+') });
	$(".Height_Down").click(function(){ FCKeditor_Height('-') });
	function FCKeditor_Height(H)
	{
		var obj = '#comment___Frame';
		if('+' == H ) $(obj).animate({  height: $(obj).height() + 150 }, "normal");
		else if('-' == H  && $(obj).height() >= 300 ) $(obj).animate({  height: $(obj).height() - 150 }, "normal");;
	}
	var  Creat_Comment_Edit = false;
	
	$("#comment").click(function(){
		var Comment_ICO = "" ;

		var FACE_URL = theme_path+"/images/Comment_ICO";
		
		for( var i = 0 ; i < 2 ; i++ )
		{
			Comment_ICO += "<ul>";
			for( var j = 0 ; j < 8 ; j++ )
				Comment_ICO += '<li><img src="'+ FACE_URL +'/'+ i +""+ j +'.gif" onclick="InserImg(\'comment\',this.src);" /></li>';
			Comment_ICO += "</ul>";
		}
		$("#Comment_ICO").html( Comment_ICO );		 
		CreatEditor("comment" ,sBasePath);
		$('#SayFormSubmit').show();
		
		setTimeout('$("#Comment_ICO").show("slow")' , 3000);
		
		$(".Height_UP").show();
		$(".Height_Down").show();		
	});
	
}); 

//照片故事
$(function(){

	var sBasePath = jslab_path+"/FCK_Editor/";
	$("#description").click(function(){
		//if( !(login_now && (user_id == photo_user_id)&& isAllowed ) ) return false;		
		if( !(login_now && isAllowed ) ) return false;		

		$("#description").hide();//jiang change 连续单击也只一个编辑窗口
		//$("#description").slideUp(1000);
		$("#description_Edit").val( $("#description").html() );		
		//setTimeout('CreatEditor("description" ,"'+ sBasePath +'" , 400 , 450)',500);
		setTimeout('CreatEditor("description_Edit" ,"'+ sBasePath +'" , 400 , 450)',0);
		
		$("#description_Form").show("slow").submit(function(){
			$('#description_Submit').hide();
			openAWindow(Open_Loading + lang_loading , false);
			setTimeout('description_Submit()' , 800 ); return false;
		});
	});
}); 

function description_Submit(){ //上面用到
	$.ajax({
		type: "POST",
		//url: './?option=yb&ac=updatephoto&photo_id='+ $("#photo_id").val() ,
		url: './?option=yb&ac=updatephoto&photo_id='+ $("#photo_id").val()+'&isAllowed='+isAllowed ,
		data:{description : $('#description_Edit').val()},
		beforeSend : function(){	
		},
		success: function(msg){
			if( msg == "OK"){msg = lang_return_susses_text ;}	
			openAWindow(msg , false);
			if( msg == lang_return_susses_text ) setTimeout("disablePopup()" , 1800 );
			$("#description_Form").slideUp();
			$("#description").html($("#description_Edit").val()).slideDown();
			$("#description_Edit___Frame").empty().remove();
		},
		complete : function(){
			$('#description_Submit').show();
		},
		error:function(){
			openAWindow( lang_server_busy , false);
		}
	});
	return false;
}

//帮助翻译
function help_description(){
		var allow_wiki = false;
		if (photo_allow_wiki==1) allow_wiki = true;
		$('#e_description').val($('#Wiki_Show').html()); 
		$("#add_Wiki").click(function(){
			if( !allow_wiki ) return false;
			$('#Wiki_Show').hide();						  
			$("#add_Wiki_Edit").slideDown("slow");
			setTimeout('CreatEditor_Wiki()' , 500);	
			return false;					
		});
}
function CreatEditor_Wiki(){CreatEditor("e_description" , jslab_path +"/FCK_Editor/") , 200 ,430;}//上面用到


//修改图片地理位置--点“修改图片所在地理位置”按钮 

function Creat_Edit_Map_Start(){ setTimeout('Creat_Edit_Map();' , 500 ); } 

function Creat_Edit_Map()
{
	if (GBrowserIsCompatible())
	{
	
	var map = new GMap2(document.getElementById("map_Edit"));
	map.setCenter(new GLatLng( $('#Edit_X').html(), $('#Edit_Y').html()), 10);
	
	
	var marker = new GMarker(map.getCenter(),{dragCrossMove:true,draggable:true});
	map.addOverlay(marker);
	map.enableScrollWheelZoom();
	map.addControl( new GScaleControl() );
	map.addControl( new GMapTypeControl() );
	
	
	GEvent.addListener(marker,"dragend",Edit_Map_DisPoint);	
	//GEvent.addListener(map, "click", Edit_Map_DisPoint ) ; // onMoveEndMap);
	//GEvent.addListener(map,"dragend",Edit_Map_DisPoint);	
	}
}

var Edit_Map_DisPoint = function ()
{
	var point=this.getPoint();
	//this.openInfoWindow(point.toString());			
	var NowPoint = point.toString().replace("(" ,"").replace(")" ,"").replace(" " ,"");
	var NowPointSplit = NowPoint.split(",");
	$("#Edit_X").html( NowPointSplit[0] );
	$("#Edit_Y").html( NowPointSplit[1] );
}
//修改图片地理位置--结束--
