/*               Global variables
*          
*/ 
var formsubmitted=false;        // to prevent double request
var datasciAddress = "";				// http://www.datasci.net
var csideAddress 	 = "http://www.c-side.ca";

///

//this function change the background color of the menu item when you put your mouse on
function changeColor( id ,color){ 
 if(getCookie('ItemNumber')==id)
  return;
 var el= document.getElementById( id); 
 el.style.backgroundColor=color; 
}
function changeFontColor( id ,color){ 
 if(getCookie('ItemNumber')==id)
  return;
 var el= document.getElementById( id); 
 el.style.color=color; 
}
//
//////////////////////////////////////////////////////////
// This part is for the scrooling ticker line
////////////////////////////////////////////
// Begin
var l1 = 245; // left of ticker in pixel, or 0 to position relative
var t1 = 103; // top of ticker in pixel, or 0 to position relative
var w1 = 555; // width of ticker in pixel
var ie = document.all ? true : false;
var first = true;
var l2 = l1 + w1;
var l3 = l1 - l2;
var l = l2;

function tickinit() {
if ( !ie ) return;
if (ie) {
if (l1 == 0 && t1 == 0) {
pos = document.all['tickpos'];
l1 = getLeft(pos);
t1 = getTop(pos);
}
ticktext.style.posTop = t1;
}
else {
if (l1 == 0 && t1 == 0) {
pos = document.anchors['tickpos'];
l1 = pos.x;
t1 = pos.y;
}
document.ticktext.pageY = t1;
}
l2 = l1 + w1;
l3 = l1 - l2;
l = l2;
setInterval('tick()', 10);
}
function getLeft(ll) {
if (ll.offsetParent)
return (ll.offsetLeft + getLeft(ll.offsetParent));
else 
return (ll.offsetLeft);
}
function getTop(ll) {
if (ll.offsetParent)
return (ll.offsetTop + getTop(ll.offsetParent));
else
return (ll.offsetTop);
}
function tick() {
l = l - 0.5;
if (l < -4800 ) l = l2;     //to start over

cl = l1 - l;
cr = l2 - l;
if (ie) {
ticktext.style.posLeft = l;
ticktext.style.posTop = t1;
ticktext.style.clip = "rect(0px, "+cr+"px, 14px, "+cl+"px)";
if (first) ticktext.style.visibility = "visible";
}
else {
document.ticktext.pageX = l;
document.ticktext.clip.left = cl;
document.ticktext.clip.right = cr;
if (first) document.ticktext.visibility = "show";
}
first = false;
}
////////////////////////////////////////////
//  End -->


// this part is to manipulate the cookies 
//////////////////////////////
function getExpDate(days, hours, minutes) {
    var expDate = new Date( );
    if (typeof days == "number" && typeof hours == "number" && 
        typeof hours == "number") {
        expDate.setDate(expDate.getDate( ) + parseInt(days));
        expDate.setHours(expDate.getHours( ) + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
        return expDate.toGMTString( );
    }
}

// global variable for the cookies
var expDate = getExpDate(180, 0, 0);

// utility function called by getCookie( )
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}
  
// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return "";
}
   
// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
   
// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
//////////////////////////////
// this is the end of manipulating cookies
// this Function pops up the enlarged graph
function popUpPage(vurl,width,height) {
var url = vurl; //'common/popup.jsp';
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars= auto ,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+",left= 0,top = 0');");
}

function popUp86(vurl){
	popUpPage(vurl,800,600);
}

function popUp(vurl) {
var url = vurl; //'common/popup.jsp';
var width = window.screen.width;
var height = window.screen.height;
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars= auto ,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+",left= 0,top = 0');");
}
function popupFull(vurl) {
var url = vurl; //'common/popup.jsp';
var width = window.screen.width;
var height = window.screen.height;
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1 ,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+",left= 0,top = 0');");
}
function popUpHtml(vurl) {
var url = vurl; //'common/popup.jsp';
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=350,left= 212,top = 234');");
}
function popUpHtmlACH(vurl) {
var url = vurl; //'common/popup.jsp';
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400,left= 212,top = 234');");
}

/*
* Create a modal popup
*/
function popUpModalHtml(vurl) {
var url = vurl; //'common/popup.jsp';
day = new Date();
id = day.getTime();
 if ( navigator.appName == "Microsoft Internet Explorer")
  eval("page" + id + " = window.showModalDialog(url, '" +id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400,left= 212,top = 234');");
 else 
  eval("page" + id + " = window.open(url, '" +id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400,left= 212,top = 234');");

}


//////////////////////////////////////////
// this function submit the forms to the server
////////////////////////////////////////
 function formsubmit( comm , FormPosition){

 if (formsubmitted) 
   return true;
 else
   formsubmitted=true;

 if ( FormPosition =='left' ){
      document.leftForm.command.value=global_number+','+comm;
      document.leftForm.submit();
 }else if (FormPosition =='right'){
    document.rightForm.command.value=global_number+','+comm;
    document.rightForm.submit();
 }else if (FormPosition == 'middle'){
    document.middleForm.command.value=global_number+','+comm;
    document.middleForm.submit();
 }else if (FormPosition == 'top'){
    document.topForm.command.value=global_number+','+comm;
    document.topForm.submit();
 }else if (FormPosition == 'UploadForm'){
   if ( document.UploadForm.filename.value==''){
      formsubmitted=false;
      window.alert('Please select a file');
     }else{  
    document.UploadForm.command.value=comm;
    document.UploadForm.submit();
    } 
 }
}// formsubmit() function
///////////////////////////////////////

/**************
 * check if the Enter key is pressed
 **************/
function isEnterKey(e, fm){
	var keyCode = e.keyCode;
	if(keyCode == 13) {// 13 == ASCII for enter key	
		fm.submit ();
	}
}

/**************
 * check if Enter is pressed to trigger the button onclick event
 **************/
function isEnterKeyInForm(e, submitID){
	var keyCode = e.keyCode;
	if(keyCode == 13) {// 13 == ASCII for enter key	
        var btn = document.getElementById (submitID);
		btn.click ();
	}
}

/**************
 * check the input to accept only the digital number
 **************/
function digitsCheck(event){
	if((event.keyCode>=48 && event.keyCode<=57) || event.keyCode==45){
	}else{
		alert("Enter Numbers Only");
		event.keyCode=0;
	}
}

 /////////////  VALIDATION FUNCTION FOR NUMBERS should be invoked by an onkeypress
function numberOnly(evt) {
    evt = (evt) ? evt : ((window.event) ? event : null);
    if (evt) {
       var elem = (evt.target) ? evt.target : 
          ((evt.srcElement) ? evt.srcElement : null);
       if (elem) {
           var charCode = (evt.charCode) ? evt.charCode : 
               ((evt.which) ? evt.which : evt.keyCode);
           if ((charCode < 32 ) || 
               (charCode > 44 && charCode < 47) || 
               (charCode > 47 && charCode < 58)) {
               return true;
           } else {
               return false;
           }
       }
    }
}
///////////////////////////////////////////////////////////////////////////
// to adjust the frame to be the same height as the page
function adjustIFrameSize(id) {
    var myIframe = document.getElementById(id);
    if (myIframe) {
        if (myIframe.contentDocument && myIframe.contentDocument.body.offsetHeight) {
            // W3C DOM (and Mozilla) syntax
            myIframe.height = myIframe.contentDocument.body.offsetHeight+100;    
            myIframe.width = myIframe.contentDocument.body.offsetWidth;            
        } else if (myIframe.Document && myIframe.Document.body.scrollHeight) {
            // IE DOM syntax
            myIframe.height = myIframe.Document.body.scrollHeight+100;
            myIframe.width = myIframe.Document.body.scrollWidth;
        }
    }
}

// Checking email address 
function checkEmail(id) {
	var el= document.getElementById( id);
	if ( el == null)
	return (false);

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(el.value)){
		return (true)
	}
	alert("Invalid E-mail Address! Please re-enter.")
	el.value='';
	return (false)
}

// get frame doc  
// it is not used yet.
//  
function getFrameDoc(frameElem) {
    var doc = (frameElem.contentDocument) ? frameElem.contentDocument : 
        ((frameElem.contentWindow) ? frameElem.contentWindow.document : null);
    return doc;
}




/*
   this part is to get the states within a country 
*/
//global variables for AJAX request 
var AJAXRequest ;
var global_stateid ;
/*
   name : changeStates
   date : April 2006
   Note : this method is called when the country changes in select tag.

*/
function changeStates ( countryid , stateid ){
 // set the global variable  
 global_stateid = stateid;
 
 var cid = document.getElementById ( countryid );
 var sid = document.getElementById (stateid );
 var url = "public/stateDataProvider.jsp?COUNTRY="+
                      cid.options[cid.selectedIndex].value;
 if (window.XMLHttpRequest) {
       AJAXRequest = new XMLHttpRequest();
 } else if (window.ActiveXObject) {
       AJAXRequest = new ActiveXObject("Microsoft.XMLHTTP");
 }
 AJAXRequest.open("GET", url, true);
 AJAXRequest.onreadystatechange = ChangeSelectData;
 AJAXRequest.send(null);
 sid.options.length = 0;
}//()  

/*
   name : ChangeSelectData
   date : April 2006
   Note : this method is called when the response comes back from server.
*/
function ChangeSelectData (  ){
 var sid = document.getElementById (global_stateid );
 
 if (AJAXRequest.readyState == 4) {
        if (AJAXRequest.status == 200) {
            // update the HTML DOM based on whether or not message is valid
        var SymbolCount=0;
        while (true){
         var el = AJAXRequest.responseXML.getElementsByTagName("state")[SymbolCount]; 
         if ( el == null )
          return;
         var optObj = el.getElementsByTagName("name")[0];
         var optValue = optObj.childNodes[0].nodeValue;
         var valueObj = el.getElementsByTagName("value")[0];
         var valueValue = valueObj.childNodes[0].nodeValue;
         sid.options[SymbolCount] = 
                    new Option(optValue, valueValue, false, false);
         ++SymbolCount;        
        }
        return;
    }
 }
}//()
// end of AJAX for states 


/*
   name : textCounter
   created by : DANA
   date : June 2006
   Note : this method is called to limit the size of textarea.

*/

function textCounter(field,  maxlimit)
{
  if (field.value.length > maxlimit) // if too long...trim it!
  field.value = field.value.substring(0, maxlimit); 
  
} // End


/*
	author: Walter Lin
	Date: Jan 21, 2008
	Rem: include file at runtime on client side to 
	@parameter id					id of elemenet in HTML page
	@parameter fileURL		url of file whose data will be read into the element
*/
function loadFile (id, fileURL){
	// get the element in HTML page
	var ele = document.getElementById (id);
	if (!ele){
		alert ("no id found to fill data!");
		return;
	}
	populateData (ele, fileURL);
}

// stream data of file "fileURL" into HTML element "ele"
function populateData (ele, fileURL){
	var req = false;
	if (window.XMLHttpRequest){
		try{
			req = new XMLHttpRequest ();
		}catch(E){
			req = false;
		}
	}else if (window.ActiveXObject){
		try{
			req = new ActiveXObject ("Msxml2.XMLHTTP");
		}catch(E){
			try{
				req = new ActiveXObject ("Microsoft.XMLHTTP");
			}catch(E){
				req = false;
			}
		}
	}// end of if
	
	// open the page whose content will be populated in the element
	if (req){
		try{
			req.open('GET', fileURL, false);
		}catch(E){
			alert ("error reading file!");
		}
		req.send (null);
		ele.innerHTML = req.responseText;
	}else{
		ele.innerHTML = "Your browser doesn't support loading file."
	}
}

/**************
 * jump to home page
 **************/
function goHome(){
	window.location = "/";
}

/**************
 * jump to C-side.ca website
 **************/
function goCside(){
	window.open (csideAddress);
}

/*
 * play the demo of products
 * @parameter URL		page url based on %root%/DOCS/demo/
 */
function playDemo (URL){
	window.open('DOCS/demo/' + URL, 'productDemo', 'toolbar=0,scrollbars= auto ,location=0,statusbar=0,menubar=0,resizable=1,left= 0,top = 0');
}

/**************
 * open the document file under "DOCS/down" directory
 **************/
function openFile(File){
	window.open('DOCS/down/' + File);
}

/*
	visit specific page with urls for left navigation and content page.
	for example, 
	visitSpecificPage ("DOCS/hr/hr_menu", "hr/hr_index")
	RETURNS "mainFrame.php?navi=DOCS/hr/hr_menu;page=hr/hr_index"
	FINALLY show mainFrame.php with 
	left navigation to "DOCS/hr/hr_menu.html"
	and content to "DOCS/hr/hr_index.html"

	@parameter navi		navigation name e.g. "hr", "invest", "portal", "public"
	@parameter page		content page url based on %root%/DOCS
 */
function visitSpecificPage (navi, page){
	visitSpecPageWithSidebar (navi, page, "");
}

function visitClientPortal (){
	currentURL = "https://" + document.location.hostname + "/client.php";
	window.location.href  = currentURL;
}

function visitEmployeeLoginPage (){
	currentURL = "https://" + document.location.hostname;
	window.location.href  = currentURL;
	/*
	alert(document.location);
	alert(document.URL);
	alert(document.referrer);
	alert(document.location.protocol);
	alert(document.location.hostname);
	alert(document.location.host);
	alert(document.location.pathname);
	alert(document.location.port);
	alert(document.location.target);
	alert(document.location.hash);
	alert(document.location.href);
	*/
}

/*
	visit specific page with urls for left navigation and content page.
	for example, 
	visitSpecificPage ("DOCS/hr/hr_menu", "hr/hr_index")
	RETURNS "mainFrame.php?navi=DOCS/hr/hr_menu;page=hr/hr_index"
	FINALLY show mainFrame.php with 
	left navigation to "DOCS/hr/hr_menu.html"
	and content to "DOCS/hr/hr_index.html"

	@parameter navi		navigation name e.g. "hr", "invest", "portal", "public"
	@parameter page		content page url based on %root%/DOCS
	@parameter sidebar	sidebar file name e.g. "hr_sidebar"
 */
 
function visitSpecPageWithSidebar (navi, page, sidebar){
	currentURL = "/mainFrame.php?navi=" + navi + ";page=" + page + ";sidebar=" + sidebar;
	currentPageName = "Data & Scientific Inc. -- " + page;
	/*
	if (currentContentContainer != null){
		// get navigation content
		if (currentNaviContainer != null){
			if (navi != currentTreeName){		// refresh navigation on the left
				currentNaviContainer.innerHTML = getMenuCodeByTreeName (navi);
			}
		}
		// get sidebar content
		if (currentSidebarContainer != null){
			if (sidebar != ""){
				populateData (currentSidebarContainer, "DOCS/" + sidebar + ".html");
			}else{
				currentSidebarContainer.innerHTML = "";
			}
		}
		
		// deal with content of page
		var pattern = /jsp$/;
		if (pattern.test(page)){			// if it is jsp file
			populateData (currentContentContainer, "app/" + page);
		}else{											// if it is html file
			populateData (currentContentContainer, "DOCS/" + page + ".html");
		}
	}else{
		window.location.href  = currentURL;
	}*/
	window.location.href  = currentURL;
	currentURL = datasciAddress + currentURL;
}

/*
	add page into favorites

	@parameter URL 		address of page
	@parameter name		name of URL to show in favorates
 */
function addBookmark(){
	if (window.external){
		window.external.addFavorite (currentURL, currentPageName);
	}else{
		alert ("Web Browser doesn't support this function");
	}
}

/*
	visit HR proudct page with HR navigation
	@parameter page		name of page url based on %root%/DOCS
*/
function visitHRPage(page){
	visitSpecPageWithSidebar ("product", "hr/" + page, "hr_sidebar");
}

/*
	visit Investment proudct page with Investment navigation
	@parameter page		name of page url based on %root%/DOCS
*/
function visitInvestPage(page){
	visitSpecPageWithSidebar ("product", "invest/" + page, "invest_sidebar");
}

/*
	visit Proudct page with product navigation
	@parameter page		name of page url based on %root%/DOCS
*/
function visitProductPage(page){
	visitSpecificPage ("product", page);
}

/*
	visit Technical Consulting Service page with service navigation and its sidebar
	@parameter page		name of page url based on %root%/DOCS
*/
function visitTechServicePage(page){
	visitSpecPageWithSidebar ("service", page, "techConsulting_sidebar");
}

/*
	visit Service page with service navigation
	@parameter page		name of page url based on %root%/DOCS
*/
function visitServicePage(page){
	visitSpecificPage ("service", page);
}

function visitSubMainPage(page){
	visitSpecificPage ("", page);
}





function visitPublicSectorMainPage(){
	visitSpecificPage ("publicSector", "publicSector");
}

function visitPublicSectorFinancials(){
	visitSpecificPage ("publicSector_Financials", "publicSectorFinancials");
}
function visitPublicSectorTaxation(){
	visitSpecificPage ("publicSector_Taxation", "publicSectorTaxation");
}
function visitPublicSectorHumanCaptial(){
	visitSpecificPage ("publicSector_HumanCaptial", "publicSectorHumanCaptial");
}
function visitPublicSectorNationalDatabank(){
	visitSpecificPage ("publicSector_NationalDatabank", "publicSectorNationalDatabank");
}
function visitPublicSectorDataSecurity(){
	visitSpecificPage ("publicSector_DataSecurity", "publicSectorDataSecurity");
}



function visitPublicSectorFinancialsFunds(){
	visitSpecificPage ("publicSector_FinancialsFunds", "publicSectorFinancialsFunds");
}
function visitPublicSectorBudget(){
	visitSpecificPage ("publicSector_Budget", "publicSectorBudget");
}
function visitPublicSectorTaxpayerRegi(){
	visitSpecificPage ("publicSector_TaxpayerRegi", "publicSectorTaxpayerRegi");
}
function visitPublicSectorRevenueAdmin(){
	visitSpecificPage ("publicSector_RevenueAdmin", "publicSectorRevenueAdmin");
}

function visitPublicSectorHRPlus(){
	visitSpecificPage ("publicSector_HRPlus", "publicSectorHRPlus");
}
function visitPublicSectorHRMgmt(){
	visitSpecificPage ("publicSector_HRMgmt", "publicSectorHRMgmt");
}
function visitPublicSectorWBT(){
	visitSpecificPage ("publicSector_WBT", "publicSectorWBT");
//	visitProductPage ('WBT');
}
function visitPublicSectorLargeDB(){
	visitSpecificPage ("publicSector_LargeDB", "publicSectorLargeDB");
}
function visitPublicSectorDataWarehouse(){
	visitSpecificPage ("publicSector_DataWarehouse", "publicSectorDataWarehouse");
}
function visitPublicSector2FactorAuth(){
	visitSpecificPage ("publicSector_2FactorAuth", "publicSector2FactorAuth");
}
function visitPublicSectorIntrusionDectPrev(){
	visitSpecificPage ("publicSector_IntrusionDectPrev", "publicSectorIntrusionDectPrev");
}


function visitPublicSectorTechConsulting(){
	visitSpecificPage ("publicSector", "publicSectorTechConsulting");
}

function visitPublicSectorCustomSolutions(){
	visitSpecificPage ("publicSector_CustomSolutions", "publicSectorCustomSolutions");
}
function visitPublicSectorFinancialsCustomSolu(){
	visitSpecificPage ("publicSector_FinancialsCustomSolu", "publicSectorFinancialsCustomSolu");
}
function visitPublicSectorTaxpayerCustom(){
	visitSpecificPage ("publicSector_TaxationCustom", "publicSectorTaxationCustom");
}

function visitPublicSectorSecurityPolicyMgmt(){
	visitSpecificPage ("publicSector_SecurityPolicyMgmt", "publicSectorSecurityPolicyMgmt");
}


/******************************
 * Training services
 */
function trainingServices(){
	visitSpecificPage ("training_services", "trainingServices");
}
function viewTrainingSchedule(){
	visitSpecificPage ("training_services_schedule", "trainingSchedule");
}

function viewTrainingEbizBasics(){
	visitSpecificPage ("training_services_EbizBasics", "trainingDetailEbizBasics");
}
function viewTrainingGeneralLedger(){
	visitSpecificPage ("training_services_GeneralLedger", "trainingDetailGeneralLedger");
}
function viewTrainingPayables(){
	visitSpecificPage ("training_services_Payables", "trainingDetailPayables");
}


/*
	visit "about" page with public navigation
	@parameter page		content page url based on %root%/DOCS
*/
function visitAboutPage (page){
	visitSpecificPage ("about", page);
}


/*
	visit Portal proudct page with specific navigation
	@parameter navi		navigation indicator could be "hr", "invest" or "portal"
	@parameter page		name of page url based on %root%/DOCS
	@DISABLED BY WALTER
*/
function visitPortalPageWithNav(navi,page){
	visitSpecificPage ("product", "portal/" + page);
}


// visit index page of "product"
function visitProductPages (){
	visitSpecificPage ("product", "product_index");
}
// visit index page of "service"
function visitServicePages(){
	visitSpecificPage ("service", "service_index");
}
// visit index page of "support"
function visitSupportPages(){
	window.location = "mainFrame.php?navi=public;page=support/login.php;sidebar=";
}

// visit job applying page of "support"
function visitJobApplicationPage(opportunity){
	window.open('app/jobApplication.jsp?opportunity=' + opportunity, 'job application', 
		'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400,left= 212,top = 234');
}

function visitCareerPage(){
    visitSpecificPage ("public", "careers");
}

/**************
 * visit about us pages
 **************/
function visitAboutPages(){
    visitSpecificPage ("about", "aboutus");
}

/**************
 * visite the main frame page
 **************/
function visitMainFramePage(){
    window.location = "mainFrame.php";
}

// register new account
function gotoRegistrationPage(){
    window.location = "mainFrame.php?navi=public;page=support/register.php";
}

// register new account
function forgotPassword(){
    window.location = "mainFrame.php?navi=public;page=support/forgotPassword.php";
}

/*
	open url page in a new windows
	@parameter URL 		page url based on %root%
*/
function openInfoWindows (URL){
	window.open(URL, 'info', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400,left= 212,top = 234');
}

/*****************
 * Menu class used for navigation
 *****************/
Menu.prototype.menuName = "";
Menu.prototype.menuUrl  = "none";
Menu.prototype.nodePage = "";
Menu.prototype.toExpand = true;
Menu.prototype.highlighted= false;
Menu.prototype.subItems;
Menu.prototype.expandMenuByName = function (menuName){
	for (var i = 0; i < this.subItems.length; i ++){
		var m = this.subItems [i];
		if (m instanceof Menu){
			if (m.menuName == menuName){
				m.toExpand = true;
			}else{
				m.toExpand = false;
			}
		}
	}
}
Menu.prototype.collapseMenuByName = function (menuName){
	for (var i = 0; i < this.subItems.length; i ++){
		var m = this.subItems [i];
		if (m instanceof Menu){
			if (m.menuName == menuName){
				m.toExpand = false;
			}
		}
	}
}
// constructors
function Menu (name, URL){
	this.menuName = name;
	this.menuUrl  = URL;
	this.nodePage = getPageName (URL);
	this.subItems = new Array();
}

/*****************
 * MenuItem class used for navigation
 *****************/
MenuItem.prototype.menuitemName = "";
MenuItem.prototype.menuitemUrl  = "";
MenuItem.prototype.highlighted= false;
// constructor
function MenuItem (name, URL){
	this.menuitemName = name;
	this.menuitemUrl  = URL;
}

// send email of telling current page to friends
function mailCurrentPage(){
	var mailContent = "mailto:?subject=Data %26 Scientific Inc. might interest you";
	if (currentURL != ""){
		mailContent += "&body=You can visit page at: " + currentURL;
	}else{
		mailContent += "&body=You can visit page at: " + location.href;
	}
	location.href = mailContent;
}

function getPageName (URL){
	/*
	var pattern = /'"/g;
	RegExp.index
	return "";
	*/
}


/**************
 * following are for browsing images in one presentation page, e.g. events page
 **************/
var indexMin = 1;
var indexMax = 2;
var ind = 1;

/**************
 * show the next picture, if index is greater than the last ordinal, then show the first picture
 **************/
function nextPicture(roomID, fileNameBase, fileExt, low, high){
	ind ++;
	indexMin = low;
	indexMax = high;

	if (ind > indexMax){
		ind = indexMin;
	}
	var room = document.getElementById(roomID);
	room.src = "images/" + fileNameBase + ind + "." + fileExt;
}

/**************
 * show the previous picture, if index is less than the first ordinal, then show the last picture
 **************/
function previousPicture(roomID, fileNameBase, fileExt, low, high){
	ind --;
	indexMin = low;
	indexMax = high;

	if (ind < indexMin){
		ind = indexMax;
	}
	var room = document.getElementById(roomID);
	room.src = "images/" + fileNameBase + ind + "." + fileExt;
}

/**************
 * change pictures function with 2 arguments (at least)
 * 1st argument is the id of image in HTML
 * 2nd argument is the name of images including the folder(s) under the root context
 **************/
function changeImages(){
	document[changeImages.arguments[0]].src = changeImages.arguments[1];
}

function fillApplicationForm(openingInfoID, openingInfo, onlineApplicationRequstForm){
	var openingInfoCtl = document.getElementById(openingInfoID);
	openingInfoCtl.value=openingInfo;
	onlineApplicationRequstForm.submit ();
}

function viewDetailedOppo(oppoCtlID, oppoID, detailedOppoReqForm){
	var oppoCtl = document.getElementById(oppoCtlID);
	oppoCtl.value = oppoID;
	detailedOppoReqForm.submit ();
}

function getRealTimeResponse (URL){
	var req = false;
	if (window.XMLHttpRequest){
		try{
			req = new XMLHttpRequest ();
		}catch(E){
			req = false;
		}
	}else if (window.ActiveXObject){
		try{
			req = new ActiveXObject ("Msxml2.XMLHTTP");
		}catch(E){
			try{
				req = new ActiveXObject ("Microsoft.XMLHTTP");
			}catch(E){
				req = false;
			}
		}
	}// end of if
	
	// open the page whose content will be populated in the element
	if (req){
		try{
			req.open('GET', URL, false);
		}catch(E){
			alert ("error reading file!");
		}
		req.send (null);
		return req.responseText;
	}else{
		return "Your browser doesn't support loading file."
	}
}

function normalizePhone(phone) {
	var p1 = /(\d{3})(\d{3})(\d{4})/; // eg, 4155551212
	var p2 = /\((\d{3})\)\s+(\d{3})[^\d]+(\d{4})/; // eg, (415)555-1212
	phone = phone.replace(p1, "$1-$2-$3");
	phone = phone.replace(p2, "$1-$2-$3");
	return phone;
}

// goto page to register for a course
function registerCourse (){
	visitSpecificPage ("training_services", "training/view/registerCourse.php");
}

// goto page to evaluate the training session
function evaluateTrainingSession(){
	window.location = "mainFrame.php?navi=public;page=training/view/evaluateTrainingSession.php;sidebar=";
}

// goto page to contact support
function contactSupport (){
	window.location = "mainFrame.php?navi=public;page=support/view/contactSupport.php;sidebar=";
}

// goto page to evaluate support's performance
function evaluateSupportPerf (){
	window.location = "mainFrame.php?navi=public;page=support/view/evaluateSupportPerf.php;sidebar=";
}

function isRated (item){
	var i = 1;
	for (; i <= 5; i ++){
		if (document.getElementById(item + "_" + i).checked){
			return true;
		}
	}
	return false;
}

var CourseEvalFormItems = new Array("jobKnowledge", "delivery", "classControl", "interaction", 
			"appearance", "coverage", "content", "duration");

function submitCourseEvalForm(){
	var instrID = document.getElementById ("instrID").value;
	var courseID = document.getElementById ("courseID").value;
	var sessID = document.getElementById ("sessID").value;

	var comments = document.getElementById ("comments").value;

	// check if instructor is selected
	if (instrID == "-1"){
		alert ("You must select one instructor");
		return;
	}
	// check if course is selected
	if (courseID == "-1"){
		alert ("You must select one course");
		return;
	}
	// check if session is selected
	if (sessID == "-1"){
		alert ("You must select one session");
		return;
	}

	for (i=0; i < CourseEvalFormItems.length; i ++){
		if (isRated (CourseEvalFormItems[i])){
			continue;
		}else{
			alert ("You have not rated " + CourseEvalFormItems[i] + " yet");
			return;
		}
	}
	
	if (comments.length > 512){
		alert ("comments is too long (limit is 512 bytes)");
		return;
	}

	document.courseEvalForm.submit();
}


function selectEmployee (emp){
	var svrURL = "/php/internal/servlet/employeeSvr.php";
	var id = emp.value;
	var jobTitle = getRealTimeResponse (svrURL + "?emp_id=" + id + "&field=jobTitle");
	var dept = getRealTimeResponse (svrURL + "?emp_id=" + id + "&field=Dept");
	var mgrID = getRealTimeResponse (svrURL + "?emp_id=" + id + "&field=MgrID");
	var mgr = getRealTimeResponse (svrURL + "?emp_id=" + id + "&field=Mgr");

	document.getElementById ("empID").value = id;
	document.getElementById ("jobTitle").value = jobTitle;
	document.getElementById ("dept").value = dept;
	document.getElementById ("mgr_id").value = mgrID;
	document.getElementById ("mgr").value = mgr;
}

var itemsPerformanceForm = new Array("jobKnowledge", "workQuality", "attendance", 
			"punctuality", "initiative", "communication", "listening", "dependability");

function submitPerfForm(){
	var emp_id = document.getElementById ("employee").value;
	var reviewFrom = document.getElementById ("reviewFrom").value;
	var reviewTo = document.getElementById ("reviewTo").value;
	
	var comments = document.getElementById ("comments").value;
	var goals = document.getElementById ("goals").value;
	
	var timePtn = /^(\d{4})-(\d{2})-(\d{2})$/;
	
	// check if employee is selected
	if (emp_id == "-1"){
		alert ("You must select one employee");
		return;
	}
	
	// validate the time input
	if (timePtn.test(reviewFrom) && timePtn.test(reviewTo)){
		reviewFrom = reviewFrom.replace(timePtn, "$2/$3/$1"); 
		reviewTo = reviewTo.replace(timePtn, "$2/$3/$1"); 

		var from = Date.parse (reviewFrom);
		var to = Date.parse (reviewTo);

		if (from > to){
			alert ("end time must be after the start time");
			return;
		}
	}else{
		alert ("period of review is not corret. e.g. 2008-01-31");
		return;
	}

	for (i=0; i < itemsPerformanceForm.length; i ++){
		if (isRated (itemsPerformanceForm[i])){
			continue;
		}else{
			alert ("You have not rated " + itemsPerformanceForm[i] + " yet");
			return;
		}
	}
	
	if (comments.length > 512){
		alert ("comments is too long (limit is 512 bytes)");
		return;
	}

	if (goals.length > 512){
		alert ("goals is too long (limit is 512 bytes)");
		return;
	}

	document.performanceForm.submit();
}

function normalizePhone(phone) {
	var p1 = /(\d{3})(\d{3})(\d{4})/; // eg, 4155551212
	var p2 = /\((\d{3})\)\s+(\d{3})[^\d]+(\d{4})/; // eg, (415)555-1212
	phone = phone.replace(p1, "$1-$2-$3");
	phone = phone.replace(p2, "$1-$2-$3");
	return phone;
}

function calculateRating(){
	var total = 0;
	for (i=0; i < itemsPerformanceForm.length; i ++){
		total += getRating (itemsPerformanceForm[i]);
	}
	document.getElementById("overallRating").value= total/itemsPerformanceForm.length;
}

function getRating (item){
	var i = 1;
	for (; i <= 5; i ++){
		if (document.getElementById(item + "_" + i).checked){
			return i;
		}
	}
	return 0;
}

function showIntro(person){
	if (person == "Walter"){
		return overlib("<img src='images/contact.gif'><br clear='both'>with 10 years of hands on experience on Java and C++ application development (e.g. GIS, website, ERP)");
	}else if (person == "Tope"){
		return overlib("<img src='images/tope.jpg'><br clear='both'>with 30+ years of experience on enterprise data issues and Unix, Linux system");
	}
}

function showCourseIntro(course){
	if (course == "Java"){
		return overlib('<ul><li>Knowledge of Java<li>Web application with Java<li>also inlcude some database integration</ul>');
	}else if (course == "Linux"){
		return overlib('Advanced Unix and Linux system administration esp. in Red Hat system and Solaris');
	}
}

/*
 * find the index of the option value in the list of select options 
 */
function indexOfOptions (opValue, select){
	if (opValue && select){
		for (var i = select.options.length; i > 0; i--){
			if (select.options[i-1].value == opValue){
				return i-1;
			}
		}
	}
	return -1;
}




function pickUpCourse (course){
	document.getElementById ("course").value = course;
}

function validateLength (inputID, inputName, limit){
	var ret = "";
	var len = document.getElementById (inputID).value.length;
	if (len > limit){
		ret = inputName + ": larger than the limit (" + limit + ") => " + len + "\n";
	}
	return ret;
}

function requireTextInput (inputID, inputName){
	var ret = "";
	var len = document.getElementById (inputID).value.length;
	if (len == 0){
		ret = "You must fill in the " + inputName + " field (required) \n";
	}
	return ret;
}

function validateEmail(inputID, inputName) {
	var ret = "";
	var emailAddr = document.getElementById (inputID).value;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr)){
	}else{
		ret = "You must enter the right email - " + inputName + " (format wrong)\n";
	}
	return ret;

}


function checkFormApplEducation(){
	var error = "";
	error += requireTextInput ("schoolName", "School name");
	error += requireTextInput ("major", "Major/Specialization");

	error += validateLength ("schoolName", "School name", 64);
	error += validateLength ("major", "Major/Specialization", 40);
	error += validateLength ("location", "Location", 64);
	error += validateLength ("honors", "Honors", 60);
	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function checkFormApplExperience(){
	var error = "";
	error += requireTextInput ("employerName", "Company Name");
	error += requireTextInput ("title", "Job title");

	error += validateLength ("employerName", "Company Name", 64);
	error += validateLength ("country", "Country", 64);
	error += validateLength ("title", "Job title", 64);
	error += validateLength ("resp", "Responsibilities", 1024);
	error += validateLength ("achi", "Achievements", 1024);
	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function checkFormApplProfile(){
	var error = "";

	error += requireTextInput ("addr", "Address");
	error += requireTextInput ("city", "City");
	error += requireTextInput ("prov", "Province");
	error += requireTextInput ("country", "country");
	error += requireTextInput ("tel1", "Primary phone");

	error += validateLength ("addr", "Address", 64);
	error += validateLength ("city", "City", 32);
	error += validateLength ("prov", "Province", 32);
	error += validateLength ("country", "country", 64);
	error += validateLength ("zip", "Postal code", 10);
	error += validateLength ("tel1", "Primary phone", 20);
	error += validateLength ("tel2", "Secondary phone", 20);
	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function confirmSubmittion(){
	var message = "Confirmation!\nYou CANNOT make changes after submission. Are you sure to submit your application now?";
	return confirm(message);
}

function checkFormApplCoverLetter(){
	var error = "";

	error += requireTextInput ("coverL", "Cover letter");
	error += validateLength ("coverL", "Cover letter", 1000);

	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function checkFormApplSkillSet(){
	var error = "";
	error += validateLength ("others", "Other qualifications", 100);
	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function onlineHelp(helpMsg){
	var HTMLoutput = "";
	myModelessDialog = showModelessDialog("/help.htm",window,"dialogLeft:0; dialogWidth:200px;dialogHeight:300px; resizable:yes; status:no;");
	modelessBody = myModelessDialog.document.body;
	modelessBody.style.backgroundColor = "#fff"

	HTMLoutput += "<html><head><title>online help</title></head>";
	HTMLoutput += "<body><div style='padding:5px;border-bottom:1px solid red'>" + helpMsg + "</div>";
	HTMLoutput += "<div align='center'><input type='button' value='close' onclick='self.close();' />";
	HTMLoutput +="</div></body></html>";

	modelessBody.innerHTML = HTMLoutput;
}

/* check the input in the registering page */
function checkRegistry (formReg){
	var error = "";
	error += requireTextInput ("email", "E-mail address");
	error += requireTextInput ("fname", "First Name");
	error += requireTextInput ("lname", "Last Name");

	error += validateLength ("email", "E-mail address", 64);
	error += validateLength ("fname", "First Name", 32);
	error += validateLength ("lname", "Last Name", 32);

	if (error != ""){
		alert (error);
		return false;
	}else{
		if (checkEmail ("email") ){
			formReg.submit();
		}
	}
}

function toggleVisible (ctlID){
	var ctl = document.getElementById (ctlID);
	if (ctl.style.display == 'none') {
		ctl.style.display = '';
	} else {
		ctl.style.display = 'none';
	}
}

function setDuration (cal, ctlID, calID, fmt){
var ctl = document.getElementById (ctlID);
cal.select(ctl, calID, fmt);
}

function setupRequestPanel (curProdServCD, reqPanelCtlID){
	var reqPanelCtl = document.getElementById (reqPanelCtlID);
	if ((curProdServCD != "") && document.recalc && document.body.attachEvent){
		reqPanelCtl.style.setExpression ("top", "document.body.scrollTop+150");
		reqPanelCtl.style.setExpression ("left", "document.body.clientWidth-95");
		document.body.onscroll=function (){document.recalc(true)};

		reqPanelCtl.innerHTML = "<form name='reqLinkForm' target='_top' method='POST' action='/mainFrame.php?navi=about;page=requestForm;sidebar=' style='margin:0; padding:0;'><input type='hidden' name='pageProdServCD' id='pageProdServCD' value=''><a href='#' onclick=\"javascipt:showRequestFormByCD('reqLinkForm', '" + curProdServCD + "');\">Order this product / service</a></form>";
		reqPanelCtl.style.display = "";
	}else{
		reqPanelCtl.style.display = "none";
	}
}

function getProdServCDByNaviPage (navi, page){
	var cd = "";
	if (navi == "product"){
		var patternHR = /^hr/;
		var patternInvest = /^invest/;
		if (patternHR.test(page)){
			cd = "H";
		}else if (patternInvest.test(page)){
			cd = "H";
		}else if (page == "WBT"){
			cd = "W";
		}
	}else if (navi == "service"){
		if (page == "oraEBizSuiteImpl" || page == "expertInImpl" ||
			page == "whyUS" ||
			page == "overviewOraEBizSuite" || page == "benefitsOfPlugging"){
			cd = "E";
		}else if ( page == "postImplSupport" || page == "oraFinancialsPackage"){
			cd = "A";
		}else if ( page == "trainingSupport"){
			cd = "T";
		}else if (page == "tippingPoint" || 
			page == "networkSecurity" || page == "WHOISON"){
			cd = "S";
		}
	}
	return cd;
}

function checkContactWay(){
	wayE = document.getElementById('contactE').checked;
	wayP = document.getElementById('contactP').checked;
	wayF = document.getElementById('contactF').checked;
	wayM = document.getElementById('contactM').checked;
	
	document.getElementById('emailTip').className= wayE ? "requiredFieldTip" : "fieldTip";
	document.getElementById('phoneTip').className= wayP ? "requiredFieldTip" : "fieldTip";
	document.getElementById('faxTip').className= wayF ? "requiredFieldTip" : "fieldTip";
	document.getElementById('mailTip').className= wayM ? "requiredFieldTip" : "fieldTip";

	proSvrH = document.getElementById('prodServH').checked;
	proSvrW = document.getElementById('prodServW').checked;
	proSvrT = document.getElementById('prodServT').checked;

	var totalCost = parseInt (document.getElementById("totalCost").value);
	proSvrC = (totalCost > 0);

	if ((! wayE && ! wayP && ! wayF && ! wayM) || 
		(! proSvrH && ! proSvrW && ! proSvrT && ! proSvrC) ){
		document.getElementById('btnSubmit').disabled="disabled";
	}else{
		document.getElementById('btnSubmit').disabled="";
	}
}

function checkInputReqForm (fm){
	errors = "";
	errors += requireTextInput ('fullName', 'Contact Name');
	errors += requireTextInput ('quest', 'Request');

	wayE = document.getElementById('contactE').checked;
	wayP = document.getElementById('contactP').checked;
	wayF = document.getElementById('contactF').checked;
	wayM = document.getElementById('contactM').checked;
	
	if (wayE) errors += requireTextInput ('contactWayE', 'Email');
	if (wayP) errors += requireTextInput ('contactWayP', 'Phone');
	if (wayF) errors += requireTextInput ('contactWayF', 'Fax');
	if (wayM) errors += requireTextInput ('contactWayM', 'Address');
	
	proSvrH = document.getElementById('prodServH').checked;
	proSvrW = document.getElementById('prodServW').checked;
	proSvrT = document.getElementById('prodServT').checked;

	var totalCost = parseInt (document.getElementById("totalCost").value);
	proSvrC = (totalCost > 0);
	
	if (!proSvrH && ! proSvrW && !proSvrT && !proSvrC){
		errors += "select our products or services!";
	}

	if (errors == ""){
		// check email address;
		if (document.getElementById('contactWayE').value != ""){
			if (checkEmail ("contactWayE") ){
				document.getElementById("cnsSvrReq").value = document.getElementById("oraConLstTblBox").innerHTML;
				return true;
			}
		}else{
			return true;
		}
	}else{
		alert (errors);
	}
	return false;
}

function showRequestFormByCD (formID, prodServCD){
	document.getElementById('pageProdServCD').value = prodServCD;
	document.getElementById(formID).submit();
}

function freshRequestForm (vPreProdServCD){
	fm = document.getElementById('reqForm');
	if (fm){
		document.getElementById('prodServH').checked = (vPreProdServCD == "H") ? "checked" : "";
		document.getElementById('prodServW').checked = (vPreProdServCD == "W") ? "checked" : "";
		document.getElementById('prodServT').checked = (vPreProdServCD == "T") ? "checked" : "";
	}
}


function clearChildren(el){
	while (el.childNodes.length > 0){
		removeChildSafe (el.childNodes [el.childNodes.length - 1]);
	}
}

function removeChildSafe (el){
	while (el.childNodes.length > 0){
		removeChildSafe (el.childNodes [el.childNodes.length - 1]);
	}
	el.parentNode.removeChild (el);
}


function makeHiddenInput (ctlID, val){
	return document.createElement(
		"<input type='hidden' id='" + ctlID + "' name='" + ctlID + "' value='" + val + "'>");
}
function makeTableCellText(val){
	var newCell = document.createElement("TD");
	var newTextNode = document.createTextNode(val);
	newCell.appendChild (newTextNode);
	return newCell;
}
function makeTableCell(ctlID, val){
	var newCell = document.createElement("TD");
	var newTextNode = document.createTextNode(val);
	newCell.appendChild (newTextNode);
	newCell.appendChild (makeHiddenInput (ctlID, val));
	return newCell;
}
function getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { 
		ol += el.offsetLeft; 
	}
	return ol;
}
function getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { 
		ot += el.offsetTop; 
	}
	return ot;
}
function closePopup(popupID){
	var box = document.getElementById(popupID);
	if (box){
		box.style.display="none";
	}
}
function showAddConsultantPanel (ele, winHeight){
	var panelBox = document.getElementById("professionalReqForm");
	if (panelBox){
		w = panelBox.style.width;
		h = panelBox.style.height;
		
		wWin = screen.width;
		hWin = screen.height;
	
		x = 200;
		y = 100;

		panelBox.style.left = x + "px";
		panelBox.style.top = y + "px";
		panelBox.style.display = "";
	}
/*
	x = getPageOffsetLeft (ele);
	y = getPageOffsetTop (ele) - winHeight; // + ele.offsetHeight

	var panelBox = document.getElementById("professionalReqForm");

	if (panelBox){
		panelBox.style.left = x + "px";
		panelBox.style.top = y + "px";
//		panelBox.style.height = winHeight + "px";
		panelBox.style.display = "";
	}
*/
}

function addCnsSvr(){
	var tblBody = document.getElementById("oraConLstTbl");
	clearChildren (tblBody);

	var totalCost = parseInt (document.getElementById("totalCost").value);
	if (totalCost > 0){
		var numCns = parseInt (document.getElementById("noCns").value);
		var numSvr = parseInt (document.getElementById("noSvr").value);
		
		var numRow = 0;
		for (var index = 1; index <= numCns; index ++){
			var noCns = parseInt (document.getElementById("noCns" + index).value);
			var timeCns = parseInt (document.getElementById("timeCns" + index).value);
			
			if (noCns > 0 && timeCns > 0){
				var cnsName = document.getElementById("cnsName" + index).value;
				var cnsLevel = document.getElementById("cnsLvl" + index).value;
				var cnsRateWay = document.getElementById("cnsRateWay" + index).value;
				var cnsRate = parseInt (document.getElementById("cnsRate" + index).value);

				tblBody.appendChild( getCnsSvrTableRow (numRow ++, cnsName, cnsLevel, cnsRate, cnsRateWay, noCns, timeCns));
			}
		}
	
		for (var index = 1; index <= numSvr; index ++){
			var noSvr = parseInt (document.getElementById("noSvr" + index).value);
			var timeSvr = parseInt (document.getElementById("timeSvr" + index).value);
			
			if (noSvr > 0 && timeSvr > 0){
				var svrName = document.getElementById("svrName" + index).value;
				var svrRateWay = document.getElementById("svrRateWay" + index).value;
				var svrRate = parseInt (document.getElementById("svrRate" + index).value);

				tblBody.appendChild( getCnsSvrTableRow (numRow ++, svrName, "", svrRate, svrRateWay, noSvr, timeSvr));
			}
		}
	}
	document.getElementById("totalCostVisible").innerHTML = totalCost;

	if (totalCost < 1){
		alert ("No consultants or services requested!");
	}else{
		closePopup('professionalReqForm');
		document.getElementById ("oraConLstTblBox").style.display = '';
		checkContactWay();
	}
}

function recalCnsSvr (){
	var numCns = parseInt (document.getElementById("noCns").value);
	var numSvr = parseInt (document.getElementById("noSvr").value);
	var totalCost = 0;
	
	for (var index = 1; index <= numCns; index ++){
		var noCns = parseInt (document.getElementById("noCns" + index).value);
		var timeCns = parseInt (document.getElementById("timeCns" + index).value);
		
		if (noCns > 0 && timeCns > 0){
			var cnsName = document.getElementById("cnsName" + index).value;
			var cnsRateWay = document.getElementById("cnsRateWay" + index).value;
			var cnsRate = parseInt (document.getElementById("cnsRate" + index).value);
			var cnsCost = noCns * timeCns * cnsRate;
			totalCost += cnsCost;
		}
	}

	for (var index = 1; index <= numSvr; index ++){
		var noSvr = parseInt (document.getElementById("noSvr" + index).value);
		var timeSvr = parseInt (document.getElementById("timeSvr" + index).value);
		
		if (noSvr > 0 && timeSvr > 0){
			var svrName = document.getElementById("svrName" + index).value;
			var svrRateWay = document.getElementById("svrRateWay" + index).value;
			var svrRate = parseInt (document.getElementById("svrRate" + index).value);
			var svrCost = noSvr * timeSvr * svrRate;
			totalCost += svrCost;
		}
	}
	document.getElementById("totalCost").value = totalCost;
}
function getCnsSvrTableRow (vPos, vName, vLevel, vRate, vRateWay, vNo, vTime){
	// 1. create table row object
	var newRow = document.createElement("TR");
	// set the css style as default
		newRow.className = ((vPos % 2) == 0 ) ? "oddRow" : "evenRow";

	// 2. create text table cells
	var cnsSvrDisplay = (vLevel == "") ? vName : vName + " -- " + vLevel;
	newRow.appendChild (makeTableCellText (cnsSvrDisplay) );
	newRow.appendChild (makeTableCellText (vRate + " / " + vRateWay) );
	newRow.appendChild (makeTableCellText (vNo) );
	newRow.appendChild (makeTableCellText (vTime + " " + vRateWay + "s") );

	// 3. return table row object
	return newRow;
}

// used in client user login page
function checkUserID (ctlUserID, fm){
	if (checkEmail (ctlUserID) ){
		fm.submit();
	}
}

/*
document.location, document.URL, and document.referrer
document.location.protocol
alert(document.referrer) 

-- one time pop up dialog at the first time
var cookies = new Object();
document.cookie = "cookiesenabled=yes";       
extractCookies();                               
if (cookies["cookiesenabled"] == "yes" && !cookies["has_seen_tip"]){   
   document.cookie = "has_seen_tip=true";
   window.open("/tipoftheday.html", "tipwindow", "resizable");
}
*/



var picCBNCurIndex = 1;
var picCBNIndexTop = 4;
var picCBNLocation = "images/";
var picCBNFilePre = "cbnTrn";
var picCBNFileType = ".jpg";
function showNextCBN(){
	picCBNCurIndex ++;
	if (picCBNCurIndex > picCBNIndexTop){
		picCBNCurIndex = 1;
	}
	refreshShowroomCBN();
}

function showPreviousCBN(){
	picCBNCurIndex --;
	if (picCBNCurIndex < 1){
		picCBNCurIndex = picCBNIndexTop;
	}
	refreshShowroomCBN ();
}

function refreshShowroomCBN () {
	var currentpicCBN = document.getElementById ("cbnCurPicture");
	currentpicCBN.src = picCBNLocation + picCBNFilePre + picCBNCurIndex + picCBNFileType;
}

var picFMFCurIndex = 6;
var picFMFIndexTop = 15;
var picFMFLocation = "images/";
var picFMFFilePre = "fmf";
var picFMFFileType = ".jpg";
function showNextFMF(){
	picFMFCurIndex ++;
	if (picFMFCurIndex > picFMFIndexTop){
		picFMFCurIndex = 1;
	}
	refreshShowroomFMF ();
}

function showPreviousFMF(){
	picFMFCurIndex --;
	if (picFMFCurIndex < 1){
		picFMFCurIndex = picFMFIndexTop;
	}
	refreshShowroomFMF ();
}

function refreshShowroomFMF () {
	var currentPic = document.getElementById ("curFMFPicture");
	currentPic.src = picFMFLocation + picFMFFilePre + picFMFCurIndex + picFMFFileType;
}

function showLatestNews(latestNewsID){
	var news = document.getElementById (latestNewsID);
	news.style.display = '';
}
function clearNews(latestNewsID){
	var news = document.getElementById (latestNewsID);
	news.style.display = 'none';
}
function countrySelected (elem){
	for (var i = document.safewordForm.state.options.length; i >= 0; i--){
		document.safewordForm.state.options[i] = null;
	}
	if (elem.options[elem.selectedIndex].value=="Canada"){
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Please select:','');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Alberta','AB');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('British Columbia','BC');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Manitoba','MB');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('New Brunswick','NB');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Newfoundland','NF');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Newfoundland and Labrador','NL');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Northwest Territories','NT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Nova Scotia','NS');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Nunavut','NU');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Ontario','ON');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Prince Edward Island','PE');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Quebec','QC');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Saskatchewan','SK');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Vermont','VT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Yukon','YT');
	}else if (elem.options[elem.selectedIndex].value=="United States"){
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Please select:','');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Alabama','AL');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Alaska','AK');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Am. Samoa','AS');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Arizona','AZ');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Arkansas','AR');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('California','CA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Colorado','CO');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Connecticut','CT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Delaware','DE');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Federated States of Micronesia','FM');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Florida','FL');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Georgia','GA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Guam','GU');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Hawaii','HI');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Idaho','ID');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Illinois','IL');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Indiana','IN');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Iowa','IA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Kansas','KS');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Kentucky','KY');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Louisiana','LA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Maine','ME');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Marshall Islands','MH');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Maryland','MD');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Massachusetts','MA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Michigan','MI');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Minnesota','MN');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Mississippi','MS');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Missouri','MO');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Montana','MT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Nebraska','NE');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Nevada','NV');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('New Hampshire','NH');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('New Jersey','NJ');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('New Mexico','NM');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('New York','NY');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('North Carolina','NC');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('North Dakota','ND');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Northern Mariana Island','MP');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Ohio','OH');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Oklahoma','OK');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Oregon','OR');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Palau','PW');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Pennsylvania','PA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Puerto Rico','PR');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Rhode Island','RI');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('South Carolina','SC');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('South Dakota','SD');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Tennessee','TN');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Texas','TX');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Utah','UT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Vermont','VT');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Virgin Islands','VI');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Virginia','VA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Washington','WA');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Washington D.C.','DC');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('West Virginia','WV');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Wisconsin','WI');
		document.safewordForm.state.options[document.safewordForm.state.options.length] = new Option('Wyoming','WY');
	}
}

function orderSafeword(){
	// check the inputs of form
	if (checkOrderForm() && checkEmail ("email") ){
		return true;
	}
	return false;
}

function hov(ele,cls) {   
  if(ele.className)   
    ele.className=cls;   
}   

function requireSelection (seleID, seleName){
	var ret = "";
	var sel = document.getElementById (seleID);
	if (sel){
		var curOp = sel.options[sel.selectedIndex].value;
		if (curOp == "" || curOp == "-1"){
			ret = "Please select " + seleName + " \n";
		}
	}else{
		ret = "invalid control id. \n"
	}
	return ret;
}

function checkOrderForm(){
	var error = "";
	error += requireTextInput ("company", "Company name");
	error += requireTextInput ("title", "Function");
	error += requireTextInput ("firstName", "First Name");
	error += requireTextInput ("lastName", "Last Name");
	error += requireTextInput ("email", "Email");
	error += requireTextInput ("phone_country_code", "Telephone Country Code");
	error += requireTextInput ("phone_area_code", "Telephone Area Code");
	error += requireTextInput ("phone_local_phone", "Telephone Local Number");

	error += requireTextInput ("address", "Address");
	error += requireTextInput ("city", "City");
	error += requireTextInput ("zip", "Zip");

	error += requireSelection ("country", "Country");
	error += requireSelection ("contactMethod", "Contact Method");

	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}

function order (prod){
	page = "support/order.php";
	currentURL = "/mainFrame.php?navi=istore;page=" + page + ";sidebar=;prod="+ prod;
	window.location.href  = currentURL;
	currentURL = datasciAddress + currentURL;
}

function selectProductToOrder (proID){
	if (proID){
		var selProd = document.getElementById('prodtoOrder');
		var index = indexOfOptions (proID, selProd);
		if (index != -1){
			selProd.selectedIndex = index;
		}
	}
}

function visitSafeword(){
	// var url = "http://www.aladdin.com/Special/safeword/counting-on-passwords/data-scientific/email.html";
	var url = "http://www.aladdin.com/Special/safeword/counting-on-passwords/data-scientific/default.asp?CMP=SFS-70120000000BSJkAAO&CID=text";
	popupFull (url);
}

function getElement (id_or_obj){
	return (typeof id_or_obj == "string") ? document.getElementById(id_or_obj) : id_or_obj;
}

function hideEle (id_or_obj){
	var el = getElement (id_or_obj);
	if (el){
		el.style.display = "none";
	}
} 

function showEle (id_or_obj){
	var el = getElement (id_or_obj);
	if (el){
		el.style.display = "block";
	}
} 

function showTooltip (contentDivID){
	var tipContent = getElement(contentDivID).innerHTML;
    var tooltipBox = getElement("tooltip");
    if (tooltipBox){
        var mouseX = 0;
        var mouseY = 0;
        var isIE = document.all ? true : false;
        if (isIE){
            mouseX = event.clientX + document.body.scrollLeft;
            mouseY = event.clientY + document.body.scrollTop;
        }else{
            // other web browsers
            mouseX = event.pageX;
            mouseY = event.pageY;
        }
        
        var offset = 5;
        
        if (mouseX > 600){
        	mouseX = 600;
        }

        tooltipBox.style.left = mouseX + offset + offset;
        tooltipBox.style.top = mouseY + offset + offset + offset;
        tooltipBox.innerHTML = tipContent;
        showEle(tooltipBox);
    }
}

function hideTooltip (){
    hideEle("tooltip");
}

function reqCrse_showRegType (){
	var ele = getElement('regTypeInd');
	if (ele){
		if (ele.checked){
			hideEle('corporateBox');
		}else{
			showEle('corporateBox');
		}
	}
}

function reqCrse_copyAddress(){
	var eleLastName = getElement('ind_lastName');
	var eleFirstName = getElement('ind_firstName');
	var eleInitials = getElement('ind_initials');
	var eleBillName= getElement('bill_name');
	if (eleLastName && eleFirstName && eleInitials && eleBillName){
		eleBillName.value = eleFirstName.value + " " + eleInitials.value  + " " + eleLastName.value;
	}
	copyValueFromTo ('ind_mailAddr', 'bill_mailAddr');
	copyValueFromTo ('ind_city', 'bill_city');
	copyValueFromTo ('ind_state', 'bill_state');
	copyValueFromTo ('ind_zip', 'bill_zip');
	copyValueFromTo ('ind_country', 'bill_country');
}

function copyValueFromTo (eleFromID, eleToID){
	var eleFrom = getElement(eleFromID);
	var eleTo = getElement(eleToID);
	if (eleTo && eleFrom){
		eleTo.value = eleFrom.value;
	}
}

function reqCrse_changeCategory (){
	var ele = getElement('courseCategory');
	if (ele.value == "ebiz"){
		showEle('courseNameSelect');
		hideEle('courseNameText');
	}else{
		hideEle('courseNameSelect');
		showEle('courseNameText');
		reqCrseHideEbizInfo ();
	}
}
function reqCrse_udpateCourseInfo (){
	var ele = getElement('courseNameSelect');
	if (ele.value == "basics_flex_op")	{reqCrseShowEbizInfo('basics_flex_box');
	}else if (ele.value == "gl1_flex_op")		{reqCrseShowEbizInfo('gl1_flex_box');
	}else if (ele.value == "payFun1_flex_op")	{reqCrseShowEbizInfo('payFun1_flex_box');
	}else if (ele.value == "finMgt1_op")		{reqCrseShowEbizInfo('finMgt1_box');
	}else if (ele.value == "finMgt2_op")		{reqCrseShowEbizInfo('finMgt2_box');
	}else if (ele.value == "gl2_op")			{reqCrseShowEbizInfo('gl2_box');
	}else if (ele.value == "subLedg_op")		{reqCrseShowEbizInfo('subLedg_box');
	}else if (ele.value == "payFun2_op")		{reqCrseShowEbizInfo('payFun2_box');
	}else if (ele.value == "recFun1_op")		{reqCrseShowEbizInfo('recFun1_box');
	}else if (ele.value == "recFun2_op")		{reqCrseShowEbizInfo('recFun2_box');
	}else if (ele.value == "cash_op")			{reqCrseShowEbizInfo('cash_box');
	}else if (ele.value == "assets1_op")		{reqCrseShowEbizInfo('assets1_box');
	}else if (ele.value == "assets2_op")		{reqCrseShowEbizInfo('assets2_box');
	}else if (ele.value == "inv1_op")			{reqCrseShowEbizInfo('inv1_box');
	}else if (ele.value == "inv2_op")			{reqCrseShowEbizInfo('inv2_box');
	}else if (ele.value == "pur1_op")			{reqCrseShowEbizInfo('pur1_box');
	}else if (ele.value == "pur2_op")			{reqCrseShowEbizInfo('pur2_box');
	}else{reqCrseHideEbizInfo ();
	}
}
var reqCrse_curCourseInfoBoxID = "";
function reqCrseShowEbizInfo (eleID){
	if (reqCrse_curCourseInfoBoxID != ""){
		hideEle(reqCrse_curCourseInfoBoxID);
	}
	reqCrse_curCourseInfoBoxID = eleID;
	showEle(reqCrse_curCourseInfoBoxID);
}
function reqCrseHideEbizInfo (){
	if (reqCrse_curCourseInfoBoxID != ""){
		hideEle(reqCrse_curCourseInfoBoxID);
		reqCrse_curCourseInfoBoxID = "";
	}
}
var numParticipants = 1;
function reqCrse_updateParticipants(){
	var ele = getElement('noParticip');
	if (ele){
		var num = parseInt (ele.value);
		if (num < numParticipants){
			// remove last rows
			reqCrse_removeLastRows (num);
		}else if (num > numParticipants){
			// append rows
			reqCrse_appendRows (numParticipants, num - numParticipants);
		}
		numParticipants = num;
	}
}

function reqCrse_removeLastRows (numRowsToKeep){
	participants = document.getElementById("participantsTable");
	var index = 1;
	var curRow = participants.firstChild;
	var nextRow = curRow.nextSibling;
	while (nextRow) {
		index++;
		if (index > numRowsToKeep){
			// remove the row from the table
			participants.removeChild (nextRow);
		}else{
			curRow = nextRow;
		}
		nextRow = curRow.nextSibling;
	}// end of while
}

function reqCrse_createInput(inputID, size){
	var newEle;
	newEle = document.createElement("input");
	newEle.type = "TEXT";
	newEle.name = inputID;
	newEle.id = inputID;
	newEle.size = size;
	return newEle;
}

function reqCrse_appendRows (numStart, numRows){
	participants = document.getElementById("participantsTable");
	if (participants){
		var index = 0;
		while (index < numRows){
			index ++;
			
			var newSN = numStart + index;
			
			// elements ID
			var ele_ptcpnt_lastNameID = "ptcpnt_lastName" + newSN;
			var ele_ptcpnt_firstNameID = "ptcpnt_firstName" + newSN;
			var ele_ptcpnt_iniID = "ptcpnt_ini" + newSN;
			var ele_ptcpnt_email1ID = "ptcpnt_email" + newSN;
	
			// 1. create table row object
			var newRow = document.createElement("TR");
			
			// 2. create table cell
			var newTableCellLastname = document.createElement("TD");
			var newTableCellFirstname = document.createElement("TD");
			var newTableCellInitials = document.createElement("TD");
			var newTableCellEmail = document.createElement("TD");
			
			// add input element inside each cell
			newTableCellLastname.appendChild (reqCrse_createInput (ele_ptcpnt_lastNameID, 15));
			newTableCellFirstname.appendChild (reqCrse_createInput (ele_ptcpnt_firstNameID, 15));
			newTableCellInitials.appendChild (reqCrse_createInput (ele_ptcpnt_iniID, 2));
			newTableCellEmail.appendChild (reqCrse_createInput (ele_ptcpnt_email1ID, 20));
	
			// add cells inside table row
			newRow.appendChild (newTableCellLastname);
			newRow.appendChild (newTableCellFirstname);
			newRow.appendChild (newTableCellInitials);
			newRow.appendChild (newTableCellEmail);
	
			participants.appendChild (newRow);
		}// end of loop
	}
}

function reqCrse_checkReqCrseForm (){
	var error = "";

	var crseErr = "";
	var crseCate = getElement('courseCategory');
	if (crseCate){
		if (crseCate.value == "ebiz"){
			crseErr += requireSelection ("courseNameSelect", "E-Business Course");
		}else{
			crseErr += requireTextInput ("courseNameText", "Course Name");
		}
	}
	crseErr += requireTextInput ("courseScheduleDate", "Course Schedule Date");

	var numPtcpnt = getElement('noParticip');
	if (numPtcpnt){
		var num = parseInt(numPtcpnt.value);
		var index = 1;
		for (;index <= num;index++){
			var lastNameID = "ptcpnt_lastName" + index;
			var firstNameID = "ptcpnt_firstName" + index;
			var emailID = "ptcpnt_email" + index;

			crseErr += requireTextInput (lastNameID, "Last Name of Participant - " + index);
			crseErr += requireTextInput (firstNameID, "First Name of Participant - " + index);
			crseErr += requireTextInput (emailID, "Email of Participant - " + index);

			crseErr += validateEmail (emailID, "Email of Participant - " + index);
		}
	}
	if (crseErr != ""){
		error += "---- Training Schedule\n";
		error += crseErr;
		error += "\n";
	}
	
	var indErr = "";
	indErr += requireTextInput ("ind_lastName", "Last Name of Person");
	indErr += requireTextInput ("ind_firstName", "First Name of Person");
	indErr += requireTextInput ("ind_email", "Email Address of Person");
	indErr += requireTextInput ("ind_mailAddr", "Mailing Address of Person");
	indErr += requireTextInput ("ind_city", "City of Person");
	indErr += requireTextInput ("ind_country", "Country of Person");
	if (indErr != ""){
		error += "---- Contact Information\n";
		error += indErr;
		error += "\n";
	}

	var regTypeCorp = getElement('regTypeCorp');
	if (regTypeCorp && regTypeCorp.checked){
		var corpErr = "";
		corpErr += requireTextInput ("corp_companyName", "Name of Company");
		corpErr += requireTextInput ("corp_mailAddr", "Mailing Address of Company");
		corpErr += requireTextInput ("corp_city", "City of Company");
		corpErr += requireTextInput ("corp_zip", "Zip of Company");
		corpErr += requireTextInput ("corp_country", "Country of Company");
		if (corpErr != ""){
			error += "---- Company Information\n";
			error += corpErr;
			error += "\n";
		}
	}

	var billErr = "";
	billErr += requireTextInput ("bill_name", "Name of Person / Company Billing to");
	billErr += requireTextInput ("bill_mailAddr", "Billing Mail Address");
	billErr += requireTextInput ("bill_city", "Billing City");
	billErr += requireTextInput ("bill_zip", "Billing Zip");
	billErr += requireTextInput ("bill_country", "Billing Country");
	if (billErr != ""){
		error += "---- Billing Information\n";
		error += billErr;
		error += "\n";
	}

	error += validateEmail ("ind_email", "Email Address of Person");

	if (error != ""){
		alert (error);
		return false;
	}
	return true;
}


function visitIStore (){
	visitBarracudaStore ();
}
function visitBarracudaStore (){
	visitSubMainPage ('barracuda');
}
function visitBarracudaPage(page){
	visitSpecificPage ("istore", page);
}
function visitSafeNetStore (){
	visitSpecificPage ("istore", 'safeWord');
}

function liveBarracudaDemo (pg){
	var url = "http://www.barracudanetworks.com/ns/products/request_online_demo.php?locale=en_US&p=" +  pg + "&form=e4979bba1ad64615fe2367a98f36709d";
	popupFull(url);
}

