// ----------------------------------------------------------------------// NAME: Browser Check// DESCRIPTION: Set global variables for browser compliancy// ----------------------------------------------------------------------var d, dom, ie, ie4, ie5x, moz, mac, ie5mac, op;d = document;n = navigator;na = n.appVersion;nua = n.userAgent;mac = ( na.indexOf('Mac') != -1 );if ( !d.layers ){	dom = ( d.getElementById );	op = ( nua.indexOf('Opera') != -1 );	saf = ( nua.indexOf('Safari') != -1 );	moz = ( nua.indexOf('Gecko') != -1 && !saf );	ie5x = ( d.all && dom );	ie5mac = ( mac && ie5x );}// content informationvar siteId, contentId, contentTypeId;var addCommentPostbackRefresh;var currentReturnContent = "";var smallDisplay = "";var pageNumber = "";// ----------------------------------------------------------------------// NAME: Display Toggle// DESCRIPTION: Toggle visibility on elements// ----------------------------------------------------------------------function toggleDiv(id,toggle){	document.getElementById(id).style.display = (toggle)? "block" : "none";}// ----------------------------------------------------------------------// NAME: Element Position// DESCRIPTION: Find Element position within page// ----------------------------------------------------------------------function findPopupPosition(element) {	var x,w,y,h,s;	if (document.getBoxObjectFor) { // mozilla (pc & mac)		var box = document.getBoxObjectFor(element); 		x = box.x;		w = box.width;		y = box.y;		h = box.height;		s = 3; // scrollTop;		return { x: x, y: (y+s), width: w, height: h }	/*		} else if (element.getBoundingClientRect) { // IE (pc)		var rect = element.getBoundingClientRect(); 		x = rect.left; 		w = rect.right - rect.left;		y = rect.top;		h = rect.bottom - rect.top;		s = document.body.scrollTop;		return { x: x, y: (y+s), width: w, height: h }	*/		} else { // All Other browsers		if(element.offsetParent) {			var posWidth = element.offsetWidth;			var posHeight = (saf)? element.offsetHeight+5 : element.offsetHeight;			for(var posX = 0, posY = 0; element.offsetParent; element = element.offsetParent) {				posX += element.offsetLeft;				posY += element.offsetTop;			}			return { x: posX, y: posY, width: posWidth, height: posHeight };		} else {			return { x: element.x, y: element.y, width: element.offsetWidth, height: element.offsetHeight };		}	}}function getSignInPage(id) {/* ===== create container element - if unavailable ===== */	if(!document.getElementById("commentsPopup")){	    var divContainer = document.createElement("div");		divContainer.setAttribute("id","commentsPopup");		document.body.appendChild(divContainer);	}		var processor = "/SignInCommentsPopup.aspx";	    /* ===== position and display form ===== */	var container = document.getElementById("commentsPopup");	var oPOS = findPopupPosition(id);	container.style.position = "absolute";	container.style.top = (oPOS.y + oPOS.height) + "px";	container.style.left = (oPOS.x - (300 - oPOS.width)) + "px";	container.style.display = "block";	displayPopup("loading","","commentsPopup","");    makeRequest(processor,null,processSignIn);}function processSignIn(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {		    if (frmReq.responseText.indexOf("Welcome") == -1) {		  	    displayPopup("display",frmReq.responseText,"commentsPopup","Sign In");		  	    addSubmitRollovers();		  	} else {		  	  // successful login		  	  toggleDiv("commentsPopup",false);		  	  document.getElementById("userSignIn").innerHTML = frmReq.responseText;                if (!addCommentPostbackRefresh) {                    getDynamicComments(siteId,contentId,contentTypeId);                } else {                    window.location.href="/ViewAllComments.aspx?SiteId=" + siteId + "&ContentId=" + contentId + "&ContentTypeId=" + contentTypeId;                }		  	}        } else {            displayPopup("display","There was a problem retrieving the Sign In Page.<br/>Please try again later.","commentsPopup","Alert!");                }	}}function postBackSignIn(formName){	var processor = "/SignInCommentsPopup.aspx";	var formdata = getFormData(formName);    makeRequest(processor,formdata,processSignIn);}function getRegisterPage() {	var processor = "/RegisterCommentsPopup.aspx";	    makeRequest(processor,null,processRegister);}function postBackRegistration(formName){	var processor = "/RegisterCommentsPopup.aspx";	var formdata = getFormData(formName);    makeRequest(processor,formdata,processRegister);}function processRegister(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {		    if (frmReq.responseText.indexOf("Welcome") == -1) {		  	    displayPopup("display",frmReq.responseText,"commentsPopup","Registration");		  	    addSubmitRollovers();		  	} else {		  	  // successful login		  	  toggleDiv("commentsPopup",false);		  	  document.getElementById("userSignIn").innerHTML = frmReq.responseText;                if (!addCommentPostbackRefresh) {                    getDynamicComments(siteId,contentId,contentTypeId);                } else {                    window.location.href="/ViewAllComments.aspx?SiteId=" + siteId + "&ContentId=" + contentId + "&ContentTypeId=" + contentTypeId;                }		  	  		  	}        } else {            displayPopup("display","There was a problem retrieving the Registration Page.<br/>Please try again later.","commentsPopup","Alert!");        }	}}function displayPopup(status,text,element,headerText){	var copy;	var popup;	switch(status){		case "loading" : copy = "<div class='loading'>Loading...</div>"; break;		case "display" : copy = text; break;	}	popup = "" +			"<div id='commentsDisplay'>" +			"	<div class='commentsHeader' style='width:300px;'><div class='commentsClose' onClick=\"toggleDiv('" + element + "',false);return false;\"></div>" + 			"   <div class='commentsHeaderText'>" + headerText + "</div>" +			"	</div>" +			"	<div id='commentsContent' align='center'>" + copy + "</div>" +			"</div>";	document.getElementById(element).innerHTML = popup;	document.getElementById(element).style.display = "block";	}function makeRequest(request,formdata,oncomplete) {    if (!formdata) {        formdata = "test=0";    }    	if (window.XMLHttpRequest) {        frmReq = new XMLHttpRequest();        frmReq.onreadystatechange = oncomplete;        frmReq.open("POST", request, true);        frmReq.setRequestHeader('content-type','application/x-www-form-urlencoded');        frmReq.setRequestHeader('content-length',formdata.length);        frmReq.send(formdata);    // branch for IE/Windows ActiveX version    } else if (window.ActiveXObject) {        frmReq = new ActiveXObject("Microsoft.XMLHTTP");        if (frmReq) {            frmReq.onreadystatechange = oncomplete;            frmReq.open("POST", request, true);            frmReq.setRequestHeader('content-type','application/x-www-form-urlencoded');                       frmReq.setRequestHeader('content-length',formdata.length);                    	frmReq.send(formdata);        }	}}function getFormData(formName) {	formId=document.getElementById(formName);	var postStr= '';	var first = true;	for (i = 0; i < formId.elements.length; i++) {		formElem = formId.elements[i];		switch (formElem.type) {			case 'text':			case 'password':            case 'hidden':			case 'textarea':			case 'submit':			{			    if (first) {                    postStr += formElem.name + '=' + urlEncode(formElem.value);	                first = false;			    } else {                    postStr += '&' + formElem.name + '=' + urlEncode(formElem.value);			    }			}		break;		}	}	return postStr;}function urlEncode(encodeValue){    encodeValue = escape(encodeValue);    encodeValue = encodeValue.replace(/\//g,"%2F");    encodeValue = encodeValue.replace(/\+/g,"%2B");            return encodeValue;}function saveContentInfo(sid,cid,ctid) {	siteId = sid;	contentId = cid;	contentTypeId = ctid;}function getDynamicComments(sid, cid, ctid) {    saveContentInfo(sid,cid,ctid);		var request = "/ViewPartialComments.aspx";	var formdata = "SiteId=" + sid + "&ContentTypeId=" + ctid + "&ContentId=" + cid + "&SmallDisplay=" + smallDisplay;			if (currentReturnContent != "") {	    formdata += "&ReturnPath=" + urlEncode(currentReturnContent);	}		if (pageNumber != "") {	    formdata += "&page=" + pageNumber;	}	    makeRequest(request,formdata,processPartialComments);	}function processPartialComments(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {		    document.getElementById("CommentsSection").innerHTML = frmReq.responseText;            addRollovers();		                // show the jump to link		    if (document.getElementById("userCommentsJumpTo")) {		        if (frmReq.responseText.indexOf("User Comments") != -1) {		            document.getElementById("userCommentsJumpTo").style.display = "block";		        } else {		            document.getElementById("userCommentsJumpTo").style.display = "none";		        }		    }        } else {            //document.getElementById("CommentsSection").innerHTML = frmReq.responseText;        }	}}function signOutUser() {    var request = "/SignInCommentsPopup.aspx";    var formdata = "Process=signout";        makeRequest(request,formdata,processSignOut);}function processSignOut() {	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {	        document.getElementById("userSignIn").innerHTML = frmReq.responseText;   	  	    if (!addCommentPostbackRefresh) {	  	        getDynamicComments(siteId,contentId,contentTypeId);	  	    } else {	  	        refreshLink = "/ViewAllComments.aspx?SiteId=" + siteId + "&ContentId=" + contentId + "&ContentTypeId=" + contentTypeId; 	        	  	        window.location.href = refreshLink;	  	    }        } 	}}function getAddCommentsPage(id) {/* ===== create container element - if unavailable ===== */	if(!document.getElementById("commentsPopup")){	    var divContainer = document.createElement("div");		divContainer.setAttribute("id","commentsPopup");		document.body.appendChild(divContainer);	}		var processor = "/AddCommentsPopup.aspx";	var formdata = "SiteId=" + siteId + "&ContentTypeId=" + contentTypeId + "&ContentId=" + contentId;	    /* ===== position and display form ===== */	var container = document.getElementById("commentsPopup");	var oPOS = findPopupPosition(id);	container.style.position = "absolute";	container.style.top = (oPOS.y + oPOS.height) + "px";	container.style.left = (oPOS.x - (300 - oPOS.width)) + "px";	container.style.display = "block";	displayPopup("loading","","commentsPopup","");    makeRequest(processor,formdata,processAddComment);}function processAddComment(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {	  	    displayPopup("display",frmReq.responseText,"commentsPopup","Add Comment");     	    addSubmitRollovers();        } else {            displayPopup("display","There was a problem retrieving the Add Comment Page.<br/>Please try again later.","commentsPopup","Alert!");        }	}}function postBackAddComment(formName){	var processor = "/AddCommentsPopup.aspx";	var formdata = getFormData(formName);    makeRequest(processor,formdata,processAddCommentPostback);}function processAddCommentPostback(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {	  	    toggleDiv("commentsPopup",false);	  	    if (!addCommentPostbackRefresh) {	  	        getDynamicComments(siteId,contentId,contentTypeId);	  	    } else {	  	        window.location.href="/ViewAllComments.aspx?SiteId=" + siteId + "&ContentId=" + contentId + "&ContentTypeId=" + contentTypeId;	  	    }        } else {            displayPopup("display","There was a problem saving the comment.<br/>Please try again later.","commentsPopup");        }	}}function setAddCommentPostbackRefresh(refresh){    addCommentPostbackRefresh = refresh;}function getForgotPasswordPage(id) {/* ===== create container element - if unavailable ===== */	if(!document.getElementById("commentsPopup")){	    var divContainer = document.createElement("div");		divContainer.setAttribute("id","commentsPopup");		document.body.appendChild(divContainer);	}		var processor = "/ForgotPasswordCommentsPopup.aspx";	    /* ===== position and display form ===== */	var container = document.getElementById("commentsPopup");	var oPOS = findPopupPosition(id);	container.style.position = "absolute";	container.style.top = (oPOS.y + oPOS.height) + "px";	container.style.left = (oPOS.x - (300 - oPOS.width)) + "px";	container.style.display = "block";	displayPopup("loading","","commentsPopup","");    makeRequest(processor,null,processForgotPassword);}function processForgotPassword(){	if (frmReq.readyState == 4) {		if (frmReq.status == 200) {	  	    displayPopup("display",frmReq.responseText,"commentsPopup","Forgot Password?");        } else {            displayPopup("display","There was a problem retrieving the Forgot Password Page.<br/>Please try again later.","commentsPopup","Alert!");                }	}}function postBackForgotPassword(formName){	var processor = "/ForgotPasswordCommentsPopup.aspx";	var formdata = getFormData(formName);    makeRequest(processor,formdata,processForgotPassword);}function setCurrentReturnContent(returnPath){    currentReturnContent = returnPath;}function setSmallDisplay(displayString) {    smallDisplay = displayString; }function setPageNumber(currentPageNumber) {    pageNumber = currentPageNumber;}
