﻿function showtime() 
{ 
var today,hour,second,minute,year,month,date; 
var strDate ; 
today=new Date(); 
var n_day = today.getDay(); 
switch (n_day) 
{ 
case 0:{ 
strDate = "星期日" 
}break; 
case 1:{ 
strDate = "星期一" 
}break; 
case 2:{ 
strDate ="星期二" 
}break; 
case 3:{ 
strDate = "星期三" 
}break; 
case 4:{ 
strDate = "星期四" 
}break; 
case 5:{ 
strDate = "星期五" 
}break; 
case 6:{ 
strDate = "星期六" 
}break; 
case 7:{ 
strDate = "星期日" 
}break; 
} 
year = today.getYear(); 
month = today.getMonth()+1; 
date = today.getDate(); 
hour = today.getHours(); 
minute =today.getMinutes(); 
second = today.getSeconds(); 
if(month<10) month="0"+month; 
if(date<10) date="0"+date; 
if(hour<10) hour="0"+hour; 
if(minute<10) minute="0"+minute; 
if(second<10) second="0"+second; 
document.getElementById('time').innerHTML = "&nbsp;" //显示时间 
//document.getElementById('time').innerHTML = month +"&nbsp;&nbsp;"+ date +"&nbsp;&nbsp;"+  year +"&nbsp;&nbsp;"+ hour + ":" + minute + ":" + second; //显示时间 
setTimeout("showtime();", 1000); //设定函数自动执行时间为 1000 ms(1 s) 
} 



function czj(yesorno)
{
	var id=document.f1.photopage.value;
	var yon=yesorno;
	
		if(event.keyCode==13 || yon==13)
		{
			if(document.f1.photopage.value=="" || document.f1.photopage.value==null)
			{
				alert("error!!!");
			}
			else
			{
				if(isNaN(id))
				{
					alert("error!!!");
				}
				else
				{
					document.f1.action="goToPhotopage.svfx";
					document.f1.method="post";
					document.f1.submit();
				}
			}				
		}
	
	
}

function czj1(yesorno)
{
	var id=document.f1.photopage1.value;
	var yon=yesorno;
	
		if(event.keyCode==13 || yon==13)
		{
			if(document.f1.photopage1.value=="" || document.f1.photopage1.value==null)
			{
				alert("error!!!");
			}
			else
			{
				if(isNaN(id))
				{
					alert("error!!!");
				}
				else
				{
					document.f1.action="goToPhotopage.svfx";
					document.f1.method="post";
					document.f1.submit();
				}
			}
		}
		
}

function czj3()
{
	var id=document.f2.id.value;


		if(document.f2.id.value=="" || document.f2.id.value==null)
		{
			alert("error!!!");
		}
		else
		{
			if(isNaN(id))
			{
				alert("error!!!");
			}
			else
			{
				document.f2.action="IdFindUpdatePageServlet";
				document.f2.method="post";
				document.f2.submit();
			}
		}		
	
}

function czj4()
{
	var id=document.f2.id.value;


		if(document.f2.id.value=="" || document.f2.id.value==null)
		{
			alert("error!!!");
		}
		else
		{
			if(isNaN(id))
			{
				alert("error!!!");
			}
			else
			{
				document.f2.action="FindIdPhotoPageServlet";
				document.f2.method="post";
				document.f2.submit();
			}
		}		
	
}

function DeletePhoto(id)
{

		if(confirm("警告\n确实要删除此图片吗？"))
        {
			var page=document.selectpage.select.value;;
			window.location='deletePhoto.svfx?id='+id+"&page="+page;
        }

}

function ValidateAddPhoto()
{
	var theform = document.addphoto;
	for (i=0;i<theform.elements.length;i++) 
	{
		var e = theform.elements[i];
		if(e.name=="photomassage")
		{
			if(e.value.length>5000)
			{
				alert("照片注释字数超出规定字数限制")
				return false;
			}
			
		}
		
		if(e.name=="photoinfo")
		{
			if(e.value.length>500)
			{
				alert("照片信息字数超出规定字数限制")
				return false;
			}
			
		}		
		

		if(e.name=="pageinfo")
		{
			if(e.value.length>100)
			{
				alert("照片页注释字数超出规定字数限制")
				return false;
			}
			
		}	

		if(e.name=="file")
		{
			if(e.value=="")
			{
				alert("上传图片不能为空");
				return false;				
				
			}
			//获取欲上传的文件路径
			var filepath =e.value; 
			//为了避免转义反斜杠出问题，这里将对其进行转换
			var re = /(\\+)/g;  
			var filename=filepath.replace(re,"#"); 
			//对路径字符串进行剪切截取
			var one=filename.split("#"); 
			//获取数组中最后一个，即文件名
			var two=one[one.length-1]; 
			//再对文件名进行截取，以取得后缀名
			var three=two.split("."); 
			 //获取截取的最后一个字符串，即为后缀名
			var last=three[three.length-1];
			//添加需要判断的后缀名类型
			var tp ="jpg,bmp,JPG,BMP"; 
			//返回符合条件的后缀名在字符串中的位置
			var rs=tp.indexOf(last); 
			//如果返回的结果大于或等于0，说明包含允许上传的文件类型
			if(rs>=0)
			{
			 	return true;
			}
			else
			{
				alert("您选择的上传文件不是有效的图片文件！");
				return false;
			}
		}
	}
}


function ValidateComment()
{

		
		var h=document.f1.hvalidateCommentString.value;
		var nh=document.f1.validateCommentString.value;	
		if(document.f1.username.value=="" || document.f1.username.value==null)
		{
			alert("username error!!!");
		}
		else if(document.f1.username.value.length>30)
		{
			alert("username error!!!");				
		}
		else if(document.f1.content.value=="" || document.f1.content.value==null)
		{
			alert("content error!!!");			
		}
		else if(document.f1.content.value.length>250)
		{
			alert("content error!!!");				
		}
		else if(h!=nh || nh=="" || nh==null)
		{
			alert("verification code error");	
		}
		else
		{
			return true;
		}
		return false;
}


function DeleteComment(id)
{

		if(confirm("警告\n确实要删除此留言么吗？"))
        {
			
			document.f1.action="deleteComments.svfx?id="+id;
			document.f1.method="post";
			document.f1.submit();	
        }

}

function DeletePhotoPage(id)
{

		if(confirm("警告\n删除此页的同时，此页的照片也将被同时删除，是否要继续？"))
        {
			document.f1.action="deletePhotopage.svfx?id="+id;
			document.f1.method="post";
			document.f1.submit();	
        }

}

function czj5()
{
	var findpage=document.f2.findpage.value;


		if(document.f2.findpage.value=="" || document.f2.findpage.value==null)
		{
			alert("error!!!");
		}
		else
		{
			if(isNaN(findpage))
			{
				alert("error!!!");
			}
			else
			{
				document.f2.action="NextUpPageServlet?page="+findpage;
				document.f2.method="post";
				document.f2.submit();
			}
		}		
	
}

function czj6(id)
{

	location.href="goToPhotopage.svfx?photopageurl="+id;

}


function proDownImage(ImgD){
      var image=new Image();
      image.src=ImgD.src;
	  var width1=image.width/2;
	  var whidth2=image.width;
	  var height1=image.height;
	  area1.coords='0,0,'+width1+','+height1;
	  area2.coords=''+width1+',0,'+whidth2+','+height1;
	  area3.coords='0,0,'+width1+','+height1;
	  area6.coords=''+width1+',0,'+whidth2+','+height1;
}

function czj7(e,img){
	var width=img.width;
	var height=img.height;
	if(e.offsetX>=0  && e.offsetX<=width/2)
	{
	  img.style.cursor = "url("+"img/pre.ani"+")";

	}
	else
	{
	  img.style.cursor = "url("+"img/next.ani"+")";

	}
}

function czj8(e,img){
	var width=img.width;
	var height=img.height;
	if(e.offsetX>=0  && e.offsetX<=width/2)
	{
	  img.style.cursor = "url("+"img/pre.ani"+")";

	}
	else
	{
	  img.style.cursor = "auto";		
	}
}

function czj9(e,img){
	var width=img.width;
	var height=img.height;
	if(e.offsetX>=0  && e.offsetX<=width/2)
	{
	  img.style.cursor = "auto";	
	}
	else
	{
	  img.style.cursor = "url("+"img/next.ani"+")";

	}
}

function czj10()
{
	var j=document.photomodel.j.value;
	if(j=="")
	{
		alert("增加的照片模块数量不能为空");
		return false;
	}
	else if(isNaN(j))
	{
		alert("增加的照片模块数量必须为数字");
		return false;
	}
	else if(j>10)
	{
		alert("增加的照片模块数量不得大于9");
		return false;
	}
	else if(j<=0)
	{
		alert("增加的照片模块数量不得小于等于0");
		return false;
	}
	else
	{
		return true;
	}
	
}


function czj11()
{
	var page=document.selectpage.select.value;
	document.selectpage.action="photoManageList.svfx?page="+page;
	document.selectpage.method="post";
	document.selectpage.submit();	

}

function czj12()
{
	var page=document.selectpage.photopage.value;
	if(page=="")
	{
		alert("照片页数不能为空");
		return false;
	}
	else if(isNaN(page))
	{
		alert("照片页数必须为数字");
		return false;
	}
	return true;
}

function czj13()
{
	var id=document.f1.id.value;
	if(id=="")
	{
		alert("照片页数不能为空");
		return false;
	}
	else if(isNaN(id))
	{
		alert("照片页数必须为数字");
		return false;
	}
	return true;
}

function czj14(id)
{

	location.href="goToUpdatePhoto.svfx?id="+id;

}

function czj15(id)
{

	location.href="goToPhotoTypePhotoListPage.svfx?id="+id+"&page=1";

}

function ValidateUpdatePhoto()
{
	var theform = document.updatephoto;
	for (i=0;i<theform.elements.length;i++) 
	{
		var e = theform.elements[i];
		if(e.name=="photomassage")
		{
			if(e.value.length>5000)
			{
				alert("照片注释字数超出规定字数限制")
				return false;
			}
			
		}
		
		if(e.name=="photoinfo")
		{
			if(e.value.length>500)
			{
				alert("照片信息字数超出规定字数限制")
				return false;
			}
			
		}			

		if(e.name=="file")
		{
			if(e.value!="")
			{
				//获取欲上传的文件路径
				var filepath =e.value; 
				//为了避免转义反斜杠出问题，这里将对其进行转换
				var re = /(\\+)/g;  
				var filename=filepath.replace(re,"#"); 
				//对路径字符串进行剪切截取
				var one=filename.split("#"); 
				//获取数组中最后一个，即文件名
				var two=one[one.length-1]; 
				//再对文件名进行截取，以取得后缀名
				var three=two.split("."); 
				 //获取截取的最后一个字符串，即为后缀名
				var last=three[three.length-1];
				//添加需要判断的后缀名类型
				var tp ="jpg,bmp,JPG,BMP"; 
				//返回符合条件的后缀名在字符串中的位置
				var rs=tp.indexOf(last); 
				//如果返回的结果大于或等于0，说明包含允许上传的文件类型
				if(rs>=0)
				{
					return true;
				}
				else
				{
					alert("您选择的上传文件不是有效的图片文件！");
					return false;
				}				
			}

		}
	}
}

function ValidateUpdatePhotopage()
{
	var theform = document.updatephotopage;
	for (i=0;i<theform.elements.length;i++) 
	{
		var e = theform.elements[i];
		if(e.name=="photomassage")
		{
			if(e.value.length>5000)
			{
				alert("照片注释字数超出规定字数限制")
				return false;
			}
			
		}
		
		if(e.name=="photoinfo")
		{
			if(e.value.length>500)
			{
				alert("照片信息字数超出规定字数限制")
				return false;
			}
			
		}		
		

		if(e.name=="pageinfo")
		{
			if(e.value.length>100)
			{
				alert("照片页注释字数超出规定字数限制")
				return false;
			}
			
		}	

		if(e.name=="file")
		{
			if(e.value!="")
			{
				//获取欲上传的文件路径
				var filepath =e.value; 
				//为了避免转义反斜杠出问题，这里将对其进行转换
				var re = /(\\+)/g;  
				var filename=filepath.replace(re,"#"); 
				//对路径字符串进行剪切截取
				var one=filename.split("#"); 
				//获取数组中最后一个，即文件名
				var two=one[one.length-1]; 
				//再对文件名进行截取，以取得后缀名
				var three=two.split("."); 
				 //获取截取的最后一个字符串，即为后缀名
				var last=three[three.length-1];
				//添加需要判断的后缀名类型
				var tp ="jpg,bmp,JPG,BMP"; 
				//返回符合条件的后缀名在字符串中的位置
				var rs=tp.indexOf(last); 
				//如果返回的结果大于或等于0，说明包含允许上传的文件类型
				if(rs>=0)
				{
					return true;
				}
				else
				{
					alert("您选择的上传文件不是有效的图片文件！");
					return false;
				}				
			}
		}
	}	
}

function browsing(id)
{
   var existprev = "605";
   var existnext = "607";
   if (existprev != "606"){
       document.write('<a href="#" id="menu_browse_prev" onclick="document.location=\'beforePhotopage.svfx?id='+id+'\';"></a>');
   }
   if (existnext != "606"){
       document.write('<a href="#" id="menu_browse_next" onclick="document.location=\'afterPhotopage.svfx?id='+id+'\';"></a>');
   }
}
function browsing1(id)
{
   var existprev = "605";
   var existnext = "607";
   if (existprev != "606"){
       document.write('<a href="#" id="menu_browse_prev" onclick="document.location=\'beforePhotopage.svfx?id='+id+'\';"></a>');
   }
}
function browsing2(id)
{
   var existprev = "605";
   var existnext = "607";
   if (existnext != "606"){
       document.write('<a href="#" id="menu_browse_next" onclick="document.location=\'afterPhotopage.svfx?id='+id+'\';"></a>');
   }
}






function ValidateAddPhotoType()
{
	var name=document.addPhotoType.name.value;
	var photoid=document.addPhotoType.photoid.value;
	var file=document.addPhotoType.file.value;
	if(name=="")
	{
		alert("照片分类名称不能为空！");
		return false;	
	}
	else if(photoid!=""){
		if(file!="")
		{
			alert("使用照片id做封面和上传照片封面二选一");
			return false;
		}
		else(isNaN(photoid))
		{
			alert("照片ID必须为数字");
			return false;	
		}		
	}
	else if(file!="")
	{
		if(photoid!="")
		{
			alert("使用照片id做封面和上传照片封面二选一");
			return false;
		}
		else
		{
				//获取欲上传的文件路径
				var filepath =file; 
				//为了避免转义反斜杠出问题，这里将对其进行转换
				var re = /(\\+)/g;  
				var filename=filepath.replace(re,"#"); 
				//对路径字符串进行剪切截取
				var one=filename.split("#"); 
				//获取数组中最后一个，即文件名
				var two=one[one.length-1]; 
				//再对文件名进行截取，以取得后缀名
				var three=two.split("."); 
				 //获取截取的最后一个字符串，即为后缀名
				var last=three[three.length-1];
				//添加需要判断的后缀名类型
				var tp ="jpg,bmp,JPG,BMP"; 
				//返回符合条件的后缀名在字符串中的位置
				var rs=tp.indexOf(last); 
				//如果返回的结果大于或等于0，说明包含允许上传的文件类型
				if(rs>=0)
				{
					return true;
				}
				else
				{
					alert("您选择的上传文件不是有效的图片文件！");
					return false;
				}		
		}
		
	}
	else
	{
		return true;
			
	}
}

function DeletePhotoType()
{
		var photoType=document.fixphototype.phototype.value;
		
		if(photoType=="0")
		{
			alert("不能删除此分类,请选择下面的照片分类!");
		}
		else
		{
			if(confirm("警告\n确实要删除此照片类型吗？"))
			{
				
				if(confirm("警告\n删除后基于本分类的照片将自动归为未分类照片！是否确认删除？"))
				{		
	
					document.fixphototype.action="deletPhotoType.svfx?photoType="+photoType;
					document.fixphototype.method="post";
					document.fixphototype.submit();
				}
        	}		
		}
}

function UpdatePhotoType()
{
		var photoType=document.fixphototype.phototype.value;
		document.fixphototype.action="goToUpdatePhotoTypePage.svfx?photoType="+photoType;
		document.fixphototype.method="post";
		document.fixphototype.submit();
}


function ValidateUpdatePhotoType()
{
	var name=document.updatePhotoType.name.value;
	var photoid=document.updatePhotoType.photoid.value;
	var file=document.updatePhotoType.file.value;
	if(name=="")
	{
		alert("照片分类名称不能为空！");
		return false;	
	}
	else if(photoid!=""){
		if(file!="")
		{
			alert("使用照片id做封面和上传照片封面二选一");
			return false;
		}
		else(isNaN(photoid))
		{
			alert("照片ID必须为数字");
			return false;	
		}		
	}
	else if(file!="")
	{
		if(photoid!="")
		{
			alert("使用照片id做封面和上传照片封面二选一");
			return false;
		}
		else
		{
				//获取欲上传的文件路径
				var filepath =file; 
				//为了避免转义反斜杠出问题，这里将对其进行转换
				var re = /(\\+)/g;  
				var filename=filepath.replace(re,"#"); 
				//对路径字符串进行剪切截取
				var one=filename.split("#"); 
				//获取数组中最后一个，即文件名
				var two=one[one.length-1]; 
				//再对文件名进行截取，以取得后缀名
				var three=two.split("."); 
				 //获取截取的最后一个字符串，即为后缀名
				var last=three[three.length-1];
				//添加需要判断的后缀名类型
				var tp ="jpg,bmp,JPG,BMP"; 
				//返回符合条件的后缀名在字符串中的位置
				var rs=tp.indexOf(last); 
				//如果返回的结果大于或等于0，说明包含允许上传的文件类型
				if(rs>=0)
				{
					return true;
				}
				else
				{
					alert("您选择的上传文件不是有效的图片文件！");
					return false;
				}		
		}
		
	}
	else
	{
		return true;
			
	}
}






