function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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();
}



function setBookmark(url,str){
    if(str=='')str=url;
    if (document.all)window.external.AddFavorite(url,str);
    else alert('Press CTRL and D to add a bookmark to:\n"'+url+'".');
}
	
document.cookie = 'test_cookie';
//	window.onload = check_JS_and_Cookies;
function check_JS_and_Cookies() {
	if (document.cookie == "") {
		/* cookies not enabled */
		document.getElementById('warningJS').style.display = 'none';
		document.getElementById('warningCookie').style.display = '';
		document.getElementById('iframeOrderForm').style.display = 'none';
	}
	else {
		/* cookies enabled */
		document.getElementById('warningJS').style.display = 'none';
		document.getElementById('warningCookie').style.display = 'none';
		document.getElementById('warningProgressBar').style.display = 'none';
		
		document.getElementById('iframeOrderForm').style.display = '';
			
		calcHeight('iframeOrderForm');
	}
}
	
function calcHeight(name) {
		//find the height of the internal page
		document.getElementById(name).height = 0;
		var the_height = document.getElementById(name).contentWindow.document.body.scrollHeight;
		//change the height of the iframe
		document.getElementById(name).height = the_height;
}
	
sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function jswebsitealivetracking(){
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
    js.setAttribute('src',document.location.protocol + '//www.websitealive7.com/27/Visitor/vTracker_v2.asp?websiteid=2&groupid=27');
			   
    document.getElementsByTagName('head').item(0).appendChild(js);
}
	
function jsInitPageDefault(){
jsInitPage(0);
}
	
function jsInitPage(PageFlags){
//Added 2007-06-11, DMac
//PageFlags do nothing right now.  
//0 is passed by default, which enables all default functions.  
//bitwise array page inits 
//bit 1 - Do Nothing - Useful it no action is wanted
//bit 2 - Quotes - Not Implemented
//bit 4 - jswebsitealivetracking

//Examples
//if you Just want Quotes, Pass 2
//if you Just want jswebsitealivetracking, Pass 4
//If You want Quotes and jswebtracking, nothing else, Pass 6 (for 2+4)
    if (typeof PageFlags == 'undefined')
    {
        PageFlags=0;
    }
    
    if(PageFlags===null){ //=== without type casting
        PageFlags=0;
    }
   
    if(PageFlags==0)
    {
        jswebsitealivetracking();
        sfHover();
    }else
    {
        if((PageFlags & 1)==1){}
        if((PageFlags & 2)==2){jsloadQuotes();}
        if((PageFlags & 4)==4){jswebsitealivetracking();}
    }
}

if (window.attachEvent) 
{
    window.attachEvent("onload", jsInitPageDefault);
}
else
{
    if(window.addEventListener)
    {
        window.addEventListener('load', jsInitPageDefault, false);
    }
}

MM_reloadPage(true);  

//**  Code added for calulator 2/2010 JC  **//

function ShowCalculatorResults() {
	
	var a = document.getElementById("calculator-participants").value;
	var b = document.getElementById("calculator-duration").value;
	var c = document.getElementById("calculator-calls").value;
    if ((a == '') || (b == '') || (c == '')) {
        return false;
    }
	var minutes = parseInt(a) * parseInt(b) * parseInt(c);
	var cost = 7.9;
	var promo = '';
	
	if (document.location.href.toLowerCase().indexOf('www.corporateconferencecalls.com') != -1) {
	    cost = 3.9;
		promo = 'tfv';
		setCookie("price","3.9", 2);
		setCookie("signuplink","http://www.corporateconferencecalls.com/signup.aspx?id=tfv");
		document.getElementById("calculator-signup").href = 'http://www.corporateconferencecalls.com/signup.aspx?id=tfv';
	}
	else {

	    if(parseFloat(cost) > parseFloat(getCookie("price")))
	    {
		    cost = parseFloat(getCookie("price"));
	    }
	    else
	    {
		    if((parseInt(minutes) >= 25000) && (parseInt(a) <= 124)) {
			    cost = 6.9;
		    }
	    }
	}

	var totalcost = (parseFloat(cost) * .01) * minutes;
	
	document.getElementById("calculator-estimate-minutes").innerHTML = addCommas(minutes);
	document.getElementById("calculator-result-total-value").innerHTML = "$" + formatAsMoney(totalcost);
	document.getElementById("calculator-cents").innerHTML = cost + "&cent;";
	document.getElementById("calculator-estimate-cost").innerHTML = cost;
	
	if(cost == 7.9)
	{
		setCookie("price","7.9",2);
		setCookie("signuplink","https://www.accuconference.com/signup.aspx?id=tftc");
		document.getElementById("calculator-signup").href = 'https://www.accuconference.com/signup.aspx?id=tftc';
		promo = 'tftc';
	}
	else if(cost == 6.9)
	{
		setCookie("price","6.9",2);
		setCookie("signuplink","https://www.accuconference.com/signup.aspx?id=tf69");
		document.getElementById("calculator-signup").href = 'https://www.accuconference.com/signup.aspx?id=tf69';
		promo = 'tf69';
	}
	
    document.getElementById('calculator-content').style.display = 'none';
	document.getElementById('calculator-results').style.display = 'block';
	
	if (typeof pageTracker != 'undefined') {
	    pageTracker._trackEvent('Price Calculator', 'Promo Code', promo);
	    alert('Participants: ' + String(a) + ' Duration: ' + String(b) + ' Calls per month: ' + String(c));
	    pageTracker._trackEvent('Price Calculator', 'Entered Values', 'Participants: ' + String(a) + ', Duration: ' + String(b) + ', Calls per month: ' + String(c));
	}

}

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 "";
}
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ";path=/" +
    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}
function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt * 100)) / 100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00'
              : ((mnt * 10 == Math.floor(mnt * 10)) ?
                       mnt + '0' : mnt);
}
function addCommas(nStr) {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}
/*-------------------------------------------------*/
//**  End Code for calulator 2/2010 JC  **//
