function DoLast()
{
if(login=="yes"){var user=$("span#user").text();
$.post("removeUseroffline",{username:user});
}
}
function goOpen(index)
 {
 var optionString = "width="+screen.availWidth+",height="+screen.availHeight+",target=_parent"+"menubar=yes,toolbar=yes,scrollbars=yes,location=yes";
 if(index==1){var operator="Mfone";}
 if(index==2){var operator="CellCard";}
 if(index==3){var operator="HelloCard";}
 window.open("claimPhoneCard?operator="+operator,"",optionString);
 }
function TxtBoard(txt){
  document.body.scrollTop=0;
  var maskHeight = $(document).height();
  var maskWidth = $(window).width();
  $('div.thickBox').css({'width':maskWidth,'height':maskHeight});
  $("div.thickBox").show();
  $("#loading").show();
  if(txt=="AdWithUs")     {$("p.ReD").load("text/AdWithUs","",            function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Ad With Us");}
  if(txt=="EmailEarn")    {$("p.ReD").load("emailFriend/earning_email","",function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Email Earning");}
  if(txt=="specialevent") {$("p.ReD").load("text/LearnSpecialEvent","",   function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Special Event");}
  if(txt=="Guide")        {$("p.ReD").load("helpGuide","",                function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Guide & Rule");}
  if(txt=="ExamHist")     {$("p.ReD").load("main/history","",             function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Exam History");}
  if(txt=="Account")      {$("p.ReD").load("main/account",{gg:1},         function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Account");}
  if(txt=="SendMes")      {$("p.ReD").load("main/send","",                function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Send Message");}
  if(txt=="Inbox")        {$("p.ReD").load("main/inbox","",               function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Inbox");}
  if(txt=="Transac")      {$("p.ReD").load("main/transaction","",         function(){$("#loading").hide();$("div#parentDiv").fadeIn("fast");});$("h3.head").text("Transaction Record");}

}
//Result Board
function ResultBoard(eventid){
  document.body.scrollTop=0;
   var maskHeight = $(document).height();
   var maskWidth = $(window).width();
  $('div.thickBox').css({'width':maskWidth,'height':maskHeight});
  $("div.thickBox").show();
  $("div#parentDiv").show("normal");
  $("h3.head").text("Awarding Result");
  $.post("declaration_result",{eventid:eventid},
  function(WTF){
    $("p.ReD").html("<p style='font:14pt Arial;text-align:left;'>"+WTF+"</p>");
    });
}
 function boxAdd(){
   $("div.thickBox").show();
   $("div.questBox").fadeIn("slow");
   window.document.body.scrollTop=0;
   var maskHeight = $(document).height();
   var maskWidth = $(window).width();
   $('div.thickBox').css({'width':maskWidth,'height':maskHeight});
}

 function backLink(){
   history.go(-1);
 }
function boxHide(){
   $("div.InboxDis").hide("fast");
   $("div.questBoxLast").hide();
   $("div.thickBox").hide();
   $("div.questBox").hide();
   $("div#parentDiv").fadeOut("fast");
 }

function revealPin()
{
$("#loading").show();
var uid=document.getElementById("userid").innerHTML;
var credit = parseInt(document.getElementById("cre").innerHTML);
var pin =document.getElementById("pin").value;
if (pin!=""){
$.post("revealPin",{uid: uid ,pin: pin},
function(WhatTheFuck){
    $("#loading").hide();
    $("div.questBoxLast").show();
    $("div.questBox").hide();
    if(WhatTheFuck!="null"){
    $("div.questBoxLast").html("<h2 style='color:#008000'><BR>Credit top up by: "+WhatTheFuck+" k</h2><h3>Thank you</h3>");
    var revise=parseInt(credit)+parseInt(WhatTheFuck);
    $("#cre").text(revise);
    }else{
    $("div.questBoxLast").html("<BR><h2 style='color:#FF0000'><BR>Invalid Pin !</h2>");
    }
    setTimeout("boxHide();",4000);

});
}
}
function btnGetPremium()
{
$("span.loading").show();
var uid=document.getElementById("userid").innerHTML;
var months =document.getElementById("month").innerHTML;
var charge =document.getElementById("price").innerHTML;

$.post("checkingMemberAccount",{uid:uid ,price:charge,month:months},
function(WTF){
    $("span.loading").hide();
    if(WTF=="success"){
    $("div.container").html('<h2 style="color:#008000"><img src="gif/yes.gif" alt="Yes,." border="0">Thank you <BR>for buying<BR>Premium Member</h2>');
    $("span#member").html("<span style='color:#008000'>Premium Member</span>");
    }
    if(WTF=="fail"){
    $("div.container").html('<h2 style="color:#FF0000"><img style="position:relative;top:3px;" src="gif/close.gif" alt="Wait,." border="0">Please Top Up Your Credit</h2><BR><Button style="font-size:14pt;" onClick="boxAdd();">Top Up</Button>');
    }
    if(WTF=="member"){
    $("div.container").html('<h2 style="color:#FF0000">You are now our member now<BR>Please continue to purchase after this member expire</h2>');
    }
    });
}
 function goGrammar()
 {
 //var optionString = "width="+screen.availWidth+",height="+screen.availHeight+",menubar=no,toolbar=no,scrollbars=yes,location=no,fullscreen=1";
 var rand=Math.round((Math.random()*10000));
 var con = confirm('Grammar Test take 25 minutes. \n\n The test will start soon after you click OK ');
 if (con==true){window.open("main/before_grammar?rand="+rand);
 }
 }
   function goReading()
 {
 //var optionString = "width="+screen.availWidth+",height="+screen.availHeight+",menubar=no,toolbar=no,scrollbars=yes,location=no,fullscreen=1";
 var rand=Math.round((Math.random()*10000));
 var con = confirm('Short Reading Test take 30 minutes. \n\n The test will start soon after you click OK ');
 if (con==true){window.open("main/before_reading?rand="+rand);
 }}
   function goListening()
 {
 var rand=Math.round((Math.random()*10000));
 var con = confirm('Listening Test take between 25 and 30 minutes. \n\n The test will start soon after you click OK ');
 if (con==true){window.open("main/before_listening?rand="+rand);
 }
 }
 //control price unit
 function AdsDays()
 {
 var noday = document.theForm.period.value;
 var Unit = document.getElementById("Unit");
 var Days = document.getElementById("NoDay");
 var Total = document.getElementById("Total");
 var price = 4000;
 var t=price*parseInt(noday);
 Days.innerHTML=noday;
 Unit.innerHTML=price+"k";
 Total.innerHTML=t+"k";
 }
  function TextDays()
 {
 var noday = document.theForm.period.value;
 var Unit = document.getElementById("Unit");
 var Days = document.getElementById("NoDay");
 var Total = document.getElementById("Total");
 var price = 1000;
 var t=price*parseInt(noday);
 Days.innerHTML=noday;
 Unit.innerHTML=price+"k";
 Total.innerHTML=t+"k";
 }
 //fuct reveal image before uploading in Ads Manage

  function imageSelect(id)
 {
 items=parseInt($("#imageItems").text());
 $("#imageItems").text();
 var i=0;
 while (i<items)
 {i++;
 document.getElementById("img"+i).style.backgroundColor="#FFFFFF";}
 document.getElementById("img"+id).style.backgroundColor="#0080C0";
 document.theForm.image.value=document.getElementById("Name"+id).innerHTML;
 }
//Edit Cpanel
  function Cpanel_Edit()
 {
 window.open();
 }




//E-------
function hili(El) {
var El = document.getElementById(El);
El.style.backgroundColor = "rgb(210, 255, 255)";
El.style.cursor = "hand";
}
function nohili(El) {
var El = document.getElementById(El);
El.style.backgroundColor = "rgb( 255, 255, 255)";
}

function hili_m(El) {
var El = document.getElementById(El);
El.style.backgroundColor = "#80FFFF";
El.style.cursor = "hand";
}
function nohili_m(El) {
var El = document.getElementById(El);
El.style.backgroundColor = "#FFFFFF";
}//end function

function isUsername() {
if(event.keyCode>122 || event.keyCode<97)
   {
   var pass=1;
   if(event.keyCode==45 || event.keyCode==95){pass=0;}
   if(event.keyCode==32 || event.keyCode==46){pass=0;}
   if(event.keyCode>=48 && event.keyCode<=57){pass=0;}
   if(event.keyCode>=65 && event.keyCode<=90){pass=0;}
   if (pass==1){
    event.keyCode=0;
    alert("Invalid Letter Input");
    }

   }
} //end function
function isEmail() {
if(event.keyCode>122 || event.keyCode<97)
   {
   var pass = 1;
   if(event.keyCode==95 || event.keyCode==64 || event.keyCode==46){pass=0;}
   if(event.keyCode>=48 && event.keyCode<=57){pass=0;}
   if (pass==1){
    event.keyCode=0;
    alert("Invalid Email Input");
    }

   }
} //end function
function isNumber() {
if(event.keyCode>57 || event.keyCode<48)
   {
   var pass =1;
   if(event.keyCode==32){pass=0;}
   if (pass==1){
    event.keyCode=0;
    alert("Invalid Number Input");
    }

   }
}//end function
function isCorrectPwd() {
var input = document.frm.pwd.value;
var output = document.getElementById("Idpwd");
if (input.length>0){
if (input.length<6){
output.innerHTML='<span style="font-family:arial;font-size:8pt;color:#FF0000">Password must be at leat 6 character length</span>';
}else{
output.innerHTML='<span style="font-family:arial;font-size:8pt;color:#008000">Yes, correct</span>';}
 }else{
 output.innerHTML='';
 }
} //end function


function returnFun()
{
var xmlHttp;
var elem1 = document.getElementById("ajreturn");
    var vale = document.frm.uid.value;
    var pass=0;
    if (vale.length>0){
    if (vale.length>=4){
    var cha=vale.charCodeAt(0);
    if (cha<65){pass=2;}
    var space = vale.match(" ");
    if (space==" "){pass=1;}
    if (pass==0){

    try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      elem1.innerHTML= xmlHttp.responseText;
     document.getElementById("loaderInfo").style.display="none";
      }else{document.getElementById("loaderInfo").style.display="inline";}
    }
  xmlHttp.open("GET","phpreturn2register?name="+vale,true);
  xmlHttp.send(null);
}else{elem1.innerHTML= '<font color="#FF0000">Please enter your username without space</font>';}
}else{elem1.innerHTML= '<font color="#FF0000">Your username must be at leat 4 characters in length</font>';}
}else{elem1.innerHTML= "letter or number without space (e.g. bongjack)";}
if (pass==2){elem1.innerHTML= '<font color="#FF0000"><b>Username should not preceed by number.</b></font>';
alert("Don't enter the first character as number.");
document.frm.uid.value = "";
}
}//end function returnFun
function returnEmail()
{
var xmlHttp;
var elem = document.getElementById("IdEmail");
var vale = document.frm.email.value;
if (vale.length>7){


    try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      elem.innerHTML= xmlHttp.responseText;
      document.getElementById("loaderEmail").style.visibility="hidden";
      }else{document.getElementById("loaderEmail").style.visibility="visible";}
    }
  xmlHttp.open("GET","phpreturn2register_email?email="+vale,true);
  xmlHttp.send(null);
}
}//end function returnEmail

function toGrammar() {
window.open('main/gram','',
'top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no, location=no,height='+screen.availHeight+',width='+screen.availWidth);
}
function toRead() {
window.open('main/read','',
'top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no, location=no,height='+screen.availHeight+',width='+screen.availWidth);
}
function openHist1(hid)
{
window.open('main/openHistory1?id='+hid,'',
'toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,height=500,width=600');
}
function openHist2(hid)
{
window.open('main/openHistory2?id='+hid,'',
'toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,height=500,width=600');
}
function openHist3(hid)
{
window.open('main/openHistory3?id='+hid,'',
'toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,height=500,width=600');
}
function toNews(id)
{
window.open('main/toNews?id='+id,'',
'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes, location=no,height=500,width=600');
}
function backTut_hover(id)
{
document.getElementById("border_ud"+id).style.backgroundColor="#CCE6FF";
}
function backTut_out(id)
{
document.getElementById("border_ud"+id).style.backgroundColor="#FFFFFF";
}
function openClassified(what)
{

window.open('classifiedAds/html/'+what+'.html','',
'toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,height=700,width=800');
}



