// JavaScript Document.
$(document).ready(function(){

						   });



function OpenWindow(titlestr,www,wwh){

if (!$('#shadow').length ){



var shadow = $(document.createElement("div"));
shadow.attr({"id":"shadow"});


var windowOut = $(document.createElement("div"));
windowOut.attr({"id":"wout"});
windowOut.css({
			  width:www + 'px',
			  height:wwh + 'px'
			  });


var wtitle = $(document.createElement("div"));
wtitle.attr({
			id:"wtitle",
			title:"Close",
			alt:"Close"
			});

wtitle.text(titlestr);
	

var wclose = $(document.createElement("span"));
wclose.attr({
			'class':"wclose",
			id:"wclose"
			});

wclose.html('<img src="ime/close.gif" width="20" height="18" title="閉じる" />');
windowOut.append(wclose);

var bcontent = $(document.createElement("div"));
bcontent.attr({"id":"bcontent"});
var cw = www;//-30
var ch = wwh - 55;
bcontent.css({
			  width:cw + 'px',
			  height:ch + 'px'
			  });

$('body').append(shadow);
$("#main_out").append(windowOut);
windowOut.append(wtitle);
windowOut.append(bcontent);




var ww = $(document).width();
var h = $(document).height();
var position = shadow.css("position");


    if (position != 'fixed') {
Resized();
window.onresize = Resized;
 }
						   
var halfwindowout = Math.round(www / 2);
	var act = Math.round(ww / 2 - halfwindowout);
act = act + 'px';	

windowOut.css({"left":act});

var hw = $(window).height();
var halfheight = Math.round(wwh / 2);
var heighthalf = Math.round(hw / 2 - halfheight);
heighthalf = heighthalf + 'px';
//alert(heighthalf);


version=0
if (navigator.appVersion.indexOf("MSIE")!=-1){
temp=navigator.appVersion.split("MSIE")
version=parseFloat(temp[1])
}

//if (version>=7.0) {//NON IE browser will return 0

if((version == 0) || (version >= 7.0)){

if(hw >= wwh){
windowOut.css({"top":heighthalf});
}else{
windowOut.css({"top":3 + 'px'});	
}
}




windowOut.draggable({
handle:'#wtitle'
});



$(".wclose").click(function(){
				   
	shadow.remove();
	windowOut.remove();
 });

}
 }


function Resized(theEvent){ 
var ww = $(document).width();
var h = $(document).height();
      $("#shadow").width(ww);
	  $("#shadow").height(h);
	}
	
	
function ErrorShadow(Etitle,Etext){
//alert('koko');
var ES = $(document.createElement("div"));
ES.attr({
			'class':"ES",
			id:"ES"
			});

var ESTitle = $(document.createElement("div"));
ESTitle.attr({"id":"ESTitle"});

var EContent = $(document.createElement("div"));
EContent.attr({"id":"EContent"});

var buttonout = $(document.createElement("div"));
buttonout.attr({"id":"buttonout",
			   'align':'center'
			   });

/*var Ebutton = $(document.createElement("div"));
Ebutton.attr({id:"Ebutton",
			 'class':'button'
			 });*/

var Ebutton = $(document.createElement("input"));
/*Ebutton.type = 'button';
Ebutton.value = 'yyy';
Ebutton.name = 'button1';*/

Ebutton.attr({
			 'id':'b_1',
			 type : 'button',
			 value : 'OK',
			 name : 'b_1',
			 'class':'button2'
			 });


var sh = $(document.createElement("div"));
sh.attr({"id":"sh"});
var sf = $("#wout").height() - 25;
sh.css({
	   height:sf + 'px'
	   });

//Ebutton.text('OK');
$("#wout").append(ES);
$("#wout").append(sh);
ES.append(ESTitle);
ES.append(EContent);
ES.append(buttonout);
buttonout.append(Ebutton);

ESTitle.text(Etitle);
EContent.text(Etext);

var wi = $("#wout").width() / 2 - 125;
var hi = $("#wout").height() / 2 - 80;

ES.css({
	   top:hi + "px",
	   left:wi + "px"
	   });
//$("#ES").text(text);

ES.draggable({
handle:'#ESTitle'
});
Ebutton.click(function(){
					   ES.remove();
					   sh.remove();
					   });

}


