// The Dev Center JavaScript Functions

<!-- //reloads the window if Nav4 resized
function MM_reloadPage(init) {  
  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 to bust frames
<!--
if (window!= top)
top.location.href=location.href
// -->

// Begin function for antispam email address
<!-- Begin
var user;
var domain;
var suffix;

function antispam_email_address(user, domain, suffix){

document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}
//  End -->


// killErrors
function tmtC_stopErrors() {
return true;}
window.onerror = tmtC_stopErrors;
//killErrorsEnd


// Clock Script 
function tS(){ x=new Date(); x.setTime(x.getTime()); return x; } 
function lZ(x){ return (x>9)?x:'0'+x; } 
function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } 
function y2(x){ x=(x<500)?x+1900:x; return String(x).substring(2,4) } 
function dT(){ if(fr==0){ fr=1; document.write('<span id="tP">'+eval(oT)+'</span>'); } tP.innerText=eval(oT); setTimeout('dT()',1000); } 
function aP(x){ return (x>11)?'pm':'am'; } 
var dN=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'),mN=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'),fr=0,oT="dN[tS().getDay()]+' '+tS().getDate()+' '+mN[tS().getMonth()]+' '+y2(tS().getYear())+' '+''+' '+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";

// Functions for admin help menu
function toggleBox(szDivID) {
  if (document.layers) { // NN4+
    if (document.layers[szDivID].visibility == 'visible') {
      document.layers[szDivID].visibility = "hide";
      document.layers[szDivID].display = "none";
      document.layers[szDivID+"SD"].fontWeight = "normal";
    } else {
      document.layers[szDivID].visibility = "show";
      document.layers[szDivID].display = "inline";
      document.layers[szDivID+"SD"].fontWeight = "bold";
    }
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
    var obj = document.getElementById(szDivID);
    var objSD = document.getElementById(szDivID+"SD");

    if (obj.style.visibility == 'visible') {
      obj.style.visibility = "hidden";
      obj.style.display = "none";
      objSD.style.fontWeight = "normal";
    } else {
      obj.style.visibility = "visible";
      obj.style.display = "inline";
      objSD.style.fontWeight = "bold";
    }
  } else if (document.all) { // IE 4
    if (document.all[szDivID].style.visibility == 'visible') {
      document.all[szDivID].style.visibility = "hidden";
      document.all[szDivID].style.display = "none";
      document.all[szDivID+"SD"].style.fontWeight = "normal";
    } else {
      document.all[szDivID].style.visibility = "visible";
      document.all[szDivID].style.display = "inline";
      document.all[szDivID+"SD"].style.fontWeight = "bold";
    }
  }
}

// Function to expand textarea
function expandDesc(direction) {
  var txtarea = document.getElementById('txtDescripion');
  if (direction==1) {
    txtarea.cols = txtarea.cols + 1;
    txtarea.rows = txtarea.rows + 3;
  } else {
    txtarea.cols = txtarea.cols - 1;
    txtarea.rows = txtarea.rows - 3;
  }
  document.getElementById("textarea_next_time").value=txtarea.cols+","+txtarea.rows;
}

// Function to show / hide content of a div
function changeContent(id,shtml) {
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(id): document.all[id];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
   }
}

// Function to open a pop up window
function neowin(wurl,wwid,wheigh,wscroll) {
var address = wurl;
var op_tool = 0;
var op_loc_box = 0;
var op_dir = 0;
var op_stat = 0;
var op_menu = 0;
var op_scroll = wscroll;
var op_resize = 1;
var op_wid = wwid;
var op_heigh = wheigh;
var xMax = screen.width, yMax = screen.height;
var xOffset = (xMax - wwid)/2, yOffset = (yMax - wheigh)/2;
var option = "toolbar="+ op_tool +",location="+ op_loc_box +",directories=" + op_dir +",status="+ op_stat +",menubar="+ op_menu +",scrollbars=" + op_scroll +",resizable=" + op_resize +",width=" + op_wid +",height="+ op_heigh +",screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset ;
var neo = window.open(address, "PopUp", option);
if(neo.focus){neo.focus();}
}

function getElementsByClassName(clss, prnt, tg) {
    var elements = new Array();
    tg = tg || '*';
    prnt = prnt || document;
    var list = prnt.getElementsByTagName(tg);
    for (var i = 0; i < list.length; ++i) {
        if (list[i].className == clss) {
            elements.push(list[i]);
        }
    }
	return elements;
}

// Tab Functions
function hasParent(e, id) {
	if (!e.parentNode) {
	    return false;
	}
	if (e.parentNode.id == id) {
	    return e.parentNode;
	}
	
	return hasParent(e.parentNode, id);
}

// Tab Functions
function showCBox(e) {  // show divs and active tab for each id (tab and div)
  var eNews = hasParent(e, 'rssFeeds');
  
  if (eNews) {
    eNews.className = e.id;
  }
}

// Used to select all txt from textarea
<!--
function selectAll(theField) {
	var tempval=eval("document."+theField)
	tempval.focus()
	tempval.select()
	}
//-->

// Protection before launching static links
function check_compile()
{
	if (confirm("This Might Take Few Minutes!")) 
	{}
	else
	{
		return false
	}
}

function mosDHTML(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	this.onTabStyle = 'ontab';
	this.offTabStyle = 'offtab';

	this.setElemStyle = function(elem,style) {
		document.getElementById(elem).className = style;
	}
	this.showElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( 'tab', 'page' );
			this.hideElem(page);
		}
		this.setElemStyle( name, this.onTabStyle );
		this.activeTab = name;
		page = this.activeTab.replace( 'tab', 'page' );
		this.showElem(page);
	}
	return this;
}
var dhtml = new mosDHTML();


// Switch Styles
function setActiveStyleSheet(title) {
  var i, a, main;
  for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if (a.getAttribute("rel") &&
        a.getAttribute("rel").indexOf("style") != -1 &&
        a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
function getActiveStyleSheet() {
  var i, a;
  for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if (a.getAttribute("rel") &&
        a.getAttribute("rel").indexOf("style") != -1 &&
        a.getAttribute("title") &&
        !a.disabled
        ) return a.getAttribute("title");
  }
  return null;
}
function getPreferredStyleSheet() {
  var i, a;
  for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if (a.getAttribute("rel") &&
        a.getAttribute("rel").indexOf("style") != -1 &&
        a.getAttribute("rel").indexOf("alt") == -1 &&
        a.getAttribute("title")
        ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


// Handle login validation
function LoginValidate()
   {    
         var Uname = document.getElementById('Name').value;
         var Upass = document.getElementById('Password').value;
		 var ErrMsg = document.getElementById('lblError').value;
        if (Uname =="" && Upass =="")
           {
             document.getElementById('lblError').style.display='block';
			 document.getElementById('lblError').innerHTML = 'UserName / Password is Required!';
			 document.getElementById('lblError').style.color = '#FF0000';
			 document.getElementById('Name').style.border = '1px solid #FF0000';
             document.getElementById('Password').style.border = '1px solid #FF0000';
             return false;
           }
        if (Uname =="")
            {
              document.getElementById('Name').style.border = '1px solid #FF0000';
			  document.getElementById('lblError').innerHTML = 'Username is Required!';
			  document.getElementById('lblError').style.color = '#FF0000';
              return false;
            }
        if (Upass =="")
            {
              document.getElementById('Password').style.border = '1px solid #FF0000';
			  document.getElementById('lblError').innerHTML = 'Password is Required!';
			  document.getElementById('lblError').style.color = '#FF0000';
              return false;
            }
              return true;        
 }
 
<!--//
function OpenPreview()
{
	var curCookie = "strSignaturePreview=" + escape(document.frmRegister.Sig.value);
	document.cookie = curCookie;
	popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=yes,width=450,height=250')	
}
//-->