// JavaScript Document

//// HTTP Request objects
var thisDomain = ".rapidfax.com"
var defaultPromoCode = "PCNWRFfs";
function getNewRequestObject()
{
    var http = null;

	try{
		http=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(b){
		try{
			http=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(c){
			http=null
		}
	}
	if(!http&&typeof XMLHttpRequest!="undefined"){
		http=new XMLHttpRequest
	}
    return http;
}
// private method for UTF-8 decoding
function utf8_decode(utftext) {
    var string = "";
    var i = 0;
    var c = c1 = c2 = 0;

    while ( i < utftext.length ) {

        c = utftext.charCodeAt(i);

        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        }
        else if((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        }
        else {
            c2 = utftext.charCodeAt(i+1);
            c3 = utftext.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }

    }

    return string;
}

// Cookies 

//Creates or overwrites exsting cookie with same name

function putCookie(name, value, domain, path, days) {
	value = escape(value);
	var pc = name + "=" + value;
	var expr;
	if (domain)
		pc += ";domain=" + domain;
	if (path)
		pc += ";path=" + path;
	if (days) {
		expr = new Date();
		expr.setTime(days * 86400000 + expr.getTime());
		pc += ";expires=" + expr.toGMTString();
	}
	document.cookie = pc;
};

// get value of a cookie.

function getCookie(name){ 
	var srch = name + "=";
	var indxPos = 0;
	while (indxPos < document.cookie.length) {
		var valueOffset = indxPos + srch.length;
		if (document.cookie.substring(indxPos, valueOffset) == srch) {
			var endIndex = document.cookie.indexOf(";", valueOffset);
			if (endIndex == -1) { // Last cookie
				endIndex = document.cookie.length;
			}
			return unescape(document.cookie.substring(valueOffset, endIndex));
		}
		indxPos=document.cookie.indexOf(" ",indxPos)+1;
		if (indxPos == 0) {
			break;
		}
	}
	return null;
}

    var mLoc = location.href;
	var isDev = false;
	var mDomain = ".rapidfax.com";
	var ssDomain = "https://secure";
	var homepage = "";
	if(mLoc.indexOf("devwww.rapidfax")>=0){
		isDev = true;
		ssDomain = "http://devsecure";
	}
	if(mLoc.indexOf("rapidfax.net")>=0){
		mDomain = ".rapidfax.net";
	}

	function signUp(pCode){
		if(!pCode){
            pCode= defaultPromoCode;
        }
		var pDomain = ssDomain+'.rapidfax.com'+'/doccorpweb/rf/rf_signup.jsp?pc='+pCode;
		if(pCode.length>0){
			window.location = pDomain;
		}
	}

	function login(){
//		var pDomain = ssDomain+'.rapidfax.com'+'/RFLogin.serv?';
		var pDomain = "/rf_login.jsp";
			window.location = pDomain;

	}



