// JavaScript Document

function createXMLHttpRequest() 

{ 

	var ua; 

  	if(window.XMLHttpRequest) 

	{ 

		try 

		{ 

			ua = new XMLHttpRequest(); 

		} 

		catch(e) 

		{ 

			ua = false; 

		} 

	} 

	else if(window.ActiveXObject) 

	{ 

		try 

		{ 

			ua = new ActiveXObject("Microsoft.XMLHTTP"); 

		} 

		catch(e) 

		{ 

			ua = false; 

		} 

	} 

	return ua; 

} 



var req = createXMLHttpRequest(); 



function show_img1(site_path,img_path)

{

	var windowWidth = 500;

	var windowHeight = 500;

	var centerWidth = (window.screen.width - windowWidth) / 2;

    var centerHeight = (window.screen.height - windowHeight) / 2;

	var windowName = "full_img";

	var windowUri = site_path + "img_popup.php?img_path=" + img_path;



    newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 

        ',height=' + windowHeight + 

        ',left=' + centerWidth + 

        ',top=' + centerHeight);



    newWindow.focus();



	if(!newWindow)

	{

		alert("Pop Blocker is on in your browser.");

	}

}



function show_img(t,id)

{

	req.open('get', 'get_image_size.php?type=' + t + "&id=" + id); 

	req.onreadystatechange = handleResponse_h; 

	req.send(null); 

}



function handleResponse_h() 

{ 	

	var vloadtext = document.getElementById("h_check");	



	if(req.readyState == 4)

	{ 

		



		var response = req.responseText; 

		document.getElementById("loading").style.display="none";

		var up = response.split("---");

		var msg = up[0];

		var res = up[1];

		var windowWidth = up[2];

		var windowHeight = up[3];

		if(msg=="error")

		{

			alert(res);

		}

		else if(msg=="found")

		{

			windowWidth = parseInt(windowWidth);

			windowHeight = parseInt(windowHeight);

			var centerWidth = (window.screen.width - windowWidth) / 2;

			var centerHeight = (window.screen.height - windowHeight) / 2;

			var windowName = "full_img";

			var windowUri = "img_popup.php?det=" + res;

			newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 

				',height=' + windowHeight + 

				',left=' + centerWidth + 

				',top=' + centerHeight);



			if(!newWindow)

			{

				alert("ポップアップ・ブロックを無効にして下さい。");

			}

			else

			{

				newWindow.focus();

			}

		}

	} 

	else

	{

		document.getElementById("loading").style.display="block";

	}

}



function unique(a) {

   var r = new Array();

   o:for(var i = 0, n = a.length; i < n; i++) {

      for(var x = i + 1 ; x < n; x++)

         if(a[x]==a[i]) 

		 {

		     r[r.length] = a[x];

		 }

		 continue o;

   }

   return r;

}





function echeck(str,msg) {



		var at="@";

		var dot=".";

		var lat=str.indexOf(at);

		var lstr=str.length;

		var ldot=str.indexOf(dot);

		if (str.indexOf(at)==-1){

		   alert(msg);

		   return false;

		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   alert(msg);

		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    alert(msg);

		    return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

			 alert(msg);

		    return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		      alert(msg);

		    return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		   alert(msg);

		    return false

		 }

		

		 if (str.indexOf(" ")!=-1){

			  alert(msg);

		    return false

		 }



		return true;

	}