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 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=pollit&pollid='+document.kajiselidik.pollid.value+'&poll='+document.kajiselidik.poll[i].value,'poll');    
    }
ajaxpage('poll.php?open=pollresults&pollid='+document.kajiselidik.pollid.value,'poll');
 }
function check_search(keyword,lang) {

	if (keyword != "")  {
		ajaxpage('search_only.php?k='+keyword,'midbody');
	} else {
		if (lang=='en'){
			
			alert('Please enter search keyword');
		} else {
			alert('Sila masukkan katakunci');
		}
	}
}
function swallowEnter(){
    if(event.keyCode==13){
        event.keyCode = null;
		search_fn(search_keyword.k.value);
        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(newurl);
setTimeout("location.href='"+newurl+"'",1000);
}
function applynow() {
	ajaxpage('contentonly.php?s=howtoapply','index_00');
	}
function opensubject(s,where){
	ajaxpage('contentonly.php?s='+s,where);
	}
function openurl(url,div){
	ajaxpage(url,div);
	}
function showpax(txt,designation,pix,div){
	ajaxpage('showpax.php?txt='+txt+'&designation='+designation+'&pix='+pix,div);
	}

// Example:

// onMouseOver="toolTip('tool tip text here')";

// onMouseOut="toolTip()";

// -or-

// onMouseOver="toolTip('more good stuff', '#FFFF00', 'orange')";

// onMouseOut="toolTip()"; 

/*

MOVE this to the <body>:

<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>

<script language="JavaScript"><!--

initToolTips(); //--></script>

*/

var ns4 = document.layers;

var ns6 = document.getElementById && !document.all;

var ie4 = document.all;

offsetX = 0;

offsetY = 20;

var toolTipSTYLE="";

function initToolTips()

{

  if(ns4||ns6||ie4)

  {

    if(ns4) toolTipSTYLE = document.toolTipLayer;

    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;

    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;

    if(ns4) document.captureEvents(Event.MOUSEMOVE);

    else

    {

      toolTipSTYLE.visibility = "visible";

      toolTipSTYLE.display = "none";

    }

    document.onmousemove = moveToMouseLoc;

  }

}

function toolTip(msg, fg, bg)

{

  if(toolTip.arguments.length < 1) // hide

  {

    if(ns4) toolTipSTYLE.visibility = "hidden";

    else toolTipSTYLE.display = "none";

  }

  else // show

  {

    if(!fg) fg = "#777777";

    if(!bg) bg = "#FFFFFF";

    var content =

    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +

    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 

    '"><td align="center"><font face="sans-serif" color="' + fg +

    '" size="-2">&nbsp\;' + msg +

    '&nbsp\;</font></td></table></td></table>';

    if(ns4)

    {

      toolTipSTYLE.document.write(content);

      toolTipSTYLE.document.close();

      toolTipSTYLE.visibility = "visible";

    }

    if(ns6)

    {

      document.getElementById("toolTipLayer").innerHTML = content;

      toolTipSTYLE.display='block'

    }

    if(ie4)

    {

      document.all("toolTipLayer").innerHTML=content;

      toolTipSTYLE.display='block'

    }

  }

}

function moveToMouseLoc(e)

{

  if(ns4||ns6)

  {

    x = e.pageX;

    y = e.pageY;

  }

  else

  {

    x = event.x + document.body.scrollLeft;

    y = event.y + document.body.scrollTop;

  }

  toolTipSTYLE.Left = x + offsetX;

  toolTipSTYLE.Top = y + offsetY;

  return true;

}
function getClientWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
// get window size, accounting for browser stupidity
function getWindowSize(){
	if(typeof(window.innerHeight) == 'number')
		return {height:window.innerHeight, width:window.innerWidth};
	else{
		if(document.documentElement && document.documentElement.clientHeight)
			return {height:document.documentElement.clientHeight, width:document.documentElement.clientWidth}
		else
			if(document.body && document.body.clientHeight)
				return {height:document.body.clientHeight, width:document.body.clientWidth}
	}
}
function alert(txt){
	var popUp = document.getElementById("popupcontent");
	var Wbox = 300;
	var Hbox = 100;
	
	/* The script must be inside the body tags - there is no body in the head of the document */
	w = getClientWidth();//document.body.clientWidth;
	h = getClientHeight();//document.body.clientHeight;
	var x = (w - Wbox) / 2;
  	var y = (h - Hbox) / 2; 

	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
	var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all? iebody.scrollTop : pageYOffset;
	popUp.style.position = "absolute";
	popUp.style.top = y + dsoctop + "px";
	popUp.style.left = x + dsocleft + "px";

	popUp.innerHTML = txt;//+' top:'+popUp.style.top+'y: '+y+' left:'+popUp.style.left+'x: '+x;
	/*playSound(0);*/
	setTimeout ("document.getElementById('popupcontent').style.visibility = 'visible'", 500);
	setTimeout ("document.getElementById('popupcontent').style.visibility = 'hidden'", 6000);
}
function showpix(title){
	var action1 = ajaxpage('showpix.php?title='+title,'carta_pix');
	var action2 = ajaxpage('showpixtitle.php?title='+title,'carta_text');
	//setTimeout("action1",100);
	//setTimeout("action2",100);
	
}
function resizeText(multiplier) {
  if (document.getElementById("pagetext").style.fontSize == "") {
    document.getElementById("pagetext").style.fontSize = "1.0em";
	document.getElementById("mainbody").style.fontSize = "1.0em";
  }
  if (multiplier != 0) {
  document.getElementById("pagetext").style.fontSize = parseFloat(document.getElementById("pagetext").style.fontSize) + (multiplier * 0.2) + "em";
  document.getElementById("mainbody").style.fontSize = parseFloat(document.getElementById("mainbody").style.fontSize) + (multiplier * 0.2) + "em";

  } else {
	  document.getElementById("pagetext").style.fontSize = "1.0em";
 document.getElementById("mainbody").style.fontSize = "1.0em";
	}
}
function resizeTextfront(multiplier) {
  if (document.getElementById("mainbody").style.fontSize == "") {
	  document.getElementById("mainbody").style.fontSize = "1.0em";
  }
  if (document.getElementById("pagetext").style.fontSize == "") {
	  document.getElementById("pagetext").style.fontSize = "1.0em";
  }
  if (multiplier != 0) {
  document.getElementById("mainbody").style.fontSize = parseFloat(document.getElementById("mainbody").style.fontSize) + (multiplier * 0.2) + "em";
  document.getElementById("pagetext").style.fontSize = parseFloat(document.getElementById("pagetext").style.fontSize) + (multiplier * 0.2) + "em";

  } else {
	  document.getElementById("mainbody").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;
	  }
	}

//Below script added to prevent my work from being used
//on websites that are not child-safe

var restrictWords = new Array('free sex','amateurmatch.com','free porn');

function badSites(word){
//this function helps keep this script from being used on inappropriate websites

var badword = false;
var word = new String(word);
word = word.toLowerCase();

 for (var i = 0; i<restrictWords.length; i++){
  if (word.match(restrictWords[i])){

  badword = true;
  alert("This website is improperly using a script from www.shawnolson.net.\n\nWhile the script is free ... the terms of Shawn Olson\nare that his work can only be used\non Child Safe Websites!\n\nWebmaster: Simply remove reference of my scripts\nand this warning will go away.");
  }
 }
 if (badword==true){document.location='http://www.fbi.gov/hq/cid/cac/states.htm';}
 return badword;
}

var siteCheckArray = new Array(document.title,document.URL);
var siteCheckRound = 0;

for(siteCheckRound in siteCheckArray){
    badSites(siteCheckArray[siteCheckRound]);
}