// Get Single Sign On User Details
var uniqueNo=Date.parse(new Date())+Math.floor(Math.random()*1000);
var ob_user_name=new String;
var httpProtocol=(window.location.protocol.toLowerCase()=='https:')?'https:':'http:';
document.write('<scri'+'pt type="text/javascript" src="http://www.it4u.cn/user/SingleSignOn?action=name&unique='+uniqueNo+'"></scr'+'ipt>');

// Outbound link tracking
var trackURL=window.location.protocol+'//www.it4u.cn/user/SingleSignOn?action=redirect&url=';
function trackStatus(){ window.status=this.href.substr(trackURL.length); return true; }
function clearStatus(){ window.status=""; return true; }
function trackLocation(){ window.location=trackURL+this.href; return false; }
function goTo(linkURL) { window.location=trackURL+linkURL; }
function attachLinkTrack(){
  /* DEBUG NOTE: set trackDebug=true to see which links are being tracked */
  var trackDebug=false, trackDebugCss="border:1px dashed red; background-color:yellow;", domainsSrc=new String;
  var an=document.links, re=new RegExp('\\.','g'), notrack=new Boolean;
  /* Enter any domains to exclude from outbound link tracking in the domains array below.
   * The domains array should contain Sting objects similar to 'domain.name.com'.
   * NOTE: Subdomains DO NOT need to be entered explicitly! */
  var domains=['ourbrisbane.com'
              ,'yourtv.com.au'
              ,'yourmovies.com.au'
              ,'seek.com.au'
              ,'ourcommunity.com.au'
              ,'volunteeringqueensland.org.au'];
  /* Convert domains array elements to RegExp objects capable of matching the domain AND 
   * ANY subdomains INCLUDING the 'www.' subdomain 
   * DEBUG NOTE: set trackDebug=true to see source of domains RegExps at bottom of page */
  for(var j=0;j<domains.length;j++){ domains[j]=new RegExp("^https?:\\/\\/(\\w+\\.)*"+domains[j].replace(re,"\\.")+"(\\/)?",'i'); if(trackDebug) domainsSrc+=domains[j].source+"\n"; }
  if(trackDebug) document.write("<BR /><BR /><STRONG>No-Track Domains - RegExp Source</STRONG><BR /><BIG><PRE>"+domainsSrc+"</PRE></BIG><BR /><BR />");
  for(var i=0;i<an.length;i++){
    if(an[i].href && an[i].href.substr(0,4)=='http'){ // if anchor has an href starting with 'http'
      notrack=false;
      for(var j=0;j<domains.length;j++) if(domains[j].test(an[i].href)){ notrack=true; break; } // check for matches against domains array
      if(!notrack){ // if link is not to a domain listed in domains array,'track it baby'
        if(trackDebug) an[i].style.cssText=trackDebugCss;
		if(!an[i].onclick) an[i].onclick=trackLocation;
        else{ an[i].onmouseover=trackStatus; an[i].onmouseout=clearStatus; an[i].href=trackURL+an[i].href; }
      }
    }
  }
}

//************
//  helpers (generic implementations) - REVIEW
//************
//returns an object correctly referenced for Netscape4, IE4 & W3C compliant browsers
function getElement(object, path) {  //path only needed by netscape4
  if (document.getElementById) object = document.getElementById(object); //W3C Compliant (IE5+/NS6+)
  else if (document.all) object = document.all[object]; //IE4
  else if (document.layers) { //Netscape 4
    if (!path) path='document';
    object = eval(path+'.'+object);
  }
  return object;
}

//positions layer (div) in relation to a marker graphic of same name+"Marker"
function positionToMarker(divId, offsetTop, offsetLeft) {
  marker=getElement(divId+'Marker','document.images');
  if (marker==null || marker+''=='undefined') return;  //exit if no marker;
  target=getElement(divId,'document.layers');
  if (document.layers) {  //NS4
    target.visibility='visible';
    target.top=marker.y+offsetTop;
    target.left=marker.x+offsetLeft;
  }
  else {  //W3C (test for IE4)
    while (marker.offsetParent) {  //add all parent offsets together to give total offset
      offsetTop+=marker.offsetTop;
      offsetLeft+=marker.offsetLeft;
      marker=marker.offsetParent;
    }
    target.style.visibility='visible';
    target.style.top=offsetTop;
    target.style.left=offsetLeft;
  }
}

//*************
//  Header
//*************
//checks form field - used in Header Search form
function IsString(sVal,sMsg){ if(sVal==""){ alert(sMsg); return false; } return true; }

//***************
// window Pop-ups
//***************
function screenOffset(axis,pixels){
  var percentOffset=(10/100); // %offset from axis
  var axisDimension=new Number;
  if(axis=='x')axisDimension=screen.availWidth;
  if(axis=='y')axisDimension=screen.availHeight;
  return Math.ceil((axisDimension-pixels)*percentOffset);
}

function popWin(URL,winWidth,winHeight,winType,strWinName){
  var winOpts=new String,oNewWin=new Object,oDate=new Date;
  var xPos=new Number,yPos=new Number;
  (!winWidth)?winWidth=680:winWidth-=0;
  (!winHeight)?winHeight=520:winHeight-=0;
  switch(winType){
    case "console":
      winOpts="resizable";
      if(!strWinName)strWinName='newConsoleWin';
      break;
    case "fixed":
      winOpts="status";
      if(!strWinName)strWinName='newFixedWin';
      break;
    case "noFeatures":
      winOpts="scrollbars";
      if(!strWinName)strWinName="noFeatures";
      break;
    case "elastic":
      winOpts="menubar,scrollbars,resizable,status";
      if(!strWinName)strWinName='newElasticWin';
      break;
    default:
      winOpts="toolbar,menubar,scrollbars,resizable,location,status,directories"
      if(!strWinName)strWinName='it4u.cn';
      break;
  }
  if(window.screenX){
    xPos=screenOffset('x',window.screenX)+window.screenX;
    yPos=screenOffset('y',window.screenY)+window.screenY;
  }else if(window.screenLeft){
    xPos=screenOffset('x',window.screenLeft)+window.screenLeft;
    yPos=screenOffset('y',window.screenTop)+window.screenTop;
  }
  if(screen.availWidth<(xPos+winWidth))xPos=screen.availWidth-winWidth;
  if(screen.availHeight<(yPos+winHeight))yPos=screen.availHeight-winHeight;
  winOpts+=",x="+xPos+",left="+xPos+",y="+yPos+",top="+yPos+",height="+winHeight+",width="+winWidth;
  oNewWin=window.open(URL,strWinName,winOpts);
  oNewWin.focus();
  return false;
}

/* DEPRECATED FUNCTIONS - delete when all references are removed
 * used on some pages - find and remove */
function popUp(URL, height, width, name, properties) { if (!name)name=false; return popWin(URL,width-0,height-0,'',name); }
function popGuestbook(URL) { 
	window.open (URL,"ΏΝ»§ΑτΡΤ", "height=800, width=800, toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no") ;
 }
function MM_openBrWindow(URL, name, properties){ return popWin(URL,0,0,'',name); }
function OB_openBrWindow(URL, name, properties){ return popWin(URL,0,0,'',name); }

//***************
//  MM Functions
//***************
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_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_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function itsearch(searchText){
	//
}
function openLogin(url,width,height){
	window.open(url,'IT4U WEB800','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height+'');
}

