var secret="";var initflag=false;var keyVal=-1;var keyCode=-1;var ver=navigator.appVersion;var isNetscape=(navigator.appName=="Netscape");var screenW=640,screenH=480;var myFlags=new Array ("ar","arab","brazil","canada","china","philippines","france","germany","heb","india","italy","portugal","ru","spain","sweden","turkey","uk","us","colombia","morocco");var myPics=new Image();var myIcons=new Image();var ghost1=new Image(),ghost2=new Image(),ghost3=new Image(),MyGhost=new Image();PreLoadImg();GetScreenSize();function PageLoad(ghost_name,width,height){MyGhost=preloadImage ("logo","",ghost_name,"gif",width,height);if(Lang!="FB"){showGhost();document.myMain.txtQuestion.readOnly=true;document.myMain.txtRequest.focus();}	document.onmousedown=right;if(document.layers) window.captureEvents(Event.MOUSEDOWN);window.onmousedown=right;}function PreLoadImg(){ghost1=preloadImage ("logo","","ghost_logo","gif",300,85);ghost2=preloadImage ("logo","","ghost_tarot","gif",100,100);ghost3[0]=preloadImage ("logo","","animated-ghost","gif",48,58);ghost3[1]=preloadImage ("logo","","ghostanimated","gif",53,56);ghost3[2]=preloadImage ("logo","","blue_ghost","gif",49,53);/*myPics=preloadImages ("flags","flag_",myFlags,"gif",28,20);*/;myIcons= preloadImages ("icons","ADD",new Array ("facebook","twitter","favorites","more"),"png",32,32);} function preloadImage(path,prefix,pic,ext,width,height){return preloadImages(path,prefix,new Array(pic),ext,width,height);}function preloadImages(path,prefix,pics,ext,width,height){var images=new Array;var picsLength=pics.length;for(var picNum=0;picNum<picsLength;picNum++) {images[picNum]=new Image(width,height);images[picNum].src=(path + "/" + prefix + pics[picNum] + "." + ext);/* alert(images[picNum].src);*/} if(picsLength==1) return(images[0]);else	return(images);}function GetScreenSize(){if(parseInt(ver)>3){ screenW=screen.width; screenH=screen.height;}	else if(isNetscape && parseInt(ver)==3 && navigator.javaEnabled()) {var jToolkit=java.awt.Toolkit.getDefaultToolkit(); var jScreenSize=jToolkit.getScreenSize(); screenW=jScreenSize.width; screenH=jScreenSize.height;}}function WriteMsg(sMessage){document.write(sMessage);}function ShowImage(imgObj,sAlt){WriteMsg('<a onclick="ShowHide(\'myWindow\')"><img alt="');WriteMsg(sAlt);WriteMsg('" src="' + imgObj.src + '" width="' + imgObj.width + '" height="' + imgObj.height + '" border="0"/></a>');}function pausecomp(millis){var date=new Date();var curDate=null;do{ curDate=new Date();} 	while(curDate-date < millis);} function showGhost(){var randomGhost=Math.floor((Math.random()*3));document.getElementById("lblAnswer").innerHTML="<a onclick='showGhost()'><img alt='" + ghostMsg + "' src='" + ghost3[randomGhost].src + "' width='" + ghost3[randomGhost].width + " height='" + ghost3[randomGhost].height + " border='0'/><a/>";}function setVisibility(obj,IsVisible){var sVisibility=(IsVisible==1) ? "visible" : "hidden";obj.style.visibility=sVisibility;}function showSecret(){var random=Math.floor((Math.random()*(E.length)));var answer=document.myMain.txtRequest.value;setVisibility(document.myMain.btnClear);setVisibility(document.myMain.btnEnter);setVisibility(document.myMain.btnNew,1);document.myMain.txtRequest.readOnly=true;document.myMain.btnNew.focus();setLastChar(document.myMain.btnEnter,"");setLastChar(document.myMain.txtQuestion,"?");if(answer!=Request1&& answer!=Request2) document.getElementById("lblAnswer").innerHTML="<b>" + PeterAnswer + " " + "<font color='#CC0000'>" + E[random] + "</font></b>";else if(secret.length==0) document.getElementById("lblAnswer").innerHTML="<b>" + PeterAnswer + " " + "<font color='#006333'>" + S[random] + "</font></b>";else	document.getElementById("lblAnswer").innerHTML="<b>" + "<font color='#006600'>" + PeterAnswer + " " + "</font>" + secret+ "</b>";}function newQuestion(){ 	secret="";initflag=false;showGhost();setVisibility(document.myMain.btnClear,1);setVisibility(document.myMain.btnEnter);setVisibility(document.myMain.btnNew);document.myMain.txtRequest.value="";document.myMain.txtQuestion.value="";document.myMain.txtRequest.readOnly=false;document.myMain.txtQuestion.readOnly=true;document.myMain.btnNew.readOnly=true;document.myMain.txtRequest.focus();ShowHide('myWindow',true);} function questionKeyDown(e){ 	var keySel;if(window.event){ 	if(window.event.type=="keydown") keyCode=-1;if(window.event.type=="keypress") keyCode=window.event.keyCode;if(parseInt(keyCode)>0) keySel=keyCode;else keySel=window.event.keyCode;} 	else { 	if(e.type=="keydown") {keyVal=e.which;keyCode=-1;} 	if(e.type=="keypress") keyCode=e.which;if(parseInt(keyCode)>0) keySel=keyCode;else if((parseInt(keyVal)>0) && (e.which<1)) keySel=keyVal;else keySel=e.which;} 	return (parseInt(keySel));} function questionClick(e){keySel=questionKeyDown(e);if((keySel==8) && (initflag))del1char(e);}function del1char(e){if(secret.length>0) secret=secret.substring(0,secret.length - 1);if(secret.length==0) 	initflag=false;}function clearRequest(obj,newChar){var objVal=obj.value;var strLength=objVal.length;var NewVal="";var char1="";var ascii;var StopSpace=false ;if(newChar==":"){for(var i=0;i<strLength;i++){ char1=objVal.charAt(i); ascii=char1.charCodeAt(0); if(ascii==58) StopSpace= true;if(ascii!=0 && ascii!=13 && !(StopSpace) && !((ascii==32 && i==(strLength-1)))) 	NewVal += char1;}	document.myMain.txtRequest.value=NewVal;}}function getLastChar(obj){var objVal=obj.value;var strLength=objVal.length;var lchar="";if(strLength>0) lchar=objVal.charAt((strLength) - 1);return lchar;}function setLastChar(obj,newChar){var objVal=obj.value;clearRequest(obj,newChar); 	if(getLastChar(obj)!=newChar) obj.value += newChar;}function keypress(e,obj){ if(document.myMain.txtRequest.readOnly==false){if(document.myMain.txtRequest.value==""){ 	secret="";initflag=false;}	questionKeyDown(e);if(keyCode!=58){if((obj.value.length==0) && (keyCode!=0)){ keyCode=String.fromCharCode(keyCode).toUpperCase().charCodeAt(0);}	if((initflag) || (keyCode==46)){if(keyCode!=8) getTheSecret(e,obj);if(keyCode==46) initflag=!initflag;}	else{if(keyCode!=8)  getCodeVal(e,keyCode,obj);}}  }} function keyup(e,obj) { 	if((obj.value.length>2) && (keyCode==13)){setLastChar(document.myMain.txtRequest,":");keyCode=58;}	if(keyCode==58){ 	document.myMain.txtRequest.readOnly=true;document.myMain.txtQuestion.readOnly=false;document.myMain.txtQuestion.focus();}}function getTheSecret(e,obj){var iLen=obj.value.length;if(keyCode!=46) secret += String.fromCharCode(keyCode);if(iLen < Request1.length){charCode=Request1.charCodeAt(iLen);}	else{if(isNetscape && ver.indexOf("Safari")==-1) charCode=32;else	charCode=0;}	getCodeVal(e,charCode,obj);}function questionKeyUp(e,obj){ 	var isEnter=0;var iLen=obj.value.length;if(document.myMain.txtQuestion.readOnly==false){questionKeyDown(e);if((iLen==0) && (keyCode!=0) && (keyCode!=8) && (keyCode!=63)) {keyCode=String.fromCharCode(keyCode).toUpperCase().charCodeAt(0);getCodeVal(e,keyCode,obj);}	if(iLen>2 || iLen>1 && keyCode!=13){setVisibility(document.myMain.btnEnter,1);isEnter=1;}	if(keyCode==13 && (iLen>3 || iLen>2 && isEnter==1)) keyCode=63;	if(keyCode==63) {getCodeVal(e,63,obj);showSecret();}} else{var objReq=document.myMain.txtRequest;var sLastChar=getLastChar(objReq);	if(sLastChar.charCodeAt(0)!=58){getCodeVal(e,keyCode,obj);obj.value="";objReq.focus();objReq.value=objReq.value;if((objReq.value.length)>0){if((Lang=="HB" || Lang=="UA")) 	alert("(:) " + colonMsg);	else 	alert(colonMsg + " (:)");}} else{  StopSpace= true;keyCode=58;objReq.focus();document.myMain.txtQuestion.readOnly=false;document.myMain.txtQuestion.focus();}	}}function getCodeVal(e,charCode,obj){ 	if(window.Event){ 	if(keyCode!=0) {e.charcode=charCode;strCodeVal=String.fromCharCode(e.charcode);if(e.stopPropagation) e.stopPropagation();if(e.preventDefault) e.preventDefault();obj.value += strCodeVal;}} else 	e.keyCode=charCode;} function right(e){if(isNetscape && (e.which==3 || e.which==2)) return false;else if(ver.indexOf("MSIE")>-1 && (event.button==2 || event.button==3)){alert(rightMsg);return false;}	return true;}function NetscapeBR(){if(isNetscape) WriteMsg("<br/>");}function ShowHide(elementId,bHide){var element=document.getElementById(elementId);if(element.style.display!="block" && !(bHide)){if((Lang=="HB" || Lang=="UA") && !(isNetscape)){var winW=630,winH=460;if(parseInt(ver)>3) {winW=document.body.offsetWidth;	winH=document.body.offsetHeight;} var x=(winW / 2) - (element.offsetWidth / 2);var y=(winH / 2) - (element.offsetHeight / 2);myWindow.style.top=y+10;myWindow.style.left=x-200;}	element.style.display="block";jump2field(document.myForm.myName);}	else	element.style.display="none";}function checkTheName(form,message){if(isFieldBlank(form.myName) || isNotValidName(form.myName)){alert(message);founderror=true;jump2field(form.myName);return true;}	else	return false;}function checkName(form,message){var isError=checkTheName(form,message);if(isError) return false;else{form.submit();return true;}}function checkForm(form,message){var isError=checkTheName(form,message);if(isError) return false;else{var PageLang=form.elements["myLang"].value;form.action="Peter"+PageLang+".aspx";form.submit();return true;}}function ClearName(form){form.hName.value=".";form.myName.value="";}function Reset1(form,isReset){var PageLang=form.elements["myLang"].value;if(isReset){ClearName(form);form.action="Peter"+PageLang+".aspx";form.submit();}	else	location.href="Peter"+PageLang+".aspx";}function Reset(form){ClearName(form);form.submit();}function isNotValidName(theField){var inStr=theField.value;var inLen=inStr.length;var inCheck=",.\\\"/'-_+=!@#$%^&*()=+;:|?[]<>~";for(var i=0;i<inLen;i++){var ch=inStr.substring(i,i+1);for(var j=0;j<inCheck.length;j++) {if(ch==inCheck.substring(j,j+1)) return true;}}return false;}function isFieldBlank(theField){if(theField.value=="") return true;else	return false;}function jump2field(theField){theField.select();theField.focus();}function addfav(titleMsg){if(document.all){window.external.AddFavorite(location.href,titleMsg) }}function close(){ 	window.close();}
