
function clrImg(obj){
obj.style.backgroundImage="";obj.onkeydown=obj.onmousedown=null;
    }

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


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];}
}


var lastLayer ="";
   function showMenu(name){
    if(document.all[name].style.display != "none"){
     document.all[name].style.display = "none"
    }
    else{
     document.all[name].style.display = ""
    }
   }

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_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 menuon(imgEl) {
    imgEl.src = imgEl.src.replace("01.gif", "02.gif");
}

function menuout(imgEl) {
    imgEl.src = imgEl.src.replace("02.gif", "01.gif");
}

function menuclk1() {
    var disp = document.getElementById('menu1').style.display;
    if (disp == 'none') {
        document.getElementById('menu1').style.display = 'block';
    }
}

function menuclk2() {
    var disp = document.getElementById('menu1').style.display;
    if (disp == 'none') {
        document.getElementById('menu1').style.display = 'none';
    }
}

//================================================== functional JS ===========================================
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function imageview(imagestr) {
    var urlstr = "/imageview.asp?image=http://file.gamescampus.com/CU/wallpaper/" + imagestr;
    window.open(urlstr, "_imagename", "width=600, height=600, statusbar=no, scrollbars=auto, menubar=no");
}


function CheckWriteForm() {
    var obj = document.writeform;
    if (obj.title.value == "") {
        alert("Subject field cannot be blank.");
        obj.title.focus();
        return false;
    } else if (obj.content.value == "") {
        alert("Content field cannot be blank.");
        obj.content.focus();
        return false;
    } else {
        return true;
    }
}

function CheckCommentForm(thisform) {
    if (thisform.content.value == "") {
        alert("Comment field cannot be blank.");
        thisform.content.focus();
        return false;
    }
    else {
        return true;
    }
}

function ListSelectAll(){
	var bool;
	
	if(document.listform.chetitle.checked == true) {
		bool = true;
	}
	else {
		bool = false;
	}
	
	var objCheck = eval("document.getElementsByName('che')");
	if(objCheck!=null){
		if (objCheck.length == undefined){
			objCheck.checked = bool;
		}
		else
		{
			if(objCheck.length == 1){
				document.listform.che.checked = bool;
			}else{
				for(i=0;i<objCheck.length;i++) {
					document.listform.che[i].checked = bool;
				}
			}
		}
	}
}

function ListSelect(checkname) {
	var objCheck = eval("document.getElementsByName('che')");
	var param="";
	var result;

	 if (objCheck != null){
		if (objCheck.length == undefined){
			if(objCheck.checked == true) {
				param = objCheck.value;
			}
		}
		else
		{
		   for(i=0;i<objCheck.length;i++) {
				if (objCheck[i].checked == true)
				{
					param += objCheck[i].value + "|"
				}
		   }
		}
	 } 

	 if(param != "") {
		result = confirm("remove[yes, no] from the list");

		if(result) {
			self.location = "delete.asp?num=" + param;
		}	
	 }
	 else {
		alert('checkbox unselected');
	 }
}

function ConfirmDelete() {
    return confirm("Are you sure you want to remove [yes, no] this?");
}


function Login_Go(form) {
	var userid = form.userid.value;
	var pwd = form.pwd.value;
		
	if( userid == "" ) {
		alert("You must give a ID");
		form.userid.focus();
		return false;
	} 

	if( pwd == "" ) {
		alert("You must give a password");
		form.pwd.focus();
		return false;
	}

	return true;
}


function CheckSearchForm(thisform) {
    if (thisform.find.value == "") {
        alert("Search field cannot be blank.");
        thisform.find.focus();
        return false;
    }
    else {
        return true;
    }
}

function voteinsert(form) {
    var i;

    for (i = 0; i < form.poll.length; i++) {
        if (form.poll[i].checked) return true;
    }

    alert("Please select the item.");
    return false;
}

function imageviewopen(imagename) {
    window.open("/imageview.asp?image=" + imagename, "_imagename", "width=600, height=600, statusbar=no, scrollbars=auto, menubar=no");
}

function checkAll(checkname, exby) {
    for (i = 0; i < checkname.length; i++)
        checkname[i].checked = exby.checked ? true : false
}

function SendFeedback(url){
	var feedbackscore = 0;
	var feedbackform = document.viewform;

	if (feedbackform != null && feedbackform.feedback != null)
	{
		for(i=0; i<feedbackform.feedback.length; i++){
			if(feedbackform.feedback[i].checked){
				feedbackscore = feedbackform.feedback[i].value;
				break;
			}
		}

		if (feedbackscore == 0)
		{
			alert("Please choose one of the above.");
		}else{
			document.location.href = url;
		}
	}
}

function SendFeedback(feedbackform, userial, game, qnaserialno){
	var feedbackscore = 0;

	if (feedbackform != null && feedbackform.feedback != null)
	{
		for(i=0; i<feedbackform.feedback.length; i++){
			if(feedbackform.feedback[i].checked){
				feedbackscore = feedbackform.feedback[i].value;
				break;
			}
		}

		if (feedbackscore == 0)
		{
			alert("Please choose one of the above.");
		}else{
			document.location.href = "http://www.gamescampus.com/qna/feedback_exec.asp?userial="+userial+"&game="+game+"&qnaserialno="+qnaserialno+"&feedbackscore="+feedbackscore+"&returnUrl=http://"+game+".gamescampus.com/support/dqna/list.asp";
		}
	}
}

function cohref(str) {
    switch (str) {
        // FIRST TIER
        case "news":
            location.href = "/news/news/list.asp";
            break;
        case "guide":
            location.href = "/guide/community.asp?t=messenger";
            break;
        case "ranking":
            //alert('coming soon');
            location.href = "/ranking/list.asp";
            break;
        case "community":
            location.href = "http://forum.gamescampus.com/index.php?game=cueonline";
            break;
        case "download":
            location.href = "/download/client.asp";
            break;
        case "support":
            location.href = "/support/faq/list.asp?category=A";
            break;
       
        // SUB TIER NEWS
        case "notice":
            location.href = "/news/news/list.asp";
            break;
        case "events":
            location.href = "/news/events/list.asp";
            break;

        // SUB TIER GUIDE 
        case "g_community":
            location.href = "/guide/community.asp?t=messenger";
            break;
        case "g_control":
            location.href = "/guide/control.asp";
            break;
        case "g_handicap":
            location.href = "/guide/handicap.asp?t=handicap";
            break;
        case "g_ui":
            location.href = "/guide/uiguide.asp?t=lobby";
            break;
        case "g_point":
            location.href = "/guide/point.asp?t=point";
            break;

        // SUB TIER COMMUNITY 
        case "forum":
            location.href = "http://forum.gamescampus.com/index.php?game=cueonline";
            break;
        case "s_book":
            location.href = "/community/strategy/list.asp";
            break;
        case "g_board":
            location.href = "/community/gallery/list.asp";
            break;
        case "f_site":
            location.href = "/community/fansite/list.asp";
            break;
        case "poll":
            location.href = "/community/poll/list.asp";
            break;
		case "twitter":
			location.href = "/community/twitter/twitterform.asp";
			break;
            
        // SUB TIER DOWNLOAD 
        case "c_down":
            location.href = "/download/client.asp";
            break;
        case "screen":
            location.href = "/download/wallpaper.asp";
            break;
        case "movie":
            location.href = "/download/movieclip.asp";
            break;
            
        // SUB TIER SUPPORT 
        case "faq":
            location.href = "/support/faq/list.asp?category=A";
            break;
        case "dqa":
            location.href = "/support/dqna/list.asp";
            break;
  
    }
}