var xmlHttp
var LoggedIn=false
var LoginName=''
var What

function showScores(kind)
{ 
 What='S'
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
 {
  alert ("Sorry, your browser does not support HTTP requests to get scores.")
  return
 }
 var url="kpiProxy.php?u=getscores.php?o=L"
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateChanged 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
}


ThinkGreenLinks='<p><b>Related Green Links</b><br><a href="http://www.greenteacher.com" target="_blank" title="Green Teacher">Green Teacher</a> ';

function loadGame(kind) 
{     
  //alert(LoggedIn)
  if (LoggedIn==false)
  {
    outMsg='<p>&nbsp;<p>&nbsp;<p>Sorry, you must first <a href=\'javascript:void(0);\' onclick=\'showInfo("LG")\';>login</a> to participate on this site!'    
    kind='';
  }
  if (kind=='WW') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/WordWar/WordWar.swf?origin=lwc&UserID='+LoginName+'" width=500 height=480 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='MT') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/WordGames/wtetris.swf?origin=lwc&UserID='+LoginName+'" width=500 height=480 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='FC') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/FlashCards/fcfree.swf?origin=lwc" width=400 height=500 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='GA') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/CardGames/getahead.swf?origin=lwc&UserID='+LoginName+'" width=500 height=350 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='TG') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/CardGames/thinkgreen.swf?origin=lwc&UserID='+LoginName+'" width=500 height=350 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;' + ThinkGreenLinks
  if (kind=='EN') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/CardGames/ensemble.swf?origin=lwc&UserID='+LoginName+'" width=500 height=350 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='RV') outMsg='<center>Click cards to match pairs of owl. Eliminate all cards to reveal an amazing fact ... </center><object><embed src="http://www.kprobe.com/kprobe/Revelation/revelation.swf?Kind=Facts" width=485 height=325 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='RVGR') outMsg='<center>Click cards to match pairs of owls. Eliminate all cards to reveal a grammar fact ... </center><object><embed src="http://www.kprobe.com/kprobe/Revelation/revelation.swf?Kind=SC-Grammar" width=485 height=325 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='RVMT') outMsg='<center>Click cards to match pairs of owls. Eliminate all cards to reveal a mathematical fact ...  </center><object><embed src="http://www.kprobe.com/kprobe/Revelation/revelation.swf?Kind=SC-Math" width=485 height=325 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  if (kind=='FEEDBACK') outMsg='&nbsp; <object><embed src="http://www.kprobe.com/kprobe/CCC/Feedback.swf" width=333 height=333 quality=high wmode=window type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object> &nbsp;'
  //alert(outMsg)
  document.getElementById("right").innerHTML = outMsg
}

function showInfo(kind)
{
  outMsg='';

  if (kind=='LG') 
  {
    outMsg='<div id="right"><h1>Please Login!</h1>'+
	   '<div id="login">'+
	   '<fieldset><label for="id">Player Name:</label><br>'+
	   '<input id="id" type="text" name="id" value="" />'+
	   '<p><label for="pw">Password:</label><br>'+
	   '<input id="pw"  type="password" name="pw" value="" />'+
	   '<p><a href="javascript:void(0); onclick=Login(123); ">Login</a></p>'+
	   '<p><a href=\'javascript:void(0); onChange=enableLogin(); onclick=showInfo("FP"); \'>Forgot your password</a>?</p>'+
	   '<p><a href=\'javascript:void(0); onChange=enableLogin(); onclick=showInfo("RG"); \'>Register as a new player</a>.</p>'+
	   '</fieldset></div></div>'
  }								    
  if (kind=='RG') 
  {
    outMsg='<p>&nbsp;<p>&nbsp;<p>'+
      '<a href="http://www.kprobe.com/kprobe/learnwithcards/register.php" title="Register to play">Register Here</a> &nbsp;'
  }


  if (kind=='LO') 
  {
    document.getElementById("status").innerHTML="<b>You are not logged in.</b> &nbsp[<a href='javascript:void(0);' onclick='showInfo(\"LG\");' title='Login'>Login</a>]" 
    document.getElementById("right").innerHTML = ''
    LoggedIn=false;
  }


  if (kind=='MY') 
  {
    outMsg='<div id="right"><h1>MySpace and Facebook Content!</h1>'+
	   '<h4>FREE CONTENT COMING SOON</h4><br />'+
	   'We will be providing educational applications for you to use at MySpace, Facebook and other social networking sites.   '+
           '<p></p><p></p>'+
	   '<h4>DAILY QUIZ</h4><br />'+
	   '<div class="pic"><img src="http://www.kprobe.com/kprobe/DailyQuiz/112.jpg" height=66 width=66></div>'+
	   'A daily quiz where you can contribute new questions and answers to grow the community nature of this game. '+
	   '<font size=1><br>Myspace embed code: </font><br> <textarea rows=2 cols=40>???</textarea>'+
	   '<h4>GUESS WORD</h4><br />'+
	   '<div class="pic"><img src="http://www.kprobe.com/kprobe/GuessWord/gw66.gif" height=66 width=66></div>'+
	   'Guess a secret word by using clues from other words you type. '+
	   '<font size=1><br>Myspace embed code: </font><br> <textarea rows=2 cols=40>???</textarea>'+
           '</font><p></p><p></p>'+
	   '<h4>NUMSKULLS MATH</h4><br />'+
	   '<div class="pic"><img src="http://online-games.recruiter.ca/numskulls120x80.jpg" height=66 width=66></div>'+
	   'Be the top numskull in this fast-paced math game of forming simple equations for kids.'+
	   '<font size=1><br>Myspace embed code: </font><br> <textarea rows=2 cols=40>???</textarea>'+
           '</font><p></p><p></p>'
  }


  if (kind=='HM') 
  {
    outMsg='<div id="right"><h1>Welcome!</h1>'+
	   '<h4>THE FACTS</h4><br />'+
	   '<div class="pic"><img src="images/cards3.jpg" alt="Pic1" /></div> '+
	   'Kids love to play with cards. '+
	   'Cards can have educational value. Kids crave to be on-line. '+
	   'Add these facts together and you get a site where kids <b>learn as they play</b>. '+
	   'This site contains educational card games and flash cards with content on a variety of subjects. '+
	   'There is no age range for these games. '+
	   '<p></p><p></p><p></p>'+
	   '<h4>FREE MEMBERSHIP</h4><br />'+
	   '<div class="pic"><img src="images/cards6.jpg" alt="Pic1" /></div> '+
	   '<div class="pic1"><img src="images/cards2.jpg" alt="Pic1" /></div><p>'+
	   'Join for <b>free</b>. Your free membership lets you login to play and learn. '+
	   'You also get the ability to add new content to customize the games. '+
           '<p></p><p></p>'+
	   '<h4>CUSTOMIZE YOUR GAMES</h4><br />'+
	   '<div class="pic"><img src="images/cards4.jpg" alt="Pic1" /></div> '+
	   'A hallmark of our card games is <b>your</b> ability to extend content by adding new subject material. '+
	   'This customization feature allows teachers especially to add new concepts readily. '+
	   'Once accepted by the community or site moderator, these new cards are available to be used in the games. '+
	   'A voting system lets players vote on the suitability of the new cards that other users have created. '+
	   'This allows games to grow as new concepts are added. '+
           '<p></p><p></p>'+
	   '<h4>SUGGEST</h4><br />'+
	   '<div class="pic"><img src="images/cards5.jpg" alt="Pic1" /></div> '+
	   'Click the [Suggest] link below to suggest <b>new content</b> or new games. '+
	   'We look forward to hearing from you. '+
           '<p></p> <p></p> <p></p> <p></p> <p></p> <p></p>'+
	   '<h4>DONATE</h4><br />'+
	   '<div class="pic"><img src="images/cards7.jpg" alt="Pic1" /></div> '+
	   'As parents ourselves, we have built this site for the benefit of kids, teachers and parents. '+
	   'Your <b>support and encouragement</b> allows us to spend quality time building more games and creating additional content. '+
	   'If you choose to use our site, please consider an optional donation or at least let your friends now about it. '
  }

  if (kind=='FC') 
  {
    outMsg='<div id="right"><h1>Flash Cards!</h1>'+
	   '<h4>DYNAMIC CONTENT</h4><br />'+
	   'You get to create, print and maintain flash cards on any subject.  '+
           '<p></p><p></p>'+
	   '<h4>COMMUNITY CONTRIBUTION</h4><br />'+
	   'Content for flash cards is contributed by you, the community of educators, students and parents. '+
	   'All content is immediately available for sharing by anyone. Please contribute to the growth of the content. '+
           '<p></p><p></p>'
  }


  if (kind=='ST') 
  {
    outMsg='<div id="right"><h1>Sticky Notes!</h1>'+
	   '<h4>STICK IT TO US!</h4><br />'+
           'Use our sticky notes black board to post messages to friends or leave us support messages and comments ...'+
           '<p></p><p></p>'+
           '<!-- STICKY.ME SCRIPT --> <script type="text/javascript" src="http://www.sticky.me/sticky-app/sticky.js"> </script> <script type="text/javascript">    who=Math.random(); setTimeout(function(){ loadSticky("NUVWEGOTUKUMGMQFRIMOPDMVYQYHSXOQ","www.sticky.me/bgs/Chalkboard.jpg","educational","",""); }, 25); </script>    <div id="kpiSticky"> <a href="http://www.sticky.me">Stickies for your website</a></div>    <!-- END STICKY.ME SCRIPT -->'+
	   '<br>'
  }

  if (kind=='LK') 
  {
    outMsg='<div id="right"><h1>Related Links</h1>'+  ThinkGreenLinks
            
  }

  if (kind=='GM') 
  {
    outMsg='<div id="right"><h1>Games!</h1>'+
	   '<h4>CARD AND TILE GAMES</h4><br />'+
           'Our games are based on cards and tiles. Many are multi-player games. '+
           '<p></p><p></p>'+
	   '<h4>MULTI-PLAYER CARD GAMES</h4><br />'+
           'In the following games, you play against another live player in real-time. <br />'+
	   '<b>Get Ahead</b>: is a card game about life. Get ahead of your opponent before life runs out.<br />'+
	   '<b>Think Green</b>: lets you learn about the environment and ways to improve it.<br />'+
	   '<b>Ensemble</b>: gets you to build words from 1,2 and 3-letter cards.<br />'+
	   '<b>World Traveller</b>: builds up your knowledge of the world and societies.<br />'+
	   '<b>Farming</b>: makes you appreciate the job done by our farmers.<br />'+
	   '<b>Utopia</b>: is a game of running a country.<br />'+
	   '<b>The Corporation</b>: lets you build up a corporation.<br />'+
	   '<b>Canadian Citizenship</b>: gives you time to learn about becoming a Canadian<br />'+
	   '<b>Working</b>: lets you work your way up the corporate ladder.<br />'+
	   '<b>Final Fantasy</b>: is a recreational game of warriors.<br />'+
           '<p></p><p></p>'+
	   '<h4>TILE GAMES</h4><br />'+
           'Tile games are played with words or numbers. '+
           '<p></p><p></p>'+
	   '<h4>CONNECT-O-MANIA</h4><br />'+
           'The Connect-O-Mania series of games is about relationships. Play cards that relate to other cards. '+
           'Learn about The World, Universe, Government and other related entities. '+
           '<p></p><p></p>'+
	   '<h4>LANGUAGES</h4><br />'+
           'Many of our games support a variety of languages including '+
           'Danish, Dutch, English, Finnish, French, German, Hungarian, Italian, Norwegian, Polish, Portuguese, Romanian, Spanish, Swedish and Turkish. '
  }

  if (kind=='MT') 
  {
    outMsg='In <b>Multi-Lingual Word Tetris</b> you make words from falling letters. Choose your dictionary from 12 supported languages including Danish, Dutch, English, Finnish, French, German, Hungarian, Italian, Norwegian, Polish, Portuguese, Spanish, Swedish and Turkish. '
    outMsg+="<p><a href='javascript:void(0);' onclick='loadGame(\'MT\');'><img src='http://www.kprobe.com/kprobe/WordGames/wt112.jpg'></a>"
  }
  if (kind=='FP') 
  {
    outMsg='<div id="right"><h1>Login Management</h1>'+
	   '<h4>FORGOT PASSWORD</h4><br />'+
           'You can retrieve your password using your reminder prompt or via email. '+
           'Please enter the email address you used when you registered. '+
           ' FORM GOES HERE '
  }
  if (kind=='TU') 
  {
    outMsg='<div id="right"><h1>Terms of Use</h1>'+
	   '<h4></h4><br />'+
	   ''
  }

  if (kind=='DN') 
  {
    outMsg='<div id="right"><h1>Donations</h1>'+
	   '<h4></h4><br />'+
	   ''
  }

  if (kind=='SG') 
  {
    outMsg='<div id="right"><h1>Suggest</h1>'+
	   '<h4></h4><br />'+
	   ''
  }

  if (kind=='SC') 
  {
    outMsg='<div id="right"><h1>Scores</h1>'+
	   '<h4></h4><br />'+
	   ''
    showScores()
  }

  if (kind=='US') 
  {
    outMsg='<div id="right"><h1>Contact Us</h1>'+
	   '<h4>FREQUENTLY ASKED QUESTIONS</h4><br />'+
           'For your convenience, we have listed some of the most common questions to review before contacting us. '+
           '<p></p><p></p>'+
	   '<h4>EMAIL US</h4><br />'+
           'If you have any questions, comments, or suggestions, please do not hesitate to contact us. ' 
  }





  if (kind=='PV') 
  {
    outMsg='<div id="right"><h1>Privacy Policy</h1>'+
	   '<h4>USE OF PERSONAL INFORMATION</h4><br />'+
           'Knowledge Probe Inc (KProbe) does not require an end-user to provide any personally identifiable '+
           'information such as name, address or email address to play its games. '+
           '<p>The only information we collect is to represent your score and it is requested as follows: '+
           '<br><ul>'+
	   '<li> Your code name (not your real name)'+
	   '<li> Your city, region and country (do not include a street address)'+
	   '<li> Your grade.'+
           '</ul><p>'+
           'We store information that we collect through cookies and/or log files that are stored on your computer and/or within '+
           'our scoring database. This information is available to other users in the form of a scores summary which uses your code name. '+
           'Although your internet IP address may be transmitted when you register or record a score, '+
           'we do not use this IP address or store it.'+
           '<p>'
  }

  //alert(kind+outMsg)
  document.getElementById("right").innerHTML = outMsg+'</div>'
}

function enableLogin()
{
  
}


function Login(q)
{ 
 What='L'
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
 {
   alert ("Your browser doesn't support Ajax - upgrade your browser.")
   return
 }
 var url='kpiProxy.php?u=login.php?submit=submit~id='
 url+=document.getElementById("id").value
 url+='~pw='+document.getElementById("pw").value
 url=url+"&sid="+Math.random()
 //alert(url)
 xmlHttp.onreadystatechange=stateChanged
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 document.getElementById("status").innerHTML="Login in progress" 
}

function Logout()
{ 
 What='LO'
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
 {
   alert ("Your browser doesn't support Ajax - upgrade your browser.")
   return
 }
 var url="kpiProxy.php?u=login.php?submit=logout"
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateChanged
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 LoggedIn=false;
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
   var r=xmlHttp.responseText
   if (What=='L') 
   {
     LoginName=document.getElementById("id").value
     document.getElementById("status").innerHTML=r 
     if (r.indexOf('ou are log')>0) 
     {
       LoggedIn=true;
     }
   }
   if (What=='LO') 
   {
     document.getElementById("status").innerHTML=''
     LoggedIn=false;
   }
   document.getElementById("right").innerHTML=''
   if (What=='S') 
     document.getElementById("right").innerHTML=xmlHttp.responseText 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;

try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }

return xmlHttp;
}


