//window.resizeTo(screen.availWidth,screen.availHeight ) ; //全屏    

function getImageSize(img) //获取图片实际高度
{
	var bigImageHeight;
    if(typeof(img)!='object')
        img=document.getElementById(img);
    if(img==null)
        return ;
    //创建新的image
	var image=new Image();
	image.src=img.src;
	bigImageHeight=image.height;
	if (img==null || bigImageHeight==null || bigImageHeight==0 ||bigImageHeight=="")//判断第一个图片是否已经载入。
	{
			if ((document.documentElement.clientWidth-160)/2>(document.documentElement.clientHeight-160))
			{
				return document.documentElement.clientHeight-160;
			}
			else
			{
				return (document.documentElement.clientWidth-160)/2;
			}

		//return document.documentElement.clientHeight-160;
	}
	else
	{
		return bigImageHeight;
	}
}


var xmlHttp;
function createXMLHttpRequest()
	{if(window.ActiveXObject)
		{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}else if(window.XMLHttpRequest)
			{xmlHttp=new XMLHttpRequest();
			}
	}

function setMessage(message,isValid)
	{var messageArea=document.getElementById("birth");
	 var fontColor="red";
	 if(isValid==1)
	 	{fontColor="green";
		messageArea.innerHTML="<font color="+fontColor+">"+message+"</font>";
		}else{fontColor="red"; messageArea.innerHTML="<font color="+fontColor+">"+message+"</font>";
			  }	
	}

/***c uname检测  ***/
function cuname()
	{createXMLHttpRequest();
	 var name=document.getElementById("uname");
	 var url="cheuname.php?uname="+name.value;//escape()可以将汉字编码
	 xmlHttp.open("GET",url,"true");
	 xmlHttp.onreadystatechange=callbackc;
	 xmlHttp.send(null);
	}

function callbackc()
	{if(xmlHttp.readyState==4)
		{if(xmlHttp.status==200)
			{//var mes=xmlHttp.responseXML.getElementsByTagName("info")[0].firstChild.nodeValue;
			// alert(xmlHttp.responseText);
			var msg = xmlHttp.responseText;
			//alert(msg);
			var messageArea=document.getElementById("ajaxdiv");
			messageArea.innerHTML=msg;
			//init(); //初次载入控制窗口大小。
			getsize(); //初次载入控制窗口大小。
			//setTimeout("init();getsize();",300);//add it 2008.12.20 初次载入控制窗口大小。
			setTimeout("loadit();",1000); //载入后面三张图片。
			//$('#ajaxdiv').html(msg); //this is a bug
			// setMessagec(mes,val);
			}
		}
	}

var imgheight;
function getHeight()
{
	var bigImageHeight=getImageSize("BigImage");
	//window.alert (bigImageHeight);

	var exactHeight;
	if ((document.documentElement.clientWidth-160)/2>(document.documentElement.clientHeight-160))
	{
		exactHeight=document.documentElement.clientHeight-160;
	}
	else
	{
		exactHeight=(document.documentElement.clientWidth-160)/2;
	}

	if (exactHeight>=bigImageHeight)
	{
		imgheight=bigImageHeight;
	}
	else //如果实际高度小于图片100%高度，则不显示图片的100%高度
	{
		imgheight=exactHeight;	
	}	
}

function loadingajax(id,category,IsReachFirst,IsReachLast)
{	//alert(category);
	$("#ajaxdiv").css({ background: "#000" ,bottom:"0px", visibility:"inherit"}); //loadhide
	
		//window.alert ("testing");
	$("#ajaxdiv_bg").css({ bottom:"0px", visibility:"inherit"}); //loadhide
	//$("#ajaxdiv").css({ bottom:"0px", visibility:"inherit"}); //loadhide

	$("#loadhide").css({ display:"none"}); 


	//return false;
	var loadingwidth= document.body.Width;
	//var loadingwidth= 900;
	var loadingheight=document.documentElement.clientHeight-80;
		
	if (IsReachFirst==0 || IsReachFirst==1) //判断是否继续平滑显示
	{

	}
	else{

		$('#ajaxdiv').html("<div id=img_box_xxx style='width:"+(loadingwidth-80)+"px;text-align:center; background: #000;  float:none; padding:300px 0 100px 0;'><img src=images/loading.gif width=208 height=30 /></div>"); //用来覆盖		
	}

	createXMLHttpRequest();	
	//window.alert (bigImageHeight);
	getHeight();
	/*if ((document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height))>=bigImageHeight) //如果实际高度大于等于图片100%高度，则显示图片的100%高度
	{
		var imgheight=bigImageHeight;
		//window.alert (((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height));
	}
	else //如果实际高度小于图片100%高度，则不显示图片的100%高度
	{
		var imgheight=document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height);	
	}*/		
	/*if (document.documentElement.clientWidth>1600) //如果屏幕尺寸太大
	{
		var imgheight=700;
	}
	else
	{
		var imgheight=document.documentElement.clientHeight-200;	
	}*/
		
	//var imgheight=document.documentElement.clientHeight-200; //得到高度
	
	/*if (IsReachFirst==1)
	{
		window.alert ("Reach to first picture.");
	}	
	if (IsReachLast==1)
	{
		window.alert ("Reach to last picture.");
	}		*/
	var url="ajax/getphoto.php?id="+id+"&category="+category+"&imgheight="+imgheight;//escape()可以将汉字编码
	//window.alert (url);
	window.location.hash   = id+","+category;
	xmlHttp.open("GET",url,"true");
	xmlHttp.onreadystatechange=callbackc;
	//window.alert("test");	
	xmlHttp.send(null);
}

function loadingajax_mybox(id,dirname,IsReachFirst,IsReachLast)

{	
	$("#ajaxdiv").css({ background: "#000" ,bottom:"0px",visibility:"inherit"}); //loadhide
	$("#loadhide").css({ display:"none"}); //....
	var loadingwidth= document.body.Width;
	var loadingheight=document.documentElement.clientHeight-80;

	if (IsReachFirst==0 || IsReachFirst==1) //判断是否继续平滑显示
	{

	}
	else{

		$('#ajaxdiv').html("<div id=img_box_xxx style='width:"+(loadingwidth-80)+"px;text-align:center; background: #000;  float:none; padding:300px 0 100px 0;'><img src=images/loading.gif width=208 height=30 /></div>"); //用来覆盖		
	}

	createXMLHttpRequest();	
	getHeight();
	/*if (IsReachFirst==1)
	{
		window.alert ("Reach to first picture.");
	}	
	if (IsReachLast==1)
	{
		window.alert ("Reach to last picture.");
	}	*/
	//var bigImageHeight=getImageSize("BigImage");
	//window.alert (bigImageHeight);

	/*if ((document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height))>=bigImageHeight) //如果实际高度大于等于图片100%高度，则显示图片的100%高度
	{
		var imgheight=bigImageHeight;
	}
	else //如果实际高度小于图片100%高度，则不显示图片的100%高度
	{
		var imgheight=document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height);	
	}	*/
	//var url="ajax/getphoto_mybox.php?id="+id+"&dirname="+dirname;//escape()可以将汉字编码
	/*if (document.documentElement.clientWidth>1600) //如果屏幕尺寸太大
	{
		var imgheight=700;
	}
	else
	{
		var imgheight=document.documentElement.clientHeight-200;	
	}*/

	//var imgheight=document.documentElement.clientHeight-200; //得到高度
	var url="ajax/getphoto_mybox.php?id="+id+"&dirname="+dirname+"&imgheight="+imgheight;//escape()可以将汉字编码
	window.location.hash   = id+","+dirname;
	xmlHttp.open("GET",url,"true");
	xmlHttp.onreadystatechange=callbackc;
	xmlHttp.send(null);
}

function beginning()
{
	//$("#ajaxdiv").css({ background: "#fff" ,visibility:"hidden",height:"auto"});
	$("#ajaxdiv").css({ visibility:"hidden",height:"auto"});
}

function colseajax()
{
	//$("#ajaxdiv").css({ background: "#fff" ,visibility:"hidden"});
	$("#ajaxdiv").css({ visibility:"hidden"});
	$("#ajaxdiv_bg").css({ visibility:"hidden"}); //loadhide

	$("#loadhide").css({ display:"block"}); //
}

function displayarraow(which)
{
	if(which==1)
	{
		$('#box_arrow_left').slideDown("normal");$('#box_arrow_right').slideUp("normal");
	}
	if(which==2)
	{
		$('#box_arrow_right').slideDown("normal");$('#box_arrow_left').slideUp("normal");
	}
}

function hiddenarraow(which)
{
	if(which==1)
	{
		$('#box_arrow_left').fadeOut("slow");
	}
	if(which==2)
	{
		$('#box_arrow_right').fadeOut("slow");
	}
}

function  getusername()   
  {   
      var url= self.location.href; 
      var urlarray = url.split("#");
   //if(urlarray[1]=='')
   //alert('请把浏览器设置未允许javascript运行!');
     if(urlarray[1]!=undefined)
	  {
		  var functionvalues=urlarray[1].split(',');
		  var tiaojian=functionvalues[1];
		 // alert(tiaojian);
		  if(tiaojian!=undefined)
		  {
			//  alert(functionvalues[1]+'aa');
		  	loadingajax(functionvalues[0],functionvalues[1]);
		  }
		  else
		  {
		  	//alert('不执行');
		  }
	  }
	  else
	  {
		 // alert('不存在');
	  }
	   //return   urlarray[1];   //this the muti values.
  }

/* 2008 12 20 add it */


window.onresize=getsize;//改变窗口大小的函数
function getsize()
{	//$('#ajaxdiv').css({ width: "100%" });
	//document.getElementById("meme").height;
	//var meme_s_height=document.getElementById("meme").height;
	//var meme_s_width=document.getElementById("meme").width;
    //window.alert (meme_s_height);
	//var bigImage=document.getElementById("meme").height;
	//window.alert (bigImageHeight);
	//window.alert ("total:"document.documentElement.clientHeight-200+",exact:"+bigImageHeight);
	getscreenwidth();//20081223
    //var bigImageHeight=getImageSize("BigImage");
	getHeight();
	/*if ((document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height))>=bigImageHeight) //如果实际高度大于等于图片100%高度，则显示图片的100%高度
	{
		var imgheight=bigImageHeight;
	}
	else //如果实际高度小于图片100%高度，则不显示图片的100%高度
	{
		var imgheight=document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height);	
	}	
    */
   //window.alert (imgheight);

	/*if (document.documentElement.clientWidth>1600) //如果屏幕尺寸太大
	{
		var imgheight=700;
	}
	else
	{
		var imgheight=document.documentElement.clientHeight-200;	
	}*/

	//var imgwidth=imgheight*1.685;//老的比例
	var imgwidth=imgheight*2; //新的比例
	//var imgwidth=imgheight*(meme_s_width/meme_s_height);
	//window.alert (document.documentElement.clientHeight+"_"+imgwidth+"+"+meme_s_height+"_"+meme_s_width);
	var screenwidth=document.documentElement.clientWidth;
	var space_box_right=(screenwidth-imgwidth)/2;
	//alert(screenwidth);
	$("#meme").css({height:imgheight });
	$("#box_picture").css({ width: imgwidth });
	$("#box").css({ width: imgwidth+40 });
	//var imgheight=document.getElementById("meme").height;
	//var imgwidth=document.getElementById("meme").width;
	//alert();//得到宽度.然后,,要用js控制高度和宽度..
	//box_side_right  left 需要改变高度.
	$("#box_side_right").css({ height: imgheight, width:imgheight,right: space_box_right});
	$("#box_side_left").css({ height: imgheight, width:imgheight ,left:space_box_right});
	$("#box_arrow_right").css({right: space_box_right});
	$("#box_arrow_left").css({left: space_box_right});
}

//小图是 宽高比例是 0.835  大图的宽高比是 1.683  

function init()
{
	//var imgheight=document.getElementById("meme").height;
	//alert(window.screen.availHeight);
    //var bigImageHeight=getImageSize("BigImage");
	getHeight();
	//window.alert (bigImageHeight);
	/*if ((document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height))>=bigImageHeight) //如果实际高度大于等于图片100%高度，则显示图片的100%高度
	{
		var imgheight=bigImageHeight;
	}
	else //如果实际高度小于图片100%高度，则不显示图片的100%高度
	{
		var imgheight=document.documentElement.clientHeight-((window.screen.height*16/10-window.screen.width)/2+120*window.screen.width/window.screen.height);	
	}	*/
	/*var imgwidth=document.getElementById("meme").width;	
	if (document.documentElement.clientWidth>1600) //如果屏幕尺寸太大
	{
		var imgheight=700;
	}
	else
	{
		var imgheight=document.documentElement.clientHeight-200;	
	}*/

	//var imgheight=document.documentElement.clientHeight-200;
	$('#meme').css({ height:imgheight });
	//alert(imgheight);
	//var howwidth=(imgheight)/imgheight*imgwidth;
}
//setTimeout("init();getsize();",100);	//add in ajaxend
function getscreenwidth()
{
	var loadingwidth= document.documentElement.clientWidth;//width	
	loadingwidth=loadingwidth-80;
	var loadingheight=document.documentElement.clientHeight-80;
	//if(loadingwidth<663){window.resizeBy(663,loadingheight);}
	//if(loadingheight<378){window.resizeBy(loadingwidth,378);}
	//if(loadingwidth/loadingheight<663/378){window.resizeBy(663,378);}
	$('#ajaxdiv').css({ width:loadingwidth,height: loadingheight}); //兼容firefox;
}

//preload function 
function loadit()//2,3,4秒.分别载入
{	
	setTimeout("justload1('file2');",1000);
	setTimeout("justload2('file1');",2000);
	setTimeout("justload3('file3');",3000);
}

function justload1(one)
{
	var getinput=$('#'+one).val();
	//alert(getinput);
	var innerpic='<img src="'+getinput+'" width=1 height=1 />';
	var sourcehtml=$('#loadpic').val();
	$('#loadpic1').html(sourcehtml+innerpic);
}

function justload2(one)
{
	var getinput=$('#'+one).val();
	//alert(getinput);
	var innerpic='<img src="'+getinput+'" width=1 height=1 />';
	var sourcehtml=$('#loadpic').val();
	$('#loadpic2').html(sourcehtml+innerpic);
}

function justload3(one)
{
	var getinput=$('#'+one).val();
	//alert(getinput);
	var innerpic='<img src="'+getinput+'" width=1 height=1 />';
	var sourcehtml=$('#loadpic').val();
	$('#loadpic3').html(sourcehtml+innerpic);
}

function jsloadall(allcontent)
{
	var Inputall=document.getElementById("loadallpic");
	Inputall.innerHTML=allcontent;	
	//LoadAllImage();
}

function jsloadall2(allcontent)
{
	var Inputall=document.getElementById("loadallpic");
	Inputall.innerHTML=allcontent;	
}
//preload

getusername();
//getscreenwidth();//20081223 //beyond 20090515

