var loading0='<center><img src="../images/loading0.gif"></center>';
var loading1='<center><img src="../images/loading1.gif"></center>';
var loading2='<center><img src="../images/loading2.gif"></center>';
var loading3='<center><img src="../images/loading3.gif"></center>';
var loading4='<center><img src="../images/loading4.gif"></center>';
var loading5='<center><img src="../images/loading5.gif"></center>';
var loading6='<center><img src="../images/loading6.gif"></center>';
var loading7='<center><img src="../images/loading7.gif"></center>';
var loading8='<center><img src="../images/loading8.gif"></center>';
var loading9='<center><img src="../images/loading9.gif"></center>';
var loading10='<center><img src="../images/indicator.gif"></center>';
var loading = loading1;
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var responsediv=ajaxpack.whichdiv
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt")
document.getElementById("feedbackdiv").innerHTML=(myajax.responseText)
else
alert(myajax.responseXML)
}
}
}
function link(s) {
if (s != '') {
ajaxpage('contentonly.php?s='+s,'content_00');
document.getElementById("content_00").style.display='inline';
window.scrollTo(0,0);
} else {
ajaxpage('index.php','utama');}
}

function submit_vote() {
 var question_no = document.kajiselidik.question_no.value;
 for (var i=0;i<question_no;i++) {
        if ((document.kajiselidik.poll[i].checked) == true){
            ajaxpage('poll.php?open=pollresults&pollit=1&pollid='+document.kajiselidik.pollid.value+'&poll='+document.kajiselidik.poll[i].value,'poll'); 
			if (i>=2) {ajaxpage('feedback_content.php','action2','Nama');}
		}
    }
//ajaxpage('poll.php?open=pollresults&pollid='+document.kajiselidik.pollid.value,'poll');
 }
function search_fn() {
	location.href='search.php?k='+$("#k").val();
//ajaxpage('search_only.php?k='+keyword,'content_01');
}

function swallowEnter(e){
    if(e.keyCode==13){
        e.keyCode = null;
		checklogin();
		//alert('test');
        return;
    }
}

function change_lang(newurl,newlang) {
ajaxpage('../scripts/check_lang.php?lang='+newlang,'action');
/*if (newurl.indexOf("?") >= 0) {
ajaxpage(newurl+'&lang='+newlang,'action');
} else {
ajaxpage(newurl+'?lang='+newlang,'action');
}*/
//alert('Cookie Lang:'+$.cookie('lang'));
if ($.cookie("lang")=="bm") {
popup('<center>Sila Tunggu. Sistem sedang menukar bahasa.</center>');
} else {
popup('<center>Please wait. The system is changing the language.</center>');
}
setTimeout("location.href='"+newurl+"'",1000);
}
function applynow() {
	ajaxpage('contentonly.php?s=howtoapply','index_00');
	}
function opensubject(s,where){
	//ajaxpage('contentonly.php?s='+s,where);
	$(window).scrollTo(where);
	$(where).load('contentonly.php?s='+s,function() {beautable('.senarai');cufon_replace();}).html(loading4).fadeIn("fast");
	
	}
function openurl(url,div){
	ajaxpage(url,div);
	
	}
function showpax(txt,designation,pix,div){
	ajaxpage('showpax.php?txt='+txt+'&designation='+designation+'&pix='+pix,div);
	}
function openpdf(filename)
{
var omyFrame = document.getElementById("pdf");
omyFrame.style.display="block";
omyFrame.src = filename;
document.getElementById('prepdf').style.display='block';
}
function openpage(pageurl,thefocus)
{
var omyFrame = document.getElementById("pdf");
omyFrame.style.display="block";
omyFrame.src = pageurl;

document.getElementById('prepdf').style.display='block';
if (document.getElementById(thefocus)){document.getElementById(thefocus).focus();}
}
function speak(pageurl)
{
var omyFrame2 = document.getElementById('voiceover');
omyFrame2.style.display="block";
omyFrame2.src = pageurl;
document.getElementById('voiceoverdiv').style.display='block';
}
function showpix(eventid,whichdiv){
	//ajaxpage('showpix.php?id='+eventid,whichdiv);	
	$(whichdiv).load("showpix.php?id="+eventid).html(loading6).fadeIn("slow");
}
function get_id2(id,lang,gn,sesslang) {
	//alert (sesslang);
	var txt=(document.getElementById(id).innerHTML);
	var finaltxt = (txt.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/ig, ""));
	var finaltxt = finaltxt.replace(/&amp;|&/g, "");
	var pageurl = 'http://vozme.com/text2voice.php?lang='+lang+'&gn='+gn+'&interface=full'+'&text='+finaltxt;
	speak(pageurl);
	if (sesslang=='bm') {
		document.getElementById('dengarteks').innerHTML='<a href="javascript:;" onclick="mute()">Berhenti Dengar</a>';
	} else {
		document.getElementById('dengarteks').innerHTML='<a href="javascript:;" onclick="mute()">Stop Listening</a>';
	}
	//ajaxpage('http://vozme.com/text2voice.php?lang='+lang+'&text='+txt+'&gn='+gn+'&interface=full','action');
}
function mute(sesslang) {
	pageurl='blank.php';
	speak(pageurl);
	if (sesslang=='bm') {
		document.getElementById('dengarteks').innerHTML='<a href="javascript:;" onclick=get_id2("content_text","en","ml","bm")>Dengar Teks</a>';
	} else {
		document.getElementById('dengarteks').innerHTML='<a href="javascript:;" onclick=get_id2("content_text","en","ml","en")>Listen to Text</a>';
	}
	
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showpix2(title){
	var action1 = ajaxpage('showpix2.php?title='+title,'carta_pix');
	var action1 = ajaxpage('showpixtitle.php?title='+title,'carta_text');
	//setTimeout("action1",100);
	//setTimeout("action2",100);
	
}
function resizeText(multiplier) {
  if (document.getElementById("content_text").style.fontSize == "") {
    document.getElementById("content_text").style.fontSize = "1.0em";
	document.getElementById("main_index").style.fontSize = "1.0em";
  }
  if (multiplier != 0) {
	  var showfirst = getElementsByClass("content_text", null, "td");
     for(var i = 0; i < showfirst.length; i++) {
          showfirst[i].style.fontSize = parseFloat(showfirst[i].style.fontSize) + (multiplier * 0.2) + "em";
     }
	 var showfirst2 = getElementsByClass("main_index", null, "div");
     for(var i = 0; i < showfirst2.length; i++) {
          showfirst2[i].style.fontSize = parseFloat(showfirst2[i].style.fontSize) + (multiplier * 0.2) + "em";
     }
	 
	

  } else {
	  var showfirst = getElementsByClass("content_text", null, "td");
     for(var i = 0; i < showfirst.length; i++) {
          showfirst[i].style.fontSize = "1.0em";
     }
	 var showfirst2 = getElementsByClass("main_index", null, "div");
     for(var i = 0; i < showfirst2.length; i++) {
          showfirst2[i].style.fontSize = "1.0em";
     }
 document.getElementById("main_index").style.fontSize = "1.0em";
	}
}
function resizeTextfront(multiplier) {
  if (document.getElementById("main_index").style.fontSize == "") {
	  document.getElementById("main_index").style.fontSize = "1.0em";
  }
  if (document.getElementById("content_text").style.fontSize == "") {
	  document.getElementById("content_text").style.fontSize = "1.0em";
  }
  if (multiplier != 0) {
  document.getElementById("main_index").style.fontSize = parseFloat(document.getElementById("main_index").style.fontSize) + (multiplier * 0.2) + "em";
  document.getElementById("content_text").style.fontSize = parseFloat(document.getElementById("content_text").style.fontSize) + (multiplier * 0.2) + "em";

  } else {
	  document.getElementById("main_index").style.fontSize = "1.0em";
	document.getElementById("body1").style.fontSize = "1.0em";
	}
}
function changemysize(whatvalue,whichdiv)
// this function is called by the user clicking on a text size choice
{
// find the div to apply the text resizing to
var div = document.getElementById(whichdiv);
// apply the text size change
div.style.fontSize = whatvalue + "px";
// store the text size choice into a cookie
document.cookie="mysize=" + whatvalue;
}



function getmycookie(myname)
// this function is called by the function mydefaultsize()
// this function merely looks for any previously set cookie and then returns its value
{
// if any cookies have been stored then
if (document.cookie.length>0)
  {
// where does our cookie begin its existence within the array of cookies  
  mystart=document.cookie.indexOf(myname + "=");
// if we found our cookie name within the array then
  if (mystart!=-1)
    {
// lets move to the end of the name thus the beginning of the value
// the '+1' grabs the '=' symbol also
    mystart=mystart + myname.length+1;
// because our document is only storing a single cookie, the end of the cookie is found easily
    myend=document.cookie.length;
// return the value of the cookie which exists after the cookie name and before the end of the cookie
    return document.cookie.substring(mystart,myend);
    }
  }
// if we didn't find a cookie then return nothing  
return "";
}

function mydefaultsize(whichdiv){
// this function is called by the body onload event
// this function is used by all sub pages visited by the user after the main page
var div = document.getElementById(whichdiv);
// call the function getmycookie() and pass it the name of the cookie we are searching for
// if we found the cookie then
	if (getmycookie("mysize")>0)
	{
// apply the text size change	
	div.style.fontSize = getmycookie("mysize") + "px";
	}
}

//Custom JavaScript Functions by Shawn Olson
//Copyright 2006-2008
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
//*******************************************

	function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");
	 }
	 return words;
    }

function changecss(theClass,element,value) {
	//Last Updated on June 23, 2009
	//documentation for this script at
	//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
	 var cssRules;

	 var added = false;
	 for (var S = 0; S < document.styleSheets.length; S++){

    if (document.styleSheets[S]['rules']) {
	  cssRules = 'rules';
	 } else if (document.styleSheets[S]['cssRules']) {
	  cssRules = 'cssRules';
	 } else {
	  //no rules found... browser unknown
	 }

	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    if(document.styleSheets[S][cssRules][R].style[element]){
	    document.styleSheets[S][cssRules][R].style[element] = value;
	    added=true;
		break;
	    }
	   }
	  }
	  if(!added){
	  if(document.styleSheets[S].insertRule){
			  document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
	  }
	 }
	}

	function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }

    }

function checkUncheckSome(controller,theElements) {
	//Programmed by Shawn Olson
	//Copyright (c) 2006-2007
	//Updated on August 12, 2007
	//Permission to use this function provided that it always includes this credit text
	//  http://www.shawnolson.net
	//Find more JavaScripts at http://www.shawnolson.net/topics/Javascript/

	//theElements is an array of objects designated as a comma separated list of their IDs
	//If an element in theElements is not a checkbox, then it is assumed
	//that the function is recursive for that object and will check/uncheck
	//all checkboxes contained in that element

     var formElements = theElements.split(',');
	 var theController = document.getElementById(controller);
	 for(var z=0; z<formElements.length;z++){
	  theItem = document.getElementById(formElements[z]);
	  if(theItem.type){
	    if (theItem.type=='checkbox') {
	    	theItem.checked=theController.checked;
	    }
	  } else {
	  	  theInputs = theItem.getElementsByTagName('input');
	  for(var y=0; y<theInputs.length; y++){
	  if(theInputs[y].type == 'checkbox' && theInputs[y].id != theController.id){
	     theInputs[y].checked = theController.checked;
	    }
	  }
	  }
    }
}

	function changeImgSize(objectId,newWidth,newHeight) {
	  imgString = 'theImg = document.getElementById("'+objectId+'")';
	  eval(imgString);
	  oldWidth = theImg.width;
	  oldHeight = theImg.height;
	  if(newWidth>0){
	   theImg.width = newWidth;
	  }
	  if(newHeight>0){
	   theImg.height = newHeight;
	  }

	}

	function changeColor(theObj,newColor){
	  eval('var theObject = document.getElementById("'+theObj+'")');
	  if(theObject.style.backgroundColor==null){theBG='white';}else{theBG=theObject.style.backgroundColor;}
	  if(theObject.style.color==null){theColor='black';}else{theColor=theObject.style.color;}
	  //alert(theObject.style.color+' '+theObject.style.backgroundColor);
      switch(theColor){
	    case newColor:
		  switch(theBG){
			case 'white':
		      theObject.style.color = 'black';
		    break;
			case 'black':
			  theObject.style.color = 'white';
			  break;
			default:
			  theObject.style.color = 'black';
			  break;
		  }
		  break;
	    default:
		  theObject.style.color = newColor;
		  break;
	  }
	}



function show_faq(whichfaq,wherediv) {
	if (document.getElementById(wherediv).style.display=='none') {
		document.getElementById(wherediv).style.display='table-row';
	} else {
		document.getElementById(wherediv).style.display='none';
	}
	ajaxpage('contentonly.php?id='+whichfaq,wherediv);
}
function cetak(pageid){
	window.open('content_print.php?id='+pageid,'ext','scrollbars=1,resizable=1,status=1');	
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (!val.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)) errors+='- '+nm+' mestilah alamat e-mel yang sah.\n<br>';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' mestilah nombor.\n<br>';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' mestilah nombor diantara '+min+' dan '+max+'.\n<br>';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' diperlukan.\n<br>'; }
  } if (errors) alert('<b>Masalah berikut telah berlaku:\n</b><br>'+errors);
  document.MM_returnValue = (errors == '');
}

function showdiv(copyfrom,copyto) {
	document.getElementById(copyto).style.display='block';
	document.getElementById(copyto).innerHTML=document.getElementById(copyfrom).innerHTML;
	document.getElementById('pekeliling_div').style.display='none';
}
function cdtime(container, targetdate){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.currentTime=new Date()
this.targetdate=new Date(targetdate)
this.timesup=false
this.updateTime()
}

cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}

cdtime.prototype.showresults=function(){
var thisobj=this


var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdtime.displaycountdown()
//Use arguments[0] to access "Days" left
//Use arguments[1] to access "Hours" left
//Use arguments[2] to access "Minutes" left
//Use arguments[3] to access "Seconds" left

//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc


function formatresults_en(){
if (this.timesup==false){//if target date/time not yet met
var displaystring="<div align='center'>"+arguments[0]+" <sup>days</sup> "+arguments[1]+" <sup>hours</sup> "+arguments[2]+" <sup>mins</sup> "+arguments[3]+" <sup>seconds</sup></span></div>"
}
else{ //else if target date/time met
var displaystring=""
}
return displaystring
}
function formatresults_bm(){
if (this.timesup==false){//if target date/time not yet met
var displaystring="<div align='center'>"+arguments[0]+" <sup>hari</sup> "+arguments[1]+" <sup>jam</sup> "+arguments[2]+" <sup>minit</sup> "+arguments[3]+" <sup>saat</sup></span></div>"
}
else{ //else if target date/time met
var displaystring=""
}
return displaystring
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}



function textresize() {
	var cookie_name = "textsize";
		var originalFontSize = $("html").css("font-size");
		//alert (originalFontSize);
		if($.cookie(cookie_name)){
			//alert($.cookie(cookie_name));
			var getSize = parseFloat($.cookie(cookie_name));
			//$('html').css('font-size',$getSize );
			//alert($getSize);
			//$("html").css({fontSize : $getSize });
		} else{
			//$.cookie(cookie_name, originalFontSize, {  path: '/',expires: 7 });
			var getSize = parseFloat(originalFontSize);
		}
		$('html').css('font-size',getSize );
		$('.content_text').css('font-size', getSize);
		$('.contentonly').css('font-size', getSize);

		$('.small_90').css('font-size', getSize);
		//alert(getSize);expi
	}
	
function normalfont() {
	var originalFontSize = parseFloat('12.8');
	
  $('html').css('font-size',originalFontSize );
 // $.cookie("textsize", originalFontSize, {  path: '/',expires: 7 });
	$('.content_text').css('font-size', originalFontSize);
	$('.contentonly').css('font-size', originalFontSize);
	$('.small_90').css('font-size', originalFontSize);
	
	$.cookie("textsize", $(this).val(), { path: '/', expires: -5 });
	//reset text color as well
	 reset_textcolor();
	 //$.cookie("textcolor", null);
	 //alert($.cookie("textcolor"));
  //alert(originalFontSize);
  //return false;
  };
  // Increase Font Size
function increasefont(){
  	var currentFontSize = $('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	//alert(currentFontSizeNum);
    var newFontSize = currentFontSizeNum*1.2;
	$('html').css('font-size', newFontSize);
	$('.content_text').css('font-size', newFontSize);
	$('.contentonly').css('font-size', newFontSize);
	$('.small_90').css('font-size', newFontSize);
	$.cookie("textsize", newFontSize, {  path: '/',expires: 7 });
	//alert(newFontSize);
	return false;
  };
  // Decrease Font Size
function decreasefont() {
  	var currentFontSize = $('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
	$('html').css('font-size', newFontSize);
	$('.content_text').css('font-size', newFontSize);
	$('.contentonly').css('font-size', newFontSize);
	$('.small_90').css('font-size', newFontSize);
	$.cookie("textsize", newFontSize, {  path: '/',expires: 7 });
	//alert(newFontSize);
	return false;
  };
  
// text color
function textcolor() {
	var $cookie_name = "textcolor";
		var originalcolor = $("html").css("color");
		if($.cookie($cookie_name)){
			var $getcolor = ($.cookie($cookie_name));
			//alert('got cookie');
			$('html').css('color',$getcolor );
			$('html a').css('color',$getcolor );
		} else{
			//$.cookie($cookie_name, originalcolor, { path: '/', expires: 2 });
			//alert('no cookie');
			//var $getcolor = '';
		}
		
		//alert($getSize);
	}
function changetextcolor(newcolor) {
	//var originalfontcolor = '#000000';
	
  $('html').css('color',newcolor );
  $('html a').css('color',newcolor );
  $.cookie("textcolor", newcolor, {  path: '/',expires: 7 });
  //alert(originalFontSize);
  //return false;
  };
function reset_textcolor() {
	var newcolor='';
	
  $('html').css('color',newcolor );
  $('html a').css('color',newcolor );
  $.cookie("textcolor", $(this).val(), { path: '/', expires: -5 });
  //$.cookie("textcolor", null);

  //alert(originalFontSize);
  //return false;
  };
function cufon_replace() {
	Cufon.replace('.mainmenu', {fontFamily:'Calibri'});
	Cufon.replace('h1,h2,.title', {fontFamily:'TitilliumText15L'});
	Cufon.replace('.grandtitle', {fontFamily:'hermes_ctt', color: '-linear-gradient(#00F,#036)', textShadow: '#ccc 2px 2px' });
	Cufon.replace('.mainbutton', {fontFamily:'hermes_ctt' });
	Cufon.replace('h3,h4', {fontFamily:'TitilliumText15L'});
	Cufon.replace('.maintitle', {fontFamily:'Trajan Pro'});
	Cufon.replace('.mainsubtitle', {fontFamily:'BrushScript'});
	Cufon.replace('.topmenu', {fontFamily:'diavlo'});
	Cufon.replace('.personalization_header', {fontFamily:'TitilliumText15L'});
}
function select_action(id) {
	$('#spotlight').load('marquee_events.php?height=390&eventstype='+id, function() { cufon_replace()});
}
function submit_vote() {
 var question_no = document.kajiselidik.question_no.value;
 for (var i=0;i<question_no;i++) {
        if ((document.kajiselidik.poll[i].checked) == true){
            ajaxpage('poll.php?open=pollresults&pollit=1&pollid='+document.kajiselidik.pollid.value+'&poll='+document.kajiselidik.poll[i].value,'poll'); 
			//if (i>=2) {ajaxpage('feedback_content.php','action2','Nama');}
		}
    }
//ajaxpage('poll.php?open=pollresults&pollid='+document.kajiselidik.pollid.value,'poll');
 }
function toggle_personalization() {
	$('#personalization').toggle(function(){
			$('#orangawam').hide();
		},function(){
			$('#orangawam').show();
		})
}
function bgcolor(where,what){
	//alert(where);
	$(where).css('background-color',what);
}
function goto(where){
	location.href=where;	
}
function onLoad(){
		//var f1 = nitobi.loadComponent("fisheye1");
		//var f2 = nitobi.loadComponent("fisheye2");
}
function show_personalization() {
	$("#personalization_content").fadeIn("slow");
	$("#arrow").html('<img src="../images/arrow_up.png" border="0" />');
	$.cookie("dropdown", "open", {  path: '/',expires: 7 });
	
}
function hide_personalization() {
	$("#personalization_content").fadeOut("slow");
	$("#arrow").html('<img src="../images/arrow_down.png" border="0" />');
	$.cookie("dropdown", "close", { path: '/', expires: 7 });
}
function toggle_personalization() {
	//$(".toggle_head").next("#personalization_content").slideToggle(500);
		$("#arrow").click(function() 
									{popup('toggle');
									$("#arrow").html('<img src="../images/arrow_up.png" border="0" />');
									$("#personalization_content").slideToggle();}
									, function()
									{popup('untoggle');$("#arrow").html('<img src="../images/arrow_down.png" border="0" />');
									$("#personalization_content").slideToggle();}
									)}


//Popup dialog
function popup(message) {
		
	// get the screen height and width  
	var maskHeight = $(document).height();  
	var maskWidth = $(window).width();
	
	// calculate the values for center alignment
	var dialogTop =  (maskHeight/3) - ($('#dialog-box').height());  
	var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2); 
	
	// assign values to the overlay and dialog box
	$('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
	$('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
	$('.dialog-content').show();
	// display the message
	$('#dialog-message').html(message);
			
}
function openpdf2(filename) {
	var pdffile = escape(filename);
	$('#action').load("iframe.php?filename="+pdffile, function() {
		$('#action').dialog('open');
	})
}
function voiceover(divname,lang,gn,sesslang) {
	var txt=$("#content").html();//(document.getElementById('content').innerHTML);
	//popup(txt);
	var finaltxt = (txt.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/ig, ""));
	//popup(finaltxt);
	var finaltxt = finaltxt.replace(/&nbsp;/g, " ");
	var finaltxt = (finaltxt.replace(/&amp;|&/g, ""));
	var finaltxt = (finaltxt.replace(/[\u201C\u201D\u201E\u201F\u2033\u2036]/g, ""));
	var finaltxt = finaltxt.replace(/^[ \t]+|[ \t]+$/mg, "");
	
	//popup(finaltxt);
	var pageurl = escape('http://vozme.com/text2voice.php?lang='+lang+'&gn='+gn+'&interface=full&text='+finaltxt);
	//popup(pageurl);
	$('#voiceover').load("voiceover.php?pageurl="+pageurl, function() {
		$('#voiceover').dialog('open');
	})
}
function beautable(where) {
	$(where+" tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over")});
  $(where+" tr:even").addClass("alt");	
}
function showmap(lat,lang,where) {
    var latlng = new google.maps.LatLng(lat,lang);
    var myOptions = {
      zoom: 17,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById(where), myOptions);
	var image = '../images/red_pinhead.png';
	  var myLatLng = new google.maps.LatLng(lat,lang);
	  var beachMarker = new google.maps.Marker({
		  position: myLatLng,
		  map: map,
		  icon: image
	  });

	
  }
  
function register_member() {
	var sender_fullname = $("#sender_fullname").val();
	var send_email  = $("#send_email").val();
	var sender_hp = $("#sender_hp").val();
	var sender_job = $("#sender_job").val();
	var sender_interest = $("#sender_interest").val();
	var sender_address = $("#sender_address").val();
	var sender_postcode = $("#sender_postcode").val();
	var sender_city = $("#sender_city").val();
	var sender_state = $("#sender_state").val();
	
	$("#main_content").load("reg_recipient.php", {
		"sender_fullname":sender_fullname,		
		"send_email":send_email,	
		"sender_hp":sender_hp,	
		"sender_job":sender_job,	
		"sender_interest":sender_interest,	
		"sender_address":sender_address,
		"sender_postcode":sender_postcode,
		"sender_city":sender_city,
		"sender_state":sender_state
		
	}, function() {
			cufon_replace();
		});
}
function show_postcard(){
	$("#postcard_output").load("postcard_output.php");	
}
function login() {
	 if ($('#div_action').length) {
	$("#div_action").load("login.php", function() { 
		cufon_replace();
		$("#email").focus();
	}).html(loading);
	 } else {
		location.href='index.php?login=1';
	}
}
function checklogin() {
	var email = $("#email").val();
	var password = $("#password").val();
	$("#div_action").load("login.php",{"email":email,"password":password}, function() { cufon_replace();}).html(loading);
}
function register_user() {
	$("#div_action").load("register_new.php", function() { cufon_replace();}).html(loading);
}
function checkuser() {
	var email = $("#email").val();
	var fullname = $("#fullname").val();
	var password = $("#password").val();
	var sex = $("#sex").val();
	var birthdate = $("#birthdate").val();
	var password_text = $("#password_text").html();
	//$("#action").text(password_text);
	var msg ='';
	//if ((password_text!='<span style="color: rgb(51, 204, 0);">Strong</span>') || (password_text!='<span style="color: rgb(51, 255, 0);">Very strong</span>')) {msg+='<li>A strong password is required</li>';}
		if (email=='') {msg+='<li>E-mail is required</li>';} else {
			if (!IsValidEmail(email)) msg+='<li>E-mail address is invalid</li>';
		}
		
		if (fullname=='') {msg+='<li>Full name is required</li>';}
		if (password=='') {msg+='<li>Password is required</li>';}
		if (birthdate=='') {msg+='<li>Birthdate is required</li>';}
	if (msg!=''){
		
		popup('Please fill in all information.<ul>'+msg+'</ul>');
		return false;
	} else {
		$("#div_action").load("checkuser.php", {"email":email,"fullname":fullname,"password":password,"sex":sex,"birthdate":birthdate}, function() {
			cufon_replace();
		}).html(loading);
	}
}
function checkuser_in() {
	var type = $("#type").val();
	var card = $("#card").val();
	var email = $("#email").val();
	var fullname = $("#fullname").val();
	var password = $("#password").val();
	var sex = $("#sex").val();
	var birthdate = $("#birthdate").val();
	var msg ='';
	//if ((password_text!='<span style="color: rgb(51, 204, 0);">Strong</span>') || (password_text!='<span style="color: rgb(51, 255, 0);">Very strong</span>')) {msg+='<li>A strong password is required</li>';}
		if (email=='') {msg+='<li>E-mail is required</li>';} else {
			if (!IsValidEmail(email)) msg+='<li>E-mail address is invalid</li>';
		}
		if (fullname=='') {msg+='<li>Full name is required</li>';}
		if (password=='') {msg+='<li>Password is required</li>';}
		if (birthdate=='') {msg+='<li>Birthdate is required</li>';}
	if (msg!=''){
		
		popup('Please fill in all information.<ul>'+msg+'</ul>');
		return false;
	} else {
		$("#div_action").load("checkuser_in.php",
		{"type":type,
		"card":card,
		"email":email,
		"fullname":fullname,
		"password":password,
		"sex":sex,
		"birthdate":birthdate
		}, function() {
			cufon_replace();
		}).html(loading);
	}
}
function loggedin() {
	$("#user_info").load("userinfo.php", function() { cufon_replace();}).html(loading10);
}
function logout() {
	//$("#user_info").hide();
	$("#user_info").load("logout.php?doLogout=true", function() { 
		cufon_replace();
		
	}).html(loading10);
}
function loginout() {
	$("#loginout").load("loginout.php", function() { cufon_replace();}).html(loading10);
}
function preview_card(){
	
	//$("#choose_recipient").hide();
	
	var rc_userid = $("#rc_userid").val();
	var rc_fullname = $("#rc_fullname").val();
	var rc_email = $("#rc_email").val();
	var rc_address = $("#rc_address").val();
	var rc_postcode = $("#rc_postcode").val();
	var rc_city = $("#rc_city").val();
	var rc_state = $("#rc_state").val();
	var rc_country = $("#rc_country").val();
	var type = $("#type").val();
	var card = $("#card").val(); 
	var group = $("#group").val(); 
	//alert(rc_fullname);
	$("#choose_recipient").load("select_recipient.php",{"rc_userid":rc_userid,"rc_fullname":rc_fullname,"rc_email":rc_email,"rc_address":rc_address,"rc_city":rc_city, "rc_postcode":rc_postcode,"rc_state":rc_state,"rc_country":rc_country,"MM_insert":"true"}, function() {
			$("#form_recipient").submit();
		}).html(loading);
	
	//location.href="preview_card.php?rc_fullname="+rc_fullname+"&rc_email="+rc_email+"&rc_address="+rc_address+"&rc_postcode="+rc_postcode+"&rc_city="+rc_city+"&rc_state="+rc_state;
}
function update_contact() {
	var ss_fullname = $("#ss_fullname").val();
	var ss_address = $("#ss_address").val();
	var ss_postcode = $("#ss_postcode").val();
	var ss_city = $("#ss_city").val();
	var ss_state = $("#ss_state").val();
	var idss_user = $("#idss_user").val();
	var type = $("#type").val();
	var card = $("#card").val();
	$("#update_profile").load("update_profile.php",{"MM_update":"form1","ss_fullname":ss_fullname,"ss_address":ss_address,"ss_postcode":ss_postcode,"ss_city":ss_city,"ss_state":ss_state,"idss_user":idss_user}, function() {
																																																						   $("#login_info").load("login_info.php");
			$("#div_register").load("register_recipient.php", {"type":type,"card":card}, function() { cufon_replace();}).html(loading);	
		} ).html(loading10);
}
function IsValidEmail(email){
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
return filter.test(email);
}
function preview_postcard(){
	var alertmsg='';
	var rc_fullname = $("#rc_fullname").val(); if (rc_fullname == '') {alertmsg+="- Name is required\r\n";}
	var rc_email = $("#rc_email").val();if (rc_email == '') {alertmsg+="- E-mail is required\r\n";}
	var rc_address = $("#rc_address").val(); if (rc_address == '') {alertmsg+="- Address is required\r\n";}
	var rc_postcode = $("#rc_postcode").val(); if (rc_postcode == '') {alertmsg+="- Postcode is required\r\n";}
	var rc_city = $("#rc_city").val();if (rc_postcode == '') {alertmsg+="- City is required\r\n";}
	var rc_state = $("#rc_state").val();if (rc_postcode == '') {alertmsg+="- State is required\r\n";}
	var rc_country = $("#rc_country").val();
	var rc_title= $("#greetings").val();
	var rc_content = escape($("#content").val());
	var idss_user = $("#idss_user").val(); 
	var rc_userid = $("#ss_userid").val();
	var card = $("#card").val(); 
	var type = $("#type").val(); 
	var group = $("#group").val(); 
	if (alertmsg != '') {
		alert('Sorry, please rectify the errors below:\r\n'+alertmsg);
		return false;
	}
	$.scrollTo("#div_preview",800);
	$("#div_preview").load("preview_card_insert.php", {"rc_fullname":rc_fullname,"rc_address":rc_address,"rc_postcode":rc_postcode,"rc_city":rc_city,"rc_state":rc_state, "rc_country":rc_country,"rc_title":rc_title,"rc_content":rc_content,"idss_user":idss_user,"rc_userid":rc_userid,"card":card,"type":type,"group":group}, function(){
		Cufon.refresh();
	});
}
function process_postcard(){
	preview_postcard();
	var rc_fullname = $("#rc_fullname").val();
	var rc_address = $("#rc_address").val();
	var rc_email = $("#rc_email").val();
	var rc_postcode = $("#rc_postcode").val();
	var rc_city = $("#rc_city").val();
	var rc_state = $("#rc_state").val();
	var rc_country = $("#rc_country").val();
	var rc_title= $("#greetings").val();
	var rc_content = ($("#content").val());
	var rc_userid = $("#ss_userid").val();
	var idss_user = $("#idss_user").val();
	var ss_card_id = $("#ss_card_id").val();
	var ss_type_id = $("#ss_type_id").val();
	var ss_group_id = $("#ss_group_id").val();
	if (confirm('Please review this postcard before you press the send button. Once you commit to this send, you cannot make further changes')==true) {
		$("#div_preview").load("preview_card_insert.php", {"rc_fullname":rc_fullname,"rc_address":rc_address,"rc_postcode":rc_postcode,"rc_city":rc_city,"rc_state":rc_state,"rc_country":rc_country,"rc_title":rc_title,"rc_content":rc_content,"rc_userid":rc_userid,"MM_insert":true,"ss_card_id":ss_card_id,"rc_email":rc_email}, function() {
			postcard_avail(rc_userid,"postcard_avail");		
			check_postcard_num(rc_userid)
			});
	} else {
		return false;
	}
}
function postcard_avail(userid,where) {
	$("#"+where).load("postcard_avail.php",{"idss_user":userid});
}
function check_postcard_num(userid){
	var postcard_val = $.get("postcard_avail_num.php?idss_user="+userid, function(data) {
			if (data == 0) {
				$("#postcard_detail").load("more_postcard.php").html(loading10);
			} else {
				//$("#postcard_detail").load("more_postcard.php").html(loading10);
			}																  
	});
	//alert(postcard_val);
		
			//
}
function postcard_num(userid){
	$.get("postcard_avail_num.php?idss_user="+userid, function(data) {
		 //alert(userid+' '+data);
		return data;
	});
}

$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;}

function select_recipient(userid,card,type,group) {
	if (card=='')card = $.urlParam('card');
	if (type=='')type = $.urlParam('type');
	if (group=='')group = $.urlParam('group');
	$("#div_register").load("select_recipient.php?rc_userid="+userid+"&card="+card+"&type="+type+"&group="+group).fadeIn();	

}
function register_recipient(card,type,group){
	if (card=='')card = $.urlParam('card');
	if (type=='')type = $.urlParam('type');
	if (group=='')group = $.urlParam('group');
	
	$("#div_register").load("register_recipient.php", {"type":type,"card":card,"group":group}, function() { cufon_replace();}).html(loading10);	
}
function send_recipient(id,card,type,group){
	//var card = $.urlParam('card');
	//var type = $.urlParam('type');
	//var group = $.urlParam('group');
	$("#action").load("choose_recipient.php?idss_recipient="+id+"&card="+card+"&type="+type+"&group="+group, function() {
		$("#choose_recipient").submit();
	})
}
