/* +----------------------- | Check Browser +----------------------- */ var clientBrowserName = ""; var clientBrowserVer = ""; // BROWSER? if (navigator.appName.indexOf('Microsoft') != -1) clientBrowserName = 'IE' else if (navigator.appName.indexOf('Netscape') != -1) clientBrowserName = 'NS' else clientBrowserName = 'IE'; if (clientBrowserVer == ''){ clientBrowserVer= navigator.appVersion; paren = clientBrowserVer.indexOf('('); whole_version = navigator.appVersion.substring(0,paren-1); clientBrowserVer = parseInt(whole_version); } function start () { var w = Math.max(screen.width * 0.6,750); document.getElementById('layoutHeader').style.width = w; document.getElementById('layoutMain').style.width = w; document.getElementById('layoutContent').style.width = w; document.getElementById('layoutMenu').style.width = 100; document.getElementById('layoutBody').style.width = w - 150; document.getElementById('layoutOther').style.width = 50; document.getElementById('layoutAll').style.visibility = "visible"; //alert (getCookie("userid")); /* +----------------------- | Display Error +----------------------- */ errorInPage(); if (typeof main == "function") { main(); } } /* +----------------------- | Javascript General +----------------------- */ function jsSelectValue(tmpId) { tmpItem = document.getElementById(tmpId); return tmpItem.options[tmpItem.selectedIndex].value; } /* +----------------------- | Popup Functions +----------------------- */ function showpopup (tmpstyle,tmpmsg) { popupaddmsg (tmpstyle, tmpmsg); popupchangestyle (tmpstyle); popup(); } function popupaddmsg (tmpstyle, tmpmsg) { var tmpHTML =""; var container = document.getElementById('dialog'); switch (tmpstyle) { case "validateform": for (var i=0; i" + tmpmsg[i] + ""; } tmpHTML = tmpHTML + "There are errors in the form. Would you like to Correct them or to Save anyway?
"; break; case "critical": tmpHTML = "

"+tmpmsg+"

" /*for (var i=0; i 0) { showpopup ("validateform",error); return false; } else { if (typeof document.form.completed != "undefined"){ document.form.completed.value=1; } return true; } } function checkboxCheck() { for (i=0; i 0) { showError (arj.name, error); return; } else { clearError (arj.name, error); return; } } /* +----------------------- | Highlight the error +----------------------- */ function showError (tmpName, tmpError) { document.getElementById(tmpName).style.backgroundColor = "pink"; //errorInPage(tmpError); return; } function clearError (tmpName, tmpError) { document.getElementById(tmpName).style.backgroundColor = "white"; return; } function errorInPage (errFrJava) { if (document.getElementById('error').innerHTML=="") { return } var errFrPage = document.getElementById('error').innerHTML.split("|"); if (typeof errFrJava != "undefined") { var errors = errFrPage.concat(errFrJava); } else { var errors = errFrPage; } if (errors.length > 0) { for (i=0; i < errors.length; i++) { errors[i] = "--> " + errors[i] + "
"; } document.getElementById('errordisp').innerHTML = errors.join(""); document.getElementById('errordisp').style.display = "block"; } } /* function errorformdisplay (tmperror) { popupchangestyle ("validateform"); var tmpHTML =""; var container = document.getElementById('dialog'); for (var i=0; i" + tmperror[i] + ""; } mpHTML = tmpHTML + ""; container.innerHTML =tmpHTML; return; }*/ /* +----------------------- | DIV Open +----------------------- */ function divOpen (tmpDiv) { new Effect.SlideDown(tmpDiv); return; } function divClose (tmpDiv) { new Effect.SlideUp(tmpDiv); return; } /* +----------------------- | Flash Communication +----------------------- */ function SendDataToFlashMovie(tmpThis,tmpMc) { var flashMovie=window.document[tmpMc]; flashMovie.SetVariable("/:dataMsg", tmpThis.value); } /* +----------------------- | Prototype +----------------------- */ function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); } function ucwords (tmpString) { return tmpString.toLowerCase().replace(/\w+/g,function(s){ return s.charAt(0).toUpperCase() + s.substr(1); }); } /* +----------------------- | TIME +----------------------- */ function secToTime(tmpSec) { tmpD = Math.floor(tmpSec/24/60/60); tmpLeft = tmpSec % (24*60*60); tmpH = Math.floor(tmpLeft / 60/60); tmpLeft = tmpLeft % (60*60); tmpM = Math.floor(tmpLeft / 60); tmpS = tmpLeft % 60; return tmpD + "D " + tmpH + ":" + tmpM + ":" + tmpS; } /* +----------------------- | TIME +----------------------- */ function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } /* +----------------------- | | MENU | +----------------------- */ function watchDel(tmpId) { ajax_watch = new sack(); ajax_watch.method = "POST"; ajax_watch.setVar("listingid",tmpId); ajax_watch.setVar("userid",getCookie("userid")); ajax_watch.requestFile = 'ajaxwatchdel.php'; ajax_watch.onCompletion = function(){addWatchDelDone(tmpId);}; ajax_watch.runAJAX(); } function addWatchDelDone(tmpId) { var container = document.getElementById('watchItem'+tmpId); if (ajax_watch.response =="1") { container.innerHTML = ""; if (typeof document.getElementById('cWatch') == "object") { if (document.getElementById('listingsid').value == tmpId) { document.getElementById('cWatch').innerHTML = "Watch"; } } //print "Watch"; } else { alert ("Cannot delete at present, pls try later."); //container.innerHTML = "Error in adding to watch list!"; } } function menuStart() { tmpWLs= document.getElementById('cWatchList').getElementsByTagName('img'); var tmpItems = new Array; for (i=0; i 0) { ajax_wlUpdate = new sack(); ajax_wlUpdate.method = "POST"; ajax_wlUpdate.setVar("items",tmpItems.join(",")); ajax_wlUpdate.requestFile = 'ajaxwatchupdate.php'; ajax_wlUpdate.onCompletion = function(){addwlUDDone(tmpItems.join(","));}; ajax_wlUpdate.runAJAX(); } } function addwlUDDone(tmpWL) { var tmpItemsPairs = ajax_wlUpdate.response.split("&"); for (i=0;i