hText = "";
hContent ="";

function load(hContent, pContent) {
	p = new String(pContent);
	pText = myReplace(p);
	
	h = new String(hContent);
	hText = myReplace(h);
	
	hFrame = "Header";
	pFrame = "Content";
	done=false;
	opacity(hFrame, 100, 0, 500);
	opacity(pFrame, 100, 0, 500);
	//setExtra();
}

function setExtra() {
	if (document.getElementById("extra").innerHTML == "") {
		changeOpac(0, "extra");
		e = new String('Explore <a href="/video.asp" target="_blank">Abbey Glen of Spanish Wells</a>, a new development on Hilton Head Island designed by KRA and offered by Southern Lifestyle Group.');
		document.getElementById("extra").innerHTML = e;
		opacity("extra", 0, 100, 500);	
	}
}

function myReplace(string) {
	string = string.replace(/&lt;\/p&gt;&lt;p&gt;/gi,"<br/><br/>");
	string = string.replace(/<\/p><p>/gi,"<br/><br/>");
	
	string = string.replace(/&lt;p&gt;/gi,"");
	string = string.replace(/<p>/gi,"");
	
	string = string.replace(/&lt;\/p&gt;/gi,"");
	string = string.replace(/<\/p>/gi,"");
	
	string = string.replace(/&apos;/gi,"'");
	
	string = string.replace(/&lt;br&gt;/gi,"<br/>");
	
	string = string.replace(/&lt;br \/&gt;/gi,"<br/>");
	
	string = string.replace(/&lt;br\/&gt;/gi,"<br/>");
	return string;
}

function get(hContent, hDiv, pContent, pDiv) {
	document.getElementById(hDiv).innerHTML = hContent;
	document.getElementById(pDiv).innerHTML = pContent;
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;
        }
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(op, id) { 
    var object = document.getElementById(id).style; 
    object.op = (op / 100); 
    object.MozOpacity = (op / 100); 
    object.KhtmlOpacity = (op / 100); 
    object.filter = "alpha(opacity=" + op + ")"; 
	if (object.op == 0 && done==false) {
		done=true;
		get(hText, hFrame, pText, pFrame);
		opacity(hFrame, 0, 100, 500);
		opacity(pFrame, 0, 100, 500);
	}
}

//for admin section
//function limitText(limitField, limitCount, limitNum) {
//	if (limitField.value.length > limitNum) {
//		limitField.value = limitField.value.substring(0, limitNum);
//	} else {
//		limitCount.value = limitNum - limitField.value.length;
//	}
//}
