/* +++++
  Check User Input befor Submit.
  Author : tak@
  URL    : http://www.plus-5.com
  Version: 1.01
	Update : 2004. 9.14
	Copyright(C) Plus Five, All rights Reserved.
-------------------------------------------------*/
document.onkeydown = PF_checkKeyDown;
/* +++++
  SETTING VARIABLES
-------------------------------------------------*/
function check_form() {
	if (document.enterPush == 1) {
		document.enterPush = 0;
		return false;
	}
	var i, j;
	var arg = check_form.arguments;
	var targetForm = arg[0];
	var noErr = true;
	var errMsg = '';
	for(i=0; i<checkElements.length; i++){
		if (typeof(checkElements[i]) != "undefined") {
			var formElement = targetForm[checkElements[i][0]];
			if(PF_MatchData(targetForm, formElement, i) == 0){
				//alert(checkElements[i][2]);
				//if (checkElements[i][1] != "radio") formElement.focus();
				errMsg += checkElements[i][2] + "\n";
				noErr = false;
			}
		}
	}
	if (errMsg.length>0) alert(errMsg);
	return noErr;
}
/* +++++
  SETTING VARIABLES
-------------------------------------------------*/
function PF_MatchData(targetForm,formElement,n){
	var elementType = checkElements[n][1];
	var checkPoint = 0, checkValue = formElement.value;
	switch(elementType){
		case "mail" :
			checkValue = PF_shiftOneByte(checkValue);
			formElement.value = checkValue;
			if(checkValue.match(/.+@.+\..+/)){
				checkPoint = 1;
			}
			break;
			
		case "filter" :
			checkValue = PF_shiftOneByte(checkValue);
			formElement.value = checkValue;
			if(checkValue.match(/.+@.+\..+/)) {
				if (mailfilter(checkValue)==0) {
					checkPoint = 1;
				} else {
					checkElements[n][2] = filtermesg;
				}
			}
			break;
			
		case "number" :
			checkValue = PF_shiftOneByte(checkValue);
			formElement.value = checkValue;
			var numObj = checkValue.match(/[^0-9,]/g);
			if(!numObj && checkValue){
				checkPoint = 1;
			}
			break;
			
		case "url" :
			checkValue = PF_shiftOneByte(checkValue);
			formElement.value = checkValue;
			if(checkValue.match(/(http|https):\/\/.+\..+/)){
				checkPoint = 1;
			}
			break;
			
		case "retype" :
			checkValue = PF_shiftOneByte(checkValue);
			formElement.value = checkValue;
			var ret=targetForm[elementType].value;
			var type_retype = 1;
			if(checkValue == ret){
				checkPoint = 1;
			}
			break;
			
		case "upzero" :
			if(checkValue>0){
				checkPoint = 1;
			}
			break;
			
		case "radio" :
			for(var i=0; i<formElement.length; i++){
				if(formElement[i].checked){
					checkPoint = 1;
				}
				formElement[i].style.backgroundColor="#FFFFFF";
				var labelName = formElement[i].name + "_" + (i+1) + "_label";
				if(document.getElementById){
					document.getElementById(labelName).style.backgroundColor="#FFFFFF";
				}else{
					if(document.all){
						document.all[labelName].style.backgroundColor="#FFFFFF";
					}else{
						document.layers[labelName].bgColor="#FFFFFF";
					}
				}
			}
			break;
			
		default :
			if(checkValue != "" && typeof(checkValue) != "undefined"){
				checkPoint = 1;
			}
			// 2004.6.2
			if(elementType.indexOf("int_") != -1){
				var ketasu = elementType.substring(4, elementType.length);
				var regStr = '^\\d{' + ketasu + '}$';
				checkValue = PF_shiftOneByte(checkValue);
				formElement.value = checkValue;
				if(!checkValue.match(new RegExp(regStr, "g"))){
					checkPoint = 1;
				}
			}
	}
	//return checkPoint;
	// 2004.6.1
	var color16 = (checkPoint == 0) ? "#F1EEE4" : "#FFFFFF";
	switch(elementType){
		case "retype" :
			targetForm[elementType].style.backgroundColor = color16;
			break;
		
		case "radio" :
			for(var i=0;i<formElement.length;i++){
				formElement[i].style.backgroundColor = color16;
				var labelName = formElement[i].name + "_" + (i+1) + "_label";
				if(document.getElementById){
					document.getElementById(labelName).style.backgroundColor  = color16;
				}else{
					if(document.all){
						document.all[labelName].style.backgroundColor = color16;
					}else{
						document.layers[labelName].bgColor = color16;
					}
				}
			}
			break;

		default :
			if (checkPoint == 0) {
				formElement.style.backgroundColor = color16;
				formElement.style.borderWidth = "1px"
				formElement.style.borderColor = "#808080"
			}
	}
	return checkPoint;
}
/* +++++
  SETTING VARIABLES
-------------------------------------------------*/
function PF_checkKeyDown(ev) {
	var keys;
	if(document.all){
		keys = window.event.keyCode;
	}else{
		keys = ev.which;
	}
	if(keys == 13){
		document.enterPush = 1;
		
		return;
	}
}
// +++++
/*

  SETTING VARIABLES
-------------------------------------------------*/
function PF_shiftOneByte(checkText) {
	var twoByteGroup, oneByteGroup, checkChar, offSetNum, i;
	var tmp = "";
	oneByteGroup  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,/+-_:@';
	twoByteGroup  = '%uFF21%uFF22%uFF23%uFF24%uFF25%uFF26%uFF27%uFF28%uFF29%uFF2A%uFF2B%uFF2C%uFF2D%uFF2E%uFF2F%uFF30%uFF31%uFF32%uFF33%uFF34%uFF35%uFF36%uFF37%uFF38%uFF39%uFF3A';
	twoByteGroup += '%uFF41%uFF42%uFF43%uFF44%uFF45%uFF46%uFF47%uFF48%uFF49%uFF4A%uFF4B%uFF4C%uFF4D%uFF4E%uFF4F%uFF50%uFF51%uFF52%uFF53%uFF54%uFF55%uFF56%uFF57%uFF58%uFF59%uFF5A';
	twoByteGroup += '%uFF10%uFF11%uFF12%uFF13%uFF14%uFF15%uFF16%uFF17%uFF18%uFF19';
	twoByteGroup += '%uFF0E%uFF0C%uFF0F%uFF0B%uFF0D%uFF3F%uFF1A%uFF20';
	twoByteGroup = unescape(twoByteGroup);
	for(i=0; i<checkText.length; i++){
		checkChar = checkText.charAt(i);
		offSetNum = twoByteGroup.indexOf(checkChar, 0);
		if (offSetNum != -1) { checkChar = oneByteGroup.charAt(offSetNum); }
		tmp += checkChar;
	}
	return tmp;
}
/*
  Original Script by Plus Five.
  Author : tak@
  URL    : http://www.plus-5.com
  Version: 1.00
	Update : 2005. 9. 1
	Copyright(C) Plus Five, All rights Reserved.
-------------------------------------------------*/
function check(obj) {
	var postNum = obj.value;
	if ((postNum.indexOf("-") > 0 && postNum.length == 8) || (postNum.indexOf("-") < 0 && postNum.length == 7)) {
		input_address(postNum, baseURL+'unit/dummy.php');
		if (postNum.indexOf("-") < 0) {
			obj.value = postNum.substr(0, 3) + "-" + postNum.substr(3, postNum.length);
		}
	}
}
function input_address(postNum, file) {
	var post = '';
	post += encodeURIComponent('mode');
	post += '=';
	post += encodeURIComponent('post');
	post += '&';
	post += encodeURIComponent('post');
	post += '=';
	post += encodeURIComponent(postNum);
	xmlhttp = createHttpRequest();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			checkResponse('address');
		}
		xmlhttp.open("POST", file, true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlhttp.send(post);
		return false;
	}
	return true;
}
function checkResponse(id) {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			document.getElementById(id).value = xmlhttp.responseText;
		}
	}
}
function createHttpRequest() {
	if (window.ActiveXObject) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				return null;
			}
		}
	} else if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		return null
	}
}
/*
  Original Script by Plus Five.
  Author : tak@
  URL    : http://www.plus-5.com
  Version: 2.00
	Update : 2004.11.13
	Copyright(C) Plus Five, All rights Reserved.
-------------------------------------------------*/
function P5_checkFlashPlayer() {
	var myVer = 0;
	var keyWord = "Shockwave Flash ";
	var s = 0;
	var e = 0;
	var serchStr = '';
	// for Windows IE.
	if (document.userSystem.osShortName == "win" && document.userSystem.browserShortName == "ie") {
		document.open();
		document.write('<scr'+'ipt type="text/VBScript">\n');
		document.write('on error resume next \n');
		document.write('Dim IsFlash \n');
		document.write('Dim FlashVersion \n');
		document.write('FlashVersion = 0 \n');
		document.write('IsFlash=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash")) \n');
		document.write('FlashVersion=Left(Hex(Int(CreateObject("ShockwaveFlash.ShockwaveFlash").FlashVersion)),1)\n');
		document.write('if Err.Number>0 Then \n');
		document.write('FlashVersion = 0 \n');
		document.write('end if\n');
		document.write('</scr'+'ipt>\n');
		document.close();
		myVer = FlashVersion;
	}
	// for Other Browsers.
	if (navigator.plugins && navigator.plugins.length > 0) {
		for (i=0; i<navigator.plugins.length; i++) {
			serchStr = navigator.plugins[i].description;
			if (serchStr.indexOf(keyWord) != -1) {
				s = serchStr.indexOf(keyWord);
				s += keyWord.length;
				e = serchStr.indexOf(" ", s);
				myVer = serchStr.substring(s, e);
			}
		}
	}
	return myVer;
}
function P5_putFlashMovie() {
	// Get This Arguments.
	// Version, ObjectID, Source, Width, Height, Bgcolor, DTD, FlashVars, AlternateType, Alternate...
	var args = P5_putFlashMovie.arguments;
	var dtd = 0;
	var version = args[0];
	var movieID = args[1];
	var moviePath = args[2];
	var movieWidth = args[3];
	var movieHeight = args[4];
	var bgColor = (typeof(args[5])!="undefined") ? args[5] : '#FFFFFF';
	if (typeof(args[6])!="undefined") dtd = args[6];
	var flashVarsObject = (typeof(args[7])!="undefined") ? '<param name="FlashVars" value="' + args[7] + '">\n' : '';
	var flashVarsEmbed = (typeof(args[7])!="undefined") ? ' FlashVars="' + args[7] + '"' : '';
	var flashDisabled = (P5_checkFlashPlayer() < version);
	var protocol = location.protocol;
	// Output Movie.
	document.open();
	if (flashDisabled) {
		if (typeof(args[8])!="undefined" && args[8]>0) {
			var useMap = (typeof(args[10])!="undefined") ? ' usemap="#' + args[10] + '"' : '';
			if (args[8]==1) {
				if(typeof(args[11])!="undefined") movieWidth=args[11];
				if(typeof(args[12])!="undefined") movieHeight=args[12];
				document.write('<div id="' + movieID + '">\n');
				document.write('<img src="' + args[9] + '" width="' + movieWidth + '" height="' + movieHeight + '" alt=""' + useMap + ' />\n');
				document.write('</div>\n');
			} else if (args[8]==2) {
				document.write('<table id="' + movieID + '_tb"><tr><td>\n');
				document.write('<img src="' + args[9] + '" alt=""' + useMap + ' />\n');
				document.write('</td></tr></table>\n');
			}
		} else {
			document.write('<p id="get-flash"><a href="'+protocol+'//www.macromedia.com/jp/shockwave/download/index.cgi?P1_Prod_Version&#61;ShockwaveFlash&amp;Lang&#61;Japanese" id="adobe" target="_blank"><img src="'+protocol+'//www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" width="88" height="31" alt="Please Download Flash Player." /></a><a href=\"old.html\" id="older"><em>‹ŒƒTƒCƒg</em></a></p>\n');
		}
	} else {
		if (dtd > 0) {
			document.write('<object id="' + movieID + '" type="application/x-shockwave-flash" data="' + moviePath + '" width="' + movieWidth + '" height="' + movieHeight + '">\n');
			document.write('<param name="movie" value="' + moviePath + '">\n');
			document.write( flashVarsObject );
			document.write('<param name="bgcolor" value="' + bgColor + '">\n');
			document.write('</object>\n');
		} else {
			document.write('<div id="' + movieID + '">\n');
			document.write('<object id="' + movieID + '-obj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+protocol+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + ',0,0,0" width="' + movieWidth + '" height="' + movieHeight + '">\n');
			document.write('<param name="movie" value="' + moviePath + '">\n');
			document.write( flashVarsObject );
			document.write('<param name="bgcolor" value="' + bgColor + '">\n');
			document.write('<embed id="' + movieID + '-emb" src="' + moviePath + '"' + flashVarsEmbed + ' bgcolor="' + bgColor + '" width="' + movieWidth + '" height="' + movieHeight + '" type="application/x-shockwave-flash" pluginpage="'+protocol+'//www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>\n');
			document.write('</object>\n');
			document.write('</div>\n');
		}
	}
	document.close();
}
/*
  Check User System
-------------------------------------------------*/
function P5_getUserSystem() {

	var key, index, keyIndex, keyIndexEnd, versionKey, i, j;
	var uaString = P5_getUserSystem.arguments[0].toUpperCase();

	this.osLongName = "---";
	this.osShortName = "---";
	this.browserLongName = "---";
	this.browserShortName = "---";
	this.browserVersion = "---";

	var OSTYPE = new Object();
	OSTYPE['W95'] = new P5_setOS('Windows 95','win','WINDOWS 95,WIN95');
	OSTYPE['W98'] = new P5_setOS('Windows 98','win','WINDOWS 98,WIN98,Win 9x');
	OSTYPE['WCE'] = new P5_setOS('Windows CE','win','WINDOWS CE,WINCE');
	OSTYPE['WME'] = new P5_setOS('Windows Me','win','WINDOWS ME,WINME');
	OSTYPE['WNT'] = new P5_setOS('Windows NT','win','WINDOWS NT),WINDOWS NT 3,WINDOWS NT 4,WINDOWS NT;,WINNT');
	OSTYPE['W2K'] = new P5_setOS('Windows 2000','win','WINDOWS 2000,WINDOWS NT 5.0,WIN2000');
	OSTYPE['WXP'] = new P5_setOS('Windows XP','win','WINDOWS NT 5.1,WINDOWS NT 5.2,WINDOWS XP');
	OSTYPE['WVS'] = new P5_setOS('Windows Vista','win','WINDOWS NT 6.0,WINDOWS NT 5.2,WINDOWS VISTA');
	OSTYPE['MAC'] = new P5_setOS('Macintosh','mac','MAC');
	OSTYPE['LNX'] = new P5_setOS('Linux','lnx','LINUX');
	OSTYPE['BSD'] = new P5_setOS('FreeBSD','bsd','FREEBSD');
	OSTYPE['X11'] = new P5_setOS('UNIX','x11','X11');
	OSTYPE['OSX'] = new P5_setOS('Mac OS X','osx','OS X');

	var BROWSERS = new Object();
	BROWSERS['MZ'] = new P5_setBrowser('Mozilla','mz','GECKO');
	BROWSERS['IE'] = new P5_setBrowser('Internet Explorer','ie','MSIE');
	BROWSERS['AO'] = new P5_setBrowser('AOL','ao','AOL');
	BROWSERS['SF'] = new P5_setBrowser('Safari','sf','SAFARI');
	BROWSERS['OP'] = new P5_setBrowser('Opera','op','OPERA');
	BROWSERS['OW'] = new P5_setBrowser('OmniWeb','ow','OMNIWEB');
	BROWSERS['IC'] = new P5_setBrowser('iCab','ic','ICAB');
	BROWSERS['NS'] = new P5_setBrowser('Netscape','ns','NETSCAPE,NETSCAPE6');
	BROWSERS['NN'] = new P5_setBrowser('Netscape Navigator','nn','MOZILLA');
	BROWSERS['FF'] = new P5_setBrowser('Firefox','ff','FIREFOX');
	
	var UNIXDETAIL = new Array("LNX","BSD");
	var checkVersionExp01 = new Array(' ', '/', '-', '');
	var checkVersionExp02 = new Array(';', ' ', '(', '[', ')', '+', '-', '/');

	uaString = " " + uaString + ";";
	
	index = 0;
	for (key in OSTYPE) {
		for (i=0; i<OSTYPE[key].keyword.length; i++) {
			keyIndex = uaString.indexOf(OSTYPE[key].keyword[i].toUpperCase());
			if (keyIndex > index) {
				this.osLongName = OSTYPE[key].longName;
				this.osShortName = OSTYPE[key].shortName;
				index = keyIndex;
			}
		}
	}

	// UNIX is reary?
	if (this.osShortName == "x11") {
		for (i=0; i<UNIXDETAIL.length; i++) {
			key = UNIXDETAIL[i];
			for (j=0; j<OSTYPE[key].keyword.length; j++) {
				if (uaString.indexOf(OSTYPE[key].keyword[j].toUpperCase()) > 0) {
					this.osLongName = OSTYPE[key].longName;
					this.osShortName = OSTYPE[key].shortName;
				}
			}
		}
	}

	// Mac OS is reary?
	if (this.osShortName == "mac") {
		var myPlugin = navigator.plugins;
		for (i=0; i<myPlugin.length; i++) {
			if(typeof(myPlugin[i].filename)!="undefined"){
				if (myPlugin[i].filename.indexOf(".plugin") != -1 || myPlugin[i].filename.indexOf(".app") != -1) {
					this.osLongName = OSTYPE["OSX"].longName;
					this.osShortName = OSTYPE["OSX"].shortName;
				}
			}
		}
		if (uaString.indexOf("MSIE 5.2") > 0) {
			this.osLongName = OSTYPE["OSX"].longName;
			this.osShortName = OSTYPE["OSX"].shortName;
		}
	}

	index = 0;
	for (key in BROWSERS) {
		for (i=0; i<BROWSERS[key].keyword.length; i++) {
			keyIndex = uaString.indexOf(BROWSERS[key].keyword[i].toUpperCase());
			if (keyIndex > index) {
				this.browserLongName = BROWSERS[key].longName;
				this.browserShortName = BROWSERS[key].shortName;
				versionKey = BROWSERS[key].keyword[i].toUpperCase();
				index = keyIndex;
			}
		}
	}

	// Navigator is reary?
	if (this.browserShortName == "nn" && uaString.indexOf("COMPATIBLE")>0) {
		this.browserLongName = "---";
		this.browserShortName = "---";
	}

	// Version Check
	if (this.browserLongName != "---") {
		for (i=0; i<checkVersionExp01.length; i++) {
			key = versionKey + checkVersionExp01[i];
			if ( ( keyIndex = uaString.indexOf(key) ) > 0 ) break;
		}
		// Mozilla
		if ( key == 'GECKO/' ) {
			key = 'RV:';
			keyIndex = uaString.indexOf(key);
		}
		keyIndex = keyIndex + key.length;
		index = uaString.length;
		for (i=0; i<checkVersionExp02.length; i++) {
			if ((key = uaString.indexOf(checkVersionExp02[i], keyIndex)) > 0) {
				if (key < index) {
					keyIndexEnd = key;
					index = keyIndexEnd;
				}
			}
		}
		this.browserVersion = uaString.substring(keyIndex, keyIndexEnd);
	}

	this.monitorWidth = screen.width;
	this.monitorHeight = screen.height;

}
/*
  SETTING OS LIST
-------------------------------------------------*/
function P5_setOS(longName,shortName,keyWord) {
	this.longName = longName;
	this.shortName = shortName;
	this.keyword = keyWord.split(",");
}
/*
  SETTING BROWSER LIST
-------------------------------------------------*/
function P5_setBrowser(longName,shortName,keyWord) {
	this.longName = longName;
	this.shortName = shortName;
	this.keyword = keyWord.split(",");
}

function show_div(objName) {
	var frame = document.getElementById('panel');
	var obj = document.getElementById(objName);
	frame.innerHTML = '<div class="panel" style="background-image:url(../skin/images/'+objName+'_bg.jpg)"><div id="'+objName+'-inner">'+obj.innerHTML+'</div></div>';
	return false;
}
function hide_div(objName) {
	var frame = document.getElementById('panel');
	frame.innerHTML = '';
	return false;
}
function submit_alert(formObj,id) {
	for(i=0; i<checkElements.length; i++){
		if (typeof(checkElements[i]) != "undefined") {
			var formElement = formObj[checkElements[i][0]];
			if(PF_MatchData(formObj, formElement, i) == 0){
				alert(checkElements[i][2]);
				return false;
			}
		}
	}
	var url = formObj.action;
	var post = '';
	for (i=0; i<formObj.length; i++) {
		if (formObj[i].type == 'checkbox' && !formObj[i].checked) continue;
		post += encodeURIComponent(formObj[i].name);
		post += '=';
		post += encodeURIComponent(formObj[i].value);
		post += '&';
	}
	id += '-inner';
	check_alert(post, url, id);
	return false;
}
function check_alert(post, file, id) {
	xmlhttp = createHttpRequest();
	if (xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			return_alert(id);
		}
		xmlhttp.open("POST", file, true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlhttp.send(post);
		return false;
	}
	return true;
}
function return_alert(id) {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			document.getElementById(id).innerHTML = xmlhttp.responseText;
		}
	}
}

function setLayout() {
	var L1 = document.getElementById('push-out');
	var L2 = document.getElementById('surprise-out');
	var y = (L1.clientHeight<L2.clientHeight) ? L2.clientHeight : L1.clientHeight;
	var A1 = document.getElementById('push-link');
	var A2 = document.getElementById('surprise-link');
	L1.style.height = y+'px';
	L2.style.height = y+'px';
	A1.style.top = (y-22)+'px';
	A2.style.top = (y-22)+'px';
}

function rollout(obj, pos) {
	obj.style.BackgroundPosition = pos;
}

function mailfilter(mail) {
	var file = '../unit/dummy.php';
	var post = '';
	post += encodeURIComponent('mode');
	post += '=';
	post += encodeURIComponent('mailfilter');
	post += '&';
	post += encodeURIComponent('email');
	post += '=';
	post += encodeURIComponent(mail);
	xmlhttp = createHttpRequest();
	if (xmlhttp) {
		xmlhttp.open("POST", file, false);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		xmlhttp.send(post);
		return parseInt(xmlhttp.responseText);
	}
}

function openTheWindow(url, w, h) {
	var width = parseInt(w)+30;
	var height = parseInt(h)+30;
	P5_openTheWindow(url,'photo',0,0,0,0,0,0,1,width,height,10,10,0);
}
/*
  Open Sub Window
	Update 2005.04.20
-------------------------------------------------*/
function P5_openTheWindow() {
	var windowOptions = '';
	var arg = P5_openTheWindow.arguments;
	var url = arg[0];
	var windowName = arg[1];
	arg[11] += "";
	arg[12] += "";
	if (arg[11].indexOf('%')<0) {
		var pointY = arg[11];
	} else {
		var offsetY = Math.floor(arg[10]/2);
		var parcent = (parseInt(arg[11]))/100;
		if (parcent > 1) parcent=1;
		var pointY = Math.floor(screen.height*parcent)-offsetY;
		if (pointY < 0) pointY=0;
		if (pointY > screen.height-arg[10]) pointY=screen.height-arg[10];
	}
	if (arg[12].indexOf('%')<0) {
		var pointX = arg[12];
	} else {
		var offsetX = Math.floor(arg[9]/2);
		var parcent = (parseInt(arg[12]))/100;
		if (parcent > 1) parcent=1;
		var pointX = Math.floor(screen.width*parcent)-offsetX;
		if (pointX < 0) pointX=0;
		if (pointX > screen.width-arg[9]) pointX=screen.width-arg[9];
	}
	if (arg[9]>screen.width) {
		arg[9] = screen.width;
	}
	if (arg[10]>screen.height) {
		arg[10] = screen.height;
	}
	windowOptions += "toolbar=" + arg[2];
	windowOptions += ",location=" + arg[3];
	windowOptions += ",directories=" + arg[4];
	windowOptions += ",status=" + arg[5];
	windowOptions += ",menubar=" + arg[6];
	windowOptions += ",scrollbars=" + arg[7];
	windowOptions += ",resizable=" + arg[8];
	windowOptions += ",width=" + arg[9];
	windowOptions += ",height=" + arg[10];
	windowOptions += ",top=" + pointY;
	windowOptions += ",left=" + pointX;
	windowOptions += ",screenY=" + pointY;
	windowOptions += ",screenX=" + pointX;
	document[windowName] = window.open(url, windowName, windowOptions);
	if (typeof(arg[13])!="undefined" && arg[13] == 1) { document[windowName].resizeTo(arg[9], arg[10]); }
	document[windowName].focus();
}
/*
  Close Sub Window
-------------------------------------------------*/
function P5_closeTheWindow() {
	if (window.opener) {
		if (!window.opener.closed) {
			window.close();
			return false;
		}
		return false;
	}
	return true;
}
function P5_setWindow(w,h,t,l) {
	moveTo(t,l);
	resizeTo(w,h);
}

document.userSystem = new P5_getUserSystem(navigator.userAgent);

