<?php include("../style/header.php") ?>

<?php

/*

ǒ ó ō ò
ì ī í ǐ
á à ā ǎ
è ē é ě
ǔ ù ú ū


Things to do:

Add to invertedlogic.com
        - Computer related topics

XiaoFrog is personal site
        - Blog
        - Chinese

add blog entry for engagement
read current books

Goals:

start to write book about computer graphics / write a paper
pay off house
live in other countries
learn Chinese


*/


// Init random numbers
list($usec, $sec) = explode(' ', microtime());
srand(((float)$sec + ((float)$usec * 100000)));

$answer = rand(0,2);

?>

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--

function reset()
{
	for (var i=0; i < document.ChineseQuizForm.answer.length; i++)
	{
	   document.ChineseQuizForm.answer[i].checked = false;
	}
	document.location.reload();
}


// http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

var ScoreNum = readCookie("QuizQuestionsCorrect");
var ScoreDenom = readCookie("QuizQuestionsAsked");
if (ScoreNum == null || ScoreDenom == null) {
	createCookie("QuizQuestionsCorrect",0,1);
	createCookie("QuizQuestionsAsked",0,-1);
	ScoreNum = 0;
	ScoreDenom = 0;
}

function check_answer()
{
	for (var i=0; i < document.ChineseQuizForm.answer.length; i++)
	{
	   if (document.ChineseQuizForm.answer[i].checked)
	   {
		var answer = document.ChineseQuizForm.answer[i].value;
	   }
	}

	ScoreDenom++;

<?php echo 'if ( answer == "' . $answer . '" ) { '; ?>
		document.getElementById("answer").innerHTML = "<p>&nbsp;<p><b><font size=100 color=green>Correct</font></b><p>&nbsp;<p>";
		ScoreNum++;
		setTimeout("reset()",700);
	} else {
		document.getElementById("answer").innerHTML = "<p>&nbsp;<p><b><font size=100 color=red>Incorrect</b></font>, " +
<?php echo '"the correct answer is ' . $answer . '<p>&nbsp;<p>";'; ?>
		setTimeout("reset()",4000);
	}

	document.getElementById("score").innerHTML = "<p>Score: " + ScoreNum + " / " + ScoreDenom + " = " + Math.round(100 * ScoreNum / ScoreDenom) + "% <p>";

	createCookie("QuizQuestionsAsked",ScoreDenom,7);
	createCookie("QuizQuestionsCorrect",ScoreNum,7);
}

//-->
</SCRIPT>

<div style="float: right; margin: 0px auto; width: 180px; height: 180px; background-image: url(postit.gif); padding: 35px 20px 5px 20px;">
<!-- Begin BidVertiser code -->
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://bdv.bidvertiser.com/BidVertiser.dbm?pid=158078&bid=381934" type="text/javascript"></SCRIPT>
<noscript><a href="http://www.bidvertiser.com/bdv/BidVertiser/bdv_advertiser.dbm">marketing</a></noscript>
<!-- End BidVertiser code --> 
</div>

 
<h1>Learning Chinese</h1>


<?php

$ChineseWords = array( 
 
"Basics" => array( 

"吧 ba" => "used at end of sentence to make a suggestion or a question",
"爸爸 bàba" => "father",
"白菜 báicài" => "Chinese cabbage",
"白酒 báijiǔ" => "Chinese spirit (white liquor)",
"半 bàn" => "half",
"办公室 bàngōngshì" => "office",
"报纸 bàozhǐ" => "newspaper",
"北边 běibian" => "north direction",
"本 běn" => "measure word for books",
"笔 bǐ" => "pen, pencil",
"冰激凌 bīngjilíng" => "ice cream",
"伯父 bófù" => "uncle (or friend's father)",
"伯母 bómǔ" => "aunt (or friend's mother)",
"不 bù" => "no / not",
"不错 búcuò" => "quite good",
"不客气 búkèqi" => "You're welcome / Don't mention it / That's all right",
"不（用）谢 bú(yòng)xiè" => "You're welcome / Don't mention it",
"菜 cài" => "vegetable / dish / cuisine",
"厕所 cèsuǒ" => "toilets",
"茶 chá" => "tea",
"尝 cháng" => "to try / taste",
"炒饭 chǎofàn" => "fried rice",
"橙汁 chéngzhī(r)" => "orange juice",
"橙子 chéngzi" => "an orange",
"吃 chī" => "to eat",
"吃饭 chīfàn" => "eat a meal",
"抽 chōu" => "to inhale",
"抽烟 chōuyān" => "to smoke",
"厨房 chúfáng" => "kitchen",
"穿 chuān" => "to put on / wear",
"床 chuáng" => "bed",
"聪明 cōngming" => "clever / intelligent",
"次 cì" => "time (eg used in one time, two times etc)",
"答 dá" => "to answer / respond",
"大 dà" => "big or large",
"大家 dàjiā" => "everybody",
"当然 dāngrán" => "of course",
"的 de" => "of / belongs to / a structural particle",
"地 de" => "adverbial structural particle",
"得 děi" => "to have to / must",

"等 děng" => "wait",
"弟弟 didi" => "younger brother",
"点 diǎn" => "o'clock",
"电话 diànhuà" => "telephone / telephone call",
"电梯 diànti" => "lift",
"电影 diànying" => "movie",
"东边 dongbian" => "east direction",
"东西 dongxi" => "thing",
"动物 dongwu" => "animal",
"都 dou" => "all",
"对 dui" => "correct / right",
"对不起 duibuqi" => "sorry / excuse me",
"对面 duimiàn" => "opposite side",
"多 duo" => "many / much",
"多长 duocháng" => "how long",
"多少 duoshǎo" => "how many / how much",
"饿 e" => "hungry",
"儿子 erzi" => "son",
"饭 fàn" => "meal",
"分 fen" => "minute",
"分 fen" => "1/100 of a yuan (similar to 1 cent)",
"份 fen" => "measure word for paper / magazine (a copy / a edition / a kind)",
"父 fu" => "formal written form of father",
"附近 fujin" => "in the area of / vicinity / near to",
"该。。。了 gāi...le" => "it's time to ...",
"干净 gānjing" => "clean",
"哥哥 gege" => "elder bother",
"个 ge" => "measure word for people / common generic measure word",
"给 gei" => "to give",
"公司 gongsi" => "company / corporation",
"关门 guānmen" => "to close the door / to close for the day",
"广东蔡 guǎngdongcài" => "Cantonese food",
"贵 gui" => "noble / respectful",
"贵姓 guixing" => "what is your last name",
"贵 gui" => "expensive",
"国 guo" => "country",
"果汁 guozhi" => "fruit juice",
"过路人 guoluren" => "passer-by",
"还是 háishi" => "or",
"汉语 hànyu" => "Chinese language",
"汉字 hànzi" => "Chinese character",
"好 hǎo" => "good / well",
"好吃 hǎochi" => "delicious",
"好的 hǎode" => "good / fine / all right",
"好喝 hǎohe" => "nice to drink",
"好看 hǎokàn" => "good looking",
"好吗 hǎo ma" => "is it all right?",
"号 hào" => "number / date",
"喝 he" => "to drink",
"和 he" => "and",
"很 hen" => "very",
"后边 houbian" => "behind",
"后年 hounián" => "the year after next",
"后天 houtiān" => "in two days (day after tomorrow)",
"胡萝卜 huluobo" => "carrot",
"画 huà" => "to paint or draw",
"画儿 huàr" => "a picture (not photo)",
"欢迎 huánying" => "welcome",
"会议室 huiyishi" => "conference room",
"鸡 ji" => "chicken",
"鸡蛋 jidàn" => "chicken egg",
"几 ji" => "several / which",
"家 jiā" => "home / family",
"件 jiàn" => "measure word for clothes",
"见面 jiànmiàn" => "to meet",
"饺子 jiǎozi" => "similar to dumplings",
"叫 jiào" => "to be called",
"教室 jiàoshi" => "classroom",
"接 jie" => "to pickup someone",
"结帐 jiezhàng" => "to pay a bill",
"姐姐 jiejie" => "elder sister",
"介绍 jieshào" => "to introduce",
"斤 jin" => "a measure of weight, 1 jin = 500g",
"今年 jinnián" => "this year",
"今天 jintiān" => "today",
"进 jin" => "to enter / come in or out",
"近 jin" => "near, close to",
"经理 jingli" => "manager",
"酒 jiu" => "alcoholic drink",
"就 jiu" => "just",
"旧 jiu" => "old / used",
"聚会 juhui" => "party",
"觉得 juede" => "to feel / to think",
"咖啡 kāfei" => "coffee",
"开门 kāimen" => "to open the door / to open for the day",
"看 kàn" => "to look / to see",
"渴 ke" => "thirsty",
"可爱 ke'ài" => "cute / lovely",
"可乐 kele" => "cola",
"刻 ke" => "quarter of an hour",
"客厅 keting" => "sitting room",
"口语 kouyu" => "spoken language",
"裤子 kuzi" => "trousers",
"快（元） kuài" => "informal word for yuan (similar to bucks instead of dollars)",
"快乐 kuàile" => "happy",
"矿泉水 kuàngquánshui" => "mineral water",
"困 kun" => "sleepy",
"来 lai" => "to come",
"老 lǎo" => "old",
"老师 lǎoshi" => "teacher",
"了 le" => "a modal particle, gives an affirmative tone",
"累 lei" => "tired",
"冷饮 lengyin" => "cold drinks",
"离 li" => "away from",
"练习 liànxi" => "exercise / practice",
"两 liǎng" => "a measure of weight, 1 liang = 50 grams",
"聊天儿 liáotiānr" => "to chat",
"龙 long" => "dragon",
"楼 lou" => "building",
"吗 ma" => "used at end of sentences to ask a question",
"妈妈 māma" => "mother",
"买 mǎi" => "to buy",
"卖 mài" => "to sell",
"慢 màn" => "slow",
"忙 máng" => "busy",
"芒果 mángguo" => "mango",
"毛（角） máo （jiǎo)" => "1/10 yuan, 10 fen",
"妹妹 meimei" => "younger sister",
"没关系 meiguānxi" => "it doesn't matter",
"没（有） mei(you)" => "don't (have) / there isn't",
"每 mei" => "every",
"们 men" => "used as a suffix to pluralize words",
"米饭 mifàn" => "cooked rice",
"秘书 mishu" => "secretary",
"面条 miàntiáo" => "noodles",
"明年 mingnián" => "next year",
"明天 mingtiān" => "tomorrow",
"名字 mingzi" => "name",
"母 mu" => "formal written form of mother",
"哪 nǎ/nei" => "which",
"那 nà" => "that",
"那些 nàxie/neixie" => "those",
"南边 nánbian" => "south direction",
"男朋友 nánpengyou" => "boyfriend",
"哪儿 nǎr" => "where",
"那儿 nàr" => "there",
"呢 ne" => "used to ask a question",
"能 neng" => "can / capable or / be able to",
"你 ni" => "you",
"年 nián" => "year",
"您 nin" => "you (respectful, used for elders)",
"牛 niu" => "cattle",
"牛肉 niurou" => "beef",
"女儿 nu'er" => "daughter",
"女朋友 nupengyou" => "girlfriend",
"旁边 pángbiān" => "beside / next to",
"陪 pei" => "to accompany",
"朋友 pengyou" => "friend",
"啤酒 pijiu" => "beer",
"便宜 piányi" => "cheap",
"票 piào" => "ticket",
"瓶 ping" => "bottle",
"苹果 pingguo" => "apple",
"苹果汁 pingguozhi" => "apple juice",
"葡萄酒 putaojiu" => "wine (red/white wine)",
"妻子 qizi" => "wife",
"起床 qichuáng" => "to get up",
"钱 qián" => "money",
"前边 qiánbian" => "in front / ahead",
"前年 qiánnian" => "the year before last",
"前天 qiántiān" => "the day before yesterday",
"芹菜 qincài" => "celery",
"请 qing" => "please",
"请问 qingwen" => "may I ask, ...",
"去 qu" => "to go to",
"去年 qunián" => "next year",
"裙子 qunzi" => "skirt",
"人 ren" => "person",
"日语 riyu" => "Japanese language",
"肉 rou" => "meat",

/* Newly added words */

"商店 shangdian" => "shop",
"上（个星期） shang (ge xingqi)" => "last (week)",
"上班 shangban" => "to go to work",
"上课 shangke" => "to go to / have class",
"上午 shangwu" => "morning",
"捎 shao" => "slightly / for a while",
"捎等 shaodeng" => "to wait for a while",
"少 shao" => "few / little",
"谁 shei/shui" => "who / whom",
"什么 shenme" => "what",
"生日 shengri" => "birthday",
"圣诞（节）shengdan(jie)" => "Christmas",
"时间 shijian" => "time",
"是 shi" => "to be",
"手 shou" => "hand",
"书 shu" => "book",
"蔬菜 shucai" => "vegetables",
"书房 shufang" => "study",
"属 shu" => "to belong to, to be born in that chinese year of",
"水果 shuiguo" => "fruit",
"睡觉 shuijiao" => "to sleep / go to bed",
"说 shuo" => "to say / speak",
"四川菜 sichuancai" => "Sichuan cuisine",
"酸奶 suannai" => "yogurt",
"她 ta" => "she/her",
"他 ta" => "he/him",
"它 ta" => "it",
"太。。。了 tai...le" => "it is too ...",
"汤 tang" => "soup",
"天 tian" => "day",
"条 tiao" => "a measure word for trousers, skirt etc",
"听 ting" => "to listen to / to hear",
"听见 tingjian" => "to have heard / to hear",
"挺。。。的 ting...de" => "(adj) quite ...",
"同事 tongshi" => "colleague",
"同学 tongxue" => "classmate",
"兔（子） tu(zi)" => "rabbit",
"外国 waiguo" => "foreign country",
"外国人 waiguoren" => "foreigner",
"晚饭 wanfan" => "dinner",
"晚上 wanshang" => "evening",
"喂 wei" => "Hello",
"为什么 weishenme" => "why",
"卫生间 weishengjian" => "bathroom / toilet",
"问 wen" => "to ask",
"我 wo" => "I / me",
"卧室 woshi" => "bedroom",
"午饭 wufan" => "lunch",
"西边 xibian" => "westward",
"习惯 xiguan" => "to be used to / habit",
"西红柿 xihongshi" => "tomato",
"喜欢 xihuan" => "to like",
"洗 xi" => "to wash",
"洗手间 xishoujian" => "washroom / toilet",
"洗澡 xizao" => "to take a bath",
"下（个星期） xia (ge xingqi)" => "next (week)",
"下班 xiaban" => "to finish work for the day",
"下课 xiake" => "to finish the lesson / class",
"下午 xiawu" => "afternoon",
"先生 xiansheng" => "Mister / Mr",
"现在 xianzai" => "now",
"想 xiang" => "to want / to think",
"小 xiao" => "young / little / small",
"小姐 xiaojie" => "Miss",
"小时 xiaoshi" => "hour",
"写 xie" => "to write",
"谢谢 xiexie" => "thanks",
"新 xin" => "new",
"新年 xinnian" => "New Year",
"星期 xingqi" => "week",
"星期六 xingqiliu" => "Saturday",
"星期天 xingqitian" => "Sunday",
"星期五 xingqiwu" => "Friday",
"姓 xing" => "surname",
"学生 xuesheng" => "student",
"学校 xuexiao" => "school",
"烟 yan" => "smoke / cigarette",
"羊 yang" => "sheep",
"洋葱 yangcong" => "onion",
"羊肉 yangrou" => "lamb meat",
"阳台 yangtai" => "balcony",
"也 ye" => "also / too",
"衣服 yifu" => "clothes",
"医院 yiyuan" => "hospital",
"一边。。。一边。。。 yibian...yibian..." => "to do ... while doing ...",
"一共 yigong" => "altogether / totally",
"一会儿 yihuir" => "a short time",
"一起 yiqi" => "together",
"一下 yixia" => "a bit",
"音乐 yinyue" => "music",
"银行 yinhang" => "bank",
"英语 yingyu" => "the English language",
"用 yong" => "need (Here?? use??)",
"邮局 youju" => "post office",
"有 you" => "to have / there is",
"有意思 youyisi" => "interesting",
"远 yuan" => "far",
"月 yue" => "month",
"在 zai" => "to be in / at",
"再见 zaijian" => "goodbye / see you",
"脏 zang" => "dirty",
"早饭 zaofan" => "breakfast",
"早上 zaoshang" => "morning / early morning",
"怎么样 zenmeyang" => "how",
"丈夫 zhangfu" => "husband",
"找 zhao" => "to look for",
"这 zhe,zhei" => "this",
"这些 zhe xie/zhei xie" => "these",
"真 zhen" => "really / truly",
"这儿 zher" => "here",
"支 zhi" => "a measure word for any writing instrument",
"知道 zhidao" => "to know",
"中午 zhongwu" => "noon",
"周末 zhoumo" => "weekend",
"总是 zongshi" => "always",
"走 zou" => "to go / to leave",
"最 zui" => "most",
"最近 zuijin" => "recently",
"昨天 zuotian" => "yesterday",
"坐 zuo" => "to sit",
"做 zuo" => "to make",
"作业 zuoye" => "homework",
"做饭 zuofan" => "to cook (food)",


/* Proper Nouns / Names */
"广东 Guangdong" => "Guangdong Province",
"广州 Guangzhou" => "Guangzhou City",
"汉语 Hanyu" => "the Chinese language",
"汉字 Hanzi" => "Chinese character",
"加拿大 Jianada" => "Canada",
"加拿大人 Jianadaren" => "Canadian",
"美国 Meiguo" => "America",
"美国人 Meiguoren" => "American",
"南京 Nanjing" => "Nanjing City",
"日本 Riben" => "Japan",
"日语 Riyu" => "the Japanese language",
"日本人 Ribenren" => "Japanese person",
"上海 Shanghai" => "Shanghai City",
"四川 Sichuan" => "Sichuan Province",
"天津 Tianjin" => "Tianjin City",
"西安 Xi'an" => "Xi'an City",
"颐和园 Yiheyuan" => "The Summer Palace",
"英国 Yingguo" => "England",
"英语 Yingyu" => "the English language",
"元 Yuan" => "Chinese money",
"中国 Zhongguo" => "China"

)

);

?>

<?php

function array_key($arr, $pos) {
    if (!empty($arr)) {
        if ($pos===null)
            $pos = 0;
       
        $all_keys = array_keys($arr);
        unset($arr);
       
        $key = $all_keys[$pos];
        unset($all_keys);
       
        if (isset($key))
            return $key;
        else {
            unset($key);
            return null;
        }
    }
}

echo $ChineseWords["Basics"][rand()]->key . "\n";
echo "<br>\n";

$numA = rand(0,count($ChineseWords["Basics"]));
$pinyinA = array_key($ChineseWords["Basics"],$numA);
$englishA = $ChineseWords["Basics"][$pinyinA];

$numB = rand(0,count($ChineseWords["Basics"]));
$pinyinB = array_key($ChineseWords["Basics"],$numB);
$englishB = $ChineseWords["Basics"][$pinyinB];

$numC = rand(0,count($ChineseWords["Basics"]));
$pinyinC = array_key($ChineseWords["Basics"],$numC);
$englishC = $ChineseWords["Basics"][$pinyinC];

$pickPinyin = array( 0 => $pinyinA, 1 => $pinyinB, 2 => $pinyinC );

echo "What is the translation for: <p> <p>";
echo "<b><font size=6>$pickPinyin[$answer]</font></b><p>";
echo "<form name='ChineseQuizForm'>";
echo '<input type="radio" name="answer" value="0" onclick="check_answer()">';
echo "$englishA <br>";
echo '<input type="radio" name="answer" value="1" onclick="check_answer()">';
echo "$englishB <br>";
echo '<input type="radio" name="answer" value="2" onclick="check_answer()">';
echo "$englishC <br>";
echo "</form>";

// echo array_keys($ChineseWords)[0];
// echo $ChineseWords[array_keys($ChineseWords)[0]];
// echo $ChineseWords[array_keys($ChineseWords)[0]]["rou"];

?>

<div id="answer"></div>
<div id="score"></div>


<script>

if (ScoreDenom == 0) {
	document.getElementById("score").innerHTML = "<p>Score: " + ScoreNum + " / " + ScoreDenom + " = 0% <p>";
} else {
	document.getElementById("score").innerHTML = "<p>Score: " + ScoreNum + " / " + ScoreDenom + " = " + Math.round(100 * ScoreNum / ScoreDenom) + "% <p>";
}

</script>

<?php include("../style/footer.php") ?>  

