
function showRegTable(v) {

    if (v=='workgroup') {
//        document.getElementById('workgroup').style.visibility = 'visible';
        document.getElementById('individual').style.display = 'block';
    } else {
 //       document.getElementById('workgroup').style.visibility = 'hidden';
        document.getElementById('individual').style.display = 'block';
    }
}





function resize(obj,height) {
    var h = height - 40;
    var s = document.getElementById(obj + '_shadow');
    if(s)
        s.style.height = h + 'px';
}

function getScrollHeight() {
    var y;
    if (self.pageYOffset) y = self.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop) y = document.documentElement.scrollTop;
    else if (document.body) y = document.body.scrollTop;
    return y;
}

function getWindowHeight() {
    var y;
    if (self.innerHeight) y = self.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight) y = document.documentElement.clientHeight;
    else if (document.body) y = document.body.clientHeight;
    return y;
}



function editPop(o,p) {
document.getElementById(o).style.display = 'block';
document.getElementById(p).style.display = 'none';
}
function getWindowHeight() {
    var y;
    if (self.innerHeight) y = self.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight) y = document.documentElement.clientHeight;
    else if (document.body) y = document.body.clientHeight;
    return y;
}

function getScrollHeight() {
    var y;
    if (self.pageYOffset) y = self.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop) y = document.documentElement.scrollTop;
    else if (document.body) y = document.body.scrollTop;
    return y;
}

function showGroup(obj, pre) {
    document.getElementById(pre).style.display = 'none';
    document.getElementById(obj).style.display = 'block';
}



function resize(obj,height) {
    var h = height - 40;
    var s = document.getElementById(obj + '_shadow');
    if(s)
    s.style.height = h + 'px';
}

function d_setColorSelect() {
    var cs = document.getElementById('colorSelect');
    var ct = document.getElementById('colorSelectTxt');
    if (cs.style.visibility=='hidden') {
        cs.style.visibility = 'visible';
        ct.innerHTML = '<b>Close Color</b>';
    } else {
        cs.style.visibility = 'hidden';
        ct.innerHTML = 'Color';
    }
}

function autoSug(n) {
    var obj = n.length;
    if(obj>2) {
        document.getElementById('autoSuggest').style.visibility = 'visible';
        document.getElementById('recentSearches').style.visibility = 'hidden';
        } else {
        document.getElementById('recentSearches').style.visibility = 'visible';
        document.getElementById('autoSuggest').style.visibility = 'hidden';
        }
}

function switchLoginTxt(val) {
    var i = document.getElementById('loggedin');
    var o = document.getElementById('loggedout');
    if (val=='yes') {
        i.style.display = '';
        o.style.display = 'none';
        } else {
        i.style.display = 'none';
        o.style.display = '';
        }
    }

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }

}


   window.onload = getHeader;


function popWin(div, dWidth) {
    var o = document.getElementById(div);
        if(!document.getElementById(div + '_shadow')) {
		var topHTML = new StringBuffer();
		topHTML.append('<table border="0" cellspacing="0" cellpadding="0" style=" top: 0px; left:0; margin-left:0px; z-index: 5; position:relative;" class="noAlpha" >');

		topHTML.append('<tr>');
		topHTML.append('<td width="20" height="20" align="left" valign="top" class="spr-no-repeat sprite_top_left"></td>');
		topHTML.append('<td  class="spr-repeat-x sprite_top"><span class="sprite_spacer"></span></td>');
		topHTML.append('<td width="20" height="20" align="right" valign="top"class="spr-no-repeat sprite_top_right"></td>');
		topHTML.append('</tr><tr>');
		topHTML.append('<td bgcolor="#F0F2F5" class="spr-repeat-y sprite_left">&nbsp;</td>');
		topHTML.append('<td id="').append(div).append('_AutoSuggest" class="resultM" style="width:').append(dWidth).append('px">');

		var middleHTML = o.innerHTML;

		var bottomHTML = new StringBuffer();
		bottomHTML.append('</td>');
		bottomHTML.append('<td width="20" bgcolor="#F0F2F5" style="background: url(/corp_images/x_repeat_sprite.png); background-position: -98px 0; background-repeat: repeat-y;">&nbsp;</td>');
		bottomHTML.append('</tr><tr>');
		bottomHTML.append('<td height="20" align="left" valign="bottom" class="spr-no-repeat sprite_bottom_left"></td>');
		bottomHTML.append('<td class="spr-repeat-x sprite_bottom"><span class="sprite_spacer"></span></td>');
		bottomHTML.append('<td width="20" height="20" align="right" valign="bottom" class="spr-no-repeat sprite_bottom_right"></td>');
		bottomHTML.append('</tr></table>');
		bottomHTML.append('<table border="0" cellspacing="0" cellpadding="0" class="dropShadow"><tr>');
		bottomHTML.append('<td class="resultSTL"><span class="sprite_spacer" style="height:20px; width:20px;">&nbsp;</span></td>');
		bottomHTML.append('<td class="resultST"><span class="sprite_spacer" style="height:20px; width:1px;"></span></td>');
		bottomHTML.append('<td class="resultSTR"><span class="sprite_spacer" style="height:20px; width:20px;"></span></td>');
		bottomHTML.append('</tr><tr>');
		bottomHTML.append('<td class="resultSL"><span class="sprite_spacer" style="height:20px; width:20px;"></span></td>');
		bottomHTML.append('<td class="resultSM"><span class="sprite_spacer" id="').append(div).append('_shadow" style="width:').append(dWidth).append('px;"></span></td>');
		bottomHTML.append('<td class="spr-repeat-y resultSR"><span class="sprite_spacer" style="height:20px; width:20px;"></span></td>');
		bottomHTML.append('</tr><tr>');
		bottomHTML.append('<td class="resultSBL"><span class="sprite_spacer" style="height:20px; width:20px;"></span></td>');
		bottomHTML.append('<td class="resultSB"><span class="sprite_spacer" style="height:20px; width:1px;"></span></td>');
		bottomHTML.append('<td class="resultSBR"><span class="sprite_spacer" style="height:20px; width:20px;"></span></td>');
		bottomHTML.append('</tr></table>');

		var divHTML = new StringBuffer();
		divHTML.append(topHTML).append(middleHTML).append(bottomHTML);
		o.innerHTML = divHTML.toString();
	}
}

function showGroup(obj, pre) {
    document.getElementById(pre).style.display = 'none';
    document.getElementById(obj).style.display = 'block';
    var o = document.getElementById('contactManage');
    var oHeight = o.scrollHeight;
    resize('contactManage',oHeight);
}

function confirm() {
    document.getElementById('getConfirmation').style.display = 'none';
    document.getElementById('confirmDelete').style.display = '';
    var o = document.getElementById('deleteConfirm');
    var oHeight = o.scrollHeight;
    resize('deleteConfirm',oHeight);
}

function openShareList(obj) {
 var sl = document.getElementById('shareList');
 var o = obj;
 if (o=='yes') {
        sl.style.display = 'block'
    } else {
        sl.style.display = 'none'
    }
    var i = document.getElementById('collectionManager');
    var iHeight = i.scrollHeight;
    resize('collectionManager',iHeight);
 }

function rename() {
    var i = document.getElementById('renameDiv')
    if (i.style.display=='none') i.style.display = 'block';
    else i.style.display = 'none';
    var o = document.getElementById('tagManager');
    var oHeight = o.scrollHeight;
    resize('tagManager',oHeight);
}

function renameTag(tID) {
    var i = document.getElementById('rename' + tID);
    var c = document.getElementById('tag' + tID);
    if (document.getElementById('renameDiv').style.display=='block') {
        if (i.style.display=='block') {
            i.style.display = 'none';
            c.style.display = 'block';
            } else {
            i.style.display = 'block';
            c.style.display = 'none';
            }
        }
    var o = document.getElementById('tagManager');
    var oHeight = o.scrollHeight;
    resize('tagManager',oHeight);
    }



function showConfirm(obj, des) {
document.getElementById('watch_' + obj).style.display = 'none';
document.getElementById('watch_' + des).style.display = 'block';
}

function removeWatch(r, num) {
    var o = document.getElementById(r);
    var d = document.getElementById(r + 'Confirm');
    var n = num;
    var w = document.getElementById('w1');
    if (o.style.display=='inline' && n=='1') {
        o.style.display = 'none';
        d.style.display = 'inline';
        } else {
        w.style.visibility ='hidden';
        o.style.display = 'inline';
        d.style.display = 'none';
        }
    }

function removeRow(wID) {
    var i = document.getElementById(wID);
    if (i.style.display=='block') i.style.display = 'none';
    else i.style.display = 'block';
}

function highlight(wID, wNum) {
var i = document.getElementById(wID);
var n = wNum;
if (n==1) i.style.backgroundColor = '#FFFFCC';
else i.style.backgroundColor = '';
}

function selectRow(wID) {
var i = document.getElementById(wID);
var o = document.getElementById(wID + 's');
if (i.className=='ruleBG') {
    i.className = 'ruleBGSelected';
    if (o) o.className = 'pselected';
} else {
    i.className = 'ruleBG';
    if (o) o.className = 'pselect';
}
}

function renameCollection() {
    var sc = document.getElementById('selectCol');
    var rc = document.getElementById('renameCol');
    var ri = document.getElementById('collectionName');
    if (sc.style.display=='none') {
        sc.style.display = '';
        rc.style.display = 'none';
        } else {
        sc.style.display = 'none';
        rc.style.display = '';
        ri.focus();
        ri.select();
        }
}

function editDesc(val) {
    var sd = document.getElementById('savedDescription');
    var ed = document.getElementById('editDescription');
    if (val=='yes') {
        sd.style.display = 'none';
        ed.style.display = '';
        } else {
        sd.style.display = '';
        ed.style.display = 'none';
        }
    var i = document.getElementById('collectionManager');
    var iHeight = i.scrollHeight;
    resize('collectionManager',iHeight);
}

function help(loc) {
var o = '../help/index.html?hID=' + loc;
if(document.location.href.indexOf("corp") != -1)
    o = '../help/index.html?hID=' + loc;
if(document.location.href.indexOf("overview") != -1)
    o = '../../help/index.html?hID=' + loc;
window.open(o ,"help","height=550,width=700,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
}

function getHeader() {
    if(document.location.href.indexOf(".html")!=-1 || document.location.href.indexOf("register.egnyte")!=-1  || document.location.href.indexOf("newuser.egnyte")!=-1){
        includeFooter();
		if(!typeof(AjaxFacadeCommon)=="undefined")
			AjaxFacadeCommon.generateStaticHeader(headerCallBack);
    }
}
function openTable(obj1,obj2)
{
	document.getElementById(obj1).style.display="none";
	document.getElementById(obj2).style.display="block"
	if(obj2!='registerTable')
	{
		document.getElementById('header').style.display="none";
		document.getElementById('divFooter').style.display="none";
	}
	else
	{
		document.getElementById('header').style.display="block";
		document.getElementById('divFooter').style.display="block";
	}
}
function headerCallBack(headerValue){

//	if(document.getElementById("currentPage")!=null && document.getElementById("currentPage").value== "register")
    document.getElementById("searchCap").innerHTML ="<span id='rightCapTxt'> <span id='loggedin'><a href='javascript:isUserSignedIn()' class='header'></a></span></span>";
//	else
//		document.getElementById("searchCap").innerHTML=headerValue;
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters)){
        setTimeout(function(){window.attachEvent("onload", correctPNG);}, 200);
   }
}

function isUserSignedIn(check){
    var url = "";
    if(document.getElementById("currentUser")) {
        if(check == 1)
            url = "register.do";
        else if(check == 2)
            url = "home.do";
        else if(check == 3)
            url = "logout.do";
        else if(check == 4)
            url = "egnyte_forum.do";
        else
            url = "egnyte_home.do";

        if(document.location.href.indexOf("overview") != -1)
            document.location.href = "../../" + url;
        else
            document.location.href = "../" + url;
    } else {
        if(check == 1)
            url = "register.egnyte";
        else if(check == 2)
            url = "home.do";
        else if(check == 3)
            url = "logout.do";
        else
            url = "egnyte_home.html";

        if(document.location.href.indexOf("overview") != -1)
            document.location.href = "../../" + url;
        else
            document.location.href = "../" + url;
    }

}


function includeFooter(){

    var footerPH=document.getElementById("staticFooter");
    var divFooter=document.createElement("DIV");
    divFooter.setAttribute("id","divFooter");

    var linkEgnyteHome=document.createElement("A");
    linkEgnyteHome.setAttribute("id","homefooter");
    linkEgnyteHome.href="javascript:isUserSignedIn();";
    linkEgnyteHome.className="actionLinks";
    linkEgnyteHome.innerHTML="Egnyte Home";
    var spanSpacerEH=document.createElement("SPAN");
    spanSpacerEH.setAttribute("id","spacer");
    spanSpacerEH.appendChild(document.createTextNode("\u0020"));
    divFooter.appendChild(linkEgnyteHome);
    divFooter.appendChild(spanSpacerEH);

    var linkBlog=document.createElement("A");
    linkBlog.href="http://egnyte.com/blog";
    linkBlog.className="actionLinks";
    linkBlog.innerHTML="Blog";
    var spanSpacerBlog=document.createElement("SPAN");
    spanSpacerBlog.setAttribute("id","spacer");
    spanSpacerBlog.appendChild(document.createTextNode("\u0020"));
    divFooter.appendChild(linkBlog);
    divFooter.appendChild(spanSpacerBlog);

    var linkFAQ=document.createElement("A");
    linkFAQ.href="javascript:navigateFooter('faq.html');";
    linkFAQ.className="actionLinks";
    linkFAQ.innerHTML="FAQs";
    var spanSpacerFAQ=document.createElement("SPAN");
    spanSpacerFAQ.setAttribute("id","spacer");
    spanSpacerFAQ.appendChild(document.createTextNode("\u0020"));
    divFooter.appendChild(linkFAQ);
    divFooter.appendChild(spanSpacerFAQ);
    var linkPrivacy=document.createElement("A");
    linkPrivacy.href="javascript:navigateFooter('privacy_policy.html');";
    linkPrivacy.className="actionLinks";
    linkPrivacy.innerHTML="Privacy Policy";
    var spanSpacerPriv=document.createElement("SPAN");
    spanSpacerPriv.setAttribute("id","spacer");
    spanSpacerPriv.appendChild(document.createTextNode("\u0020"));
    divFooter.appendChild(linkPrivacy);
    divFooter.appendChild(spanSpacerPriv);
    var linkTermsService=document.createElement("A");
    linkTermsService.href="javascript:navigateFooter('terms_of_service.html');";
    linkTermsService.className="actionLinks";
    linkTermsService.innerHTML="Terms of Service";
    var spanSpacerTS=document.createElement("SPAN");
    spanSpacerTS.setAttribute("id","spacer");
    spanSpacerTS.appendChild(document.createTextNode("\u0020"));
    divFooter.appendChild(linkTermsService);
    divFooter.appendChild(spanSpacerTS);
    var linkContactUs=document.createElement("A");
    linkContactUs.href="javascript:void(null);";
    linkContactUs.onclick=function(){loadContactUsTemplate();return(false);};
    linkContactUs.className="actionLinks";
    linkContactUs.innerHTML="Contact Us";
    divFooter.appendChild(linkContactUs);
    divFooter.appendChild(document.createElement("BR"));
    var text="Copyright " + entity('&copy;') + " 2005 Egnyte, Inc. All rights reserved";
    var textCopyRight=document.createTextNode(text);
    divFooter.appendChild(textCopyRight);
	if(footerPH != null)
		footerPH.appendChild(divFooter);

}


function entity(str, mode) {
    str = (str) ? str : "";
    mode = (mode) ? mode : "string";

    var e = document.createElement("div");
    e.innerHTML = str;
    if (mode == "numeric") {
        return "&#" + e.innerHTML.charCodeAt(0) + ";";
    }
    else if (mode == "utf16") {
        var un = e.innerHTML.charCodeAt(0).toString(16);
        while (un.length < 4) un = "0" + un;
        return "\\u" + un;
    }
    else return e.innerHTML;
}

function navigateFooter(pageName){

    if(document.location.href.indexOf("corp/overview") != -1){
        document.location.href="../" + pageName;
    }
    else if(document.location.href.indexOf("corp") != -1){
        document.location.href=pageName;
    }
    else{
        document.location.href="../corp/" + pageName;
    }

}
function sendWebinarInformation(){
    var firstName = document.getElementById('webdm_FName').value;
    var lastName = document.getElementById('webdm_LName').value;
    var phone = document.getElementById('webdm_Phone').value;
    var email = document.getElementById('webdm_Email').value;

	//	Get the selected demo date details
	var selectedDate = getCheckedValue(document.frmWebDemo.radDemoDates);
	if(selectedDate == ""){
		document.getElementById('contactUsErrorMessage').innerHTML = "Please select a demo date.";
        showHideContactErrorDiv('contactInfSend','400');
		Ext.get('contactInfSend').center();
        return(false);
	}
	var objSelectedDemo = document.getElementById(selectedDate);
	var accessCode = objSelectedDemo.getAttribute('accessCode');
	var demoDate = objSelectedDemo.getAttribute('demoDate');
	var demoSubject = objSelectedDemo.getAttribute('demoSubject');
	var dialNumber = objSelectedDemo.getAttribute('dialNumber');
	var demoURL = objSelectedDemo.getAttribute('demoURL');
	var meetingId = objSelectedDemo.getAttribute('meetingId');
	var audioPin = objSelectedDemo.getAttribute('audioPin');

    var comments = "";
	comments=demoDate;
    var CONTACT_US_ERROR_MSG = "First Name / Last Name / Email cannot be blank.";
    var INVALID_EMAIL_ADDRESS = "Invalid email address.";

	if (trimAll(firstName) == '' || trimAll(lastName) == '' || trimAll(email) == ''){
        document.getElementById('contactUsErrorMessage').innerHTML = "First Name / Last Name / Email cannot be blank.";
        showHideContactErrorDiv('contactInfSend','400');
		Ext.get('contactInfSend').center();
        return(false);
    }

    if(validateEmail(email)==false){
        document.getElementById('contactUsErrorMessage').innerHTML = "Invalid email address.";
        showHideContactErrorDiv('contactInfSend','400');
		Ext.get('contactInfSend').center();
        return(false);
    }

	if(phone != ""){
		phoneRegExp = /^((\+?\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
		if(!phoneRegExp.test(phone)) {
			document.getElementById('contactUsErrorMessage').innerHTML = 'Invalid phone number.';
			showHideContactErrorDiv('contactInfSend','400');
			Ext.get('contactInfSend').center();
			return(false);
		}
	}
	else{
		phone = '  ';
	}

    if(comments ==""){
        comments='  ';
    }

	showDialog('webDemoPop');
	var msgArea = document.getElementById("workMessageText");
	msgArea.innerHTML = "Sending request, please wait...";
	showPopDisplay("workMessagePop");

	egnyteUtils.loadScript("/wsgi/webinar_invite?firstName=" + egnyteUtils.URLencode(firstName) +
        "&lastName=" + egnyteUtils.URLencode(lastName) + "&email=" + egnyteUtils.URLencode(email) +
        "&comments=" + egnyteUtils.URLencode(comments) + "&phone=" + egnyteUtils.URLencode(phone) +
		"&accessCode=" + egnyteUtils.URLencode(accessCode) + "&demoDate=" + egnyteUtils.URLencode(demoDate) +
		"&demoSubject=" + egnyteUtils.URLencode(demoSubject) + "&dialNumber=" + egnyteUtils.URLencode(dialNumber) +
		"&demoURL=" + egnyteUtils.URLencode(demoURL) + "&audioPin=" + egnyteUtils.URLencode(audioPin) + "&meetingId=" + egnyteUtils.URLencode(meetingId)
        , "typeof(contactUsResponse) != 'undefined'", sendWebinarInformationCB);
}


function sendWebinarInfo(){
    var firstName = document.getElementById('demoFirstName').value;
    var lastName = document.getElementById('demoLastName').value;
    var phone = document.getElementById('demoPhoneNumber').value;
    var email = document.getElementById('demoContactUsEmail').value;

	//	Get the selected demo details
	var accessCode	= document.getElementById('hidAccessCode').value;
	var demoDate	= document.getElementById('hidDemoDate').value;
	var demoSubject = document.getElementById('hidDemoSubject').value;
	var dialNumber	= document.getElementById('hidDialNumber').value;
	var demoURL		= document.getElementById('hidDemoUrl').value;
	var meetingId	= document.getElementById('hidMeetingId').value;
	var audioPin	= document.getElementById('hidAudioPin').value;

    var comments = "";
	comments=demoDate;
    var CONTACT_US_ERROR_MSG = "First name/Last name/Email cannot be blank.";
    var INVALID_EMAIL_ADDRESS = "Invalid email address.";

	if (trimAll(firstName) == '' || trimAll(lastName) == '' || trimAll(email) == ''){
        document.getElementById('contactUsErrorMessage').innerHTML = "First name/Last name/Email cannot be blank.";
        showHideContactErrorDiv('contactInfSend','400');
        return(false);
    }

    if(validateEmail(email)==false){
        document.getElementById('contactUsErrorMessage').innerHTML = "Invalid email address.";
        showHideContactErrorDiv('contactInfSend','400');
        return(false);
    }

	if(phone != ""){
		phoneRegExp = /^((\+?\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
		if(!phoneRegExp.test(phone)) {
			document.getElementById('contactUsErrorMessage').innerHTML = 'Invalid phone number.';
			showHideContactErrorDiv('contactInfSend','400');
			return(false);
		}
	}
	else{
		phone = '  ';
	}

    if(comments ==""){
        comments='  ';
    }

	//showDialog('webDemoPop');
	showDIV('demosingup');
	var msgArea = document.getElementById("workMessageText");
	msgArea.innerHTML = "Sending request, please wait...";
	showPopDisplay("workMessagePop");

	egnyteUtils.loadScript("/wsgi/webinar_invite?firstName=" + egnyteUtils.URLencode(firstName) +
        "&lastName=" + egnyteUtils.URLencode(lastName) + "&email=" + egnyteUtils.URLencode(email) +
        "&comments=" + egnyteUtils.URLencode(comments) + "&phone=" + egnyteUtils.URLencode(phone) +
		"&accessCode=" + egnyteUtils.URLencode(accessCode) + "&demoDate=" + egnyteUtils.URLencode(demoDate) +
		"&demoSubject=" + egnyteUtils.URLencode(demoSubject) + "&dialNumber=" + egnyteUtils.URLencode(dialNumber) +
		"&demoURL=" + egnyteUtils.URLencode(demoURL) + "&audioPin=" + egnyteUtils.URLencode(audioPin) + "&meetingId=" + egnyteUtils.URLencode(meetingId)
        , "typeof(contactUsResponse) != 'undefined'", sendWebinarInformationCB);
}

function sendContactInformation(pageType){
	var domainName = "";
	var pageName = window.location.href;
  var emailAddArr = new Array();
  emailAddArr[0] = egnyteUtils.URLencode("support@egnyte.com");
  emailAddArr[1] = egnyteUtils.URLencode("helpdesk@egnyte.com");
  var email_addr = emailAddArr.join("&toAddr=");
	var email_subj = "Feedback message";
	var firstName = document.getElementById('firstName').value;
  var lastName = document.getElementById('lastName').value;
  var email = document.getElementById('contactUsEmail').value;
    //var comments = document.getElementById('comments').contentWindow.document.body.innerHTML;
	var comments = document.getElementById('comments').value;
	if(document.getElementById('hidSubDomainName') != null)
		domainName = document.getElementById('hidSubDomainName').value;

	if(pageType != null){
		if(pageType.toLowerCase() == 'static'){
			email_addr = egnyteUtils.URLencode("inquiry@egnyte.com");
			email_subj = "Egnyte Inquiry";
		}
		else if(pageType.toLowerCase() == 'product'){
			email_subj = domainName + " Support Request";
		}
	}

    var CONTACT_US_ERROR_MSG = "First name/Last name/Email cannot be blank.";
    var INVALID_EMAIL_ADDRESS = "Invalid email address.";

	if (trimAll(firstName) == '' || trimAll(lastName) == '' || trimAll(email) == ''){
        document.getElementById('contactUsErrorMessage').innerHTML = "First name/Last name/Email cannot be blank.";
        showHideContactErrorDiv('contactInfSend','400');
		if (pageName.indexOf('business_plans_and_pricing.html') > 0){
			document.getElementById("contactInfSend").style.top = "350px";
		}
        return(false);
    }

    if(validateEmail(email)==false){
        document.getElementById('contactUsErrorMessage').innerHTML = "Invalid email address.";
        showHideContactErrorDiv('contactInfSend','400');
		if (pageName.indexOf('business_plans_and_pricing.html') > 0){
			document.getElementById("contactInfSend").style.top = "350px";
		}
        return(false);
    }

    if(comments ==""){
        comments='  ';
    }
    egnyteUtils.loadScript("/wsgi/contact_us?firstName=" + egnyteUtils.URLencode(firstName) +
        "&lastName=" + egnyteUtils.URLencode(lastName) + "&email=" + egnyteUtils.URLencode(email) +
        "&comments=" + egnyteUtils.URLencode(comments) + "&domain=" + egnyteUtils.URLencode(domainName) +
		"&toAddr=" + email_addr + "&subject=" + egnyteUtils.URLencode(email_subj), "typeof(contactUsResponse) != 'undefined'", function(){sendContactInformationCB(pageType);});
    return false;
}

function sendContactInformationFromRegPage(){
    var firstName = document.getElementById('txtFName').value;
    var lastName = document.getElementById('txtLName').value;
    var email = document.getElementById('txtCEmail').value;
    //var comments = document.getElementById('comments').contentWindow.document.body.innerHTML;
	var comments = document.getElementById('txtUComments').value;

    var CONTACT_US_ERROR_MSG = "First name/Last name/Email cannot be blank.";
    var INVALID_EMAIL_ADDRESS = "Invalid email address.";

	if (trimAll(firstName) == '' || trimAll(lastName) == '' || trimAll(email) == ''){
        document.getElementById('contactUsErrorMessage').innerHTML = "First name/Last name/Email cannot be blank.";
        showHideContactErrorDiv('contactInfSend','400');
        return(false);
    }

    if(validateEmail(email)==false){
        document.getElementById('contactUsErrorMessage').innerHTML = "Invalid email address.";
        showHideContactErrorDiv('contactInfSend','400');
        return(false);
    }

    if(comments ==""){
        comments='  ';
    }
    egnyteUtils.loadScript("/wsgi/contact_us?firstName=" + egnyteUtils.URLencode(firstName) +
        "&lastName=" + egnyteUtils.URLencode(lastName) + "&email=" + egnyteUtils.URLencode(email) +
        "&comments=" + egnyteUtils.URLencode(comments), "typeof(contactUsResponse) != 'undefined'", sendContactInformationCB);
}

function sendWebinarInformationCB(){
	showPopDisplay("workMessagePop");
    var CONTACT_US_CONFIRMATION = "Thank you.  You will receive an email with a link to the Live demo.";
    document.getElementById('contactUsErrorMessage').innerHTML = CONTACT_US_CONFIRMATION;
    showHideContactErrorDiv('contactInfSend','400');
	Ext.get('contactInfSend').center();
}
function sendContactInformationCB(pageType){
	var CONTACT_US_CONFIRMATION = "Egnyte Support has been notified and will contact you shortly.";
	if(pageType != null){
		if(pageType.toLowerCase() == 'static'){
			CONTACT_US_CONFIRMATION = "Thank You. We will contact you shortly.";
		}
	}
	var pageName = window.location.href;
    document.getElementById('contactUsErrorMessage').innerHTML = CONTACT_US_CONFIRMATION;
    showHideContactErrorDiv('contactInfSend','400');
	if (pageName.indexOf('business_plans_and_pricing.html') > 0)
	{
		document.getElementById("contactInfSend").style.top = "350px";
	}
	showDIV('contact');
}


function xbDesignMode(oIFrame){
  this.mEditorDocument = null;
  this.mIFrameElement = null;
  this.mIFrameElement = oIFrame;

  // Mozilla
  if(this.mIFrameElement.contentDocument){
    this.mEditorDocument = this.mIFrameElement.contentDocument;
    this.mEditorDocument.designMode = "On";
  }
  // IE
   else {
		if(this.mIFrameElement.contentWindow != null)
		{
			this.mEditorDocument = this.mIFrameElement.contentWindow.document;
			this.mEditorDocument.designMode = "On";
			var bodyTag="<body  style=\"font: normal 11px arial, sans-serif; \">";
			this.mEditorDocument.open();
			this.mEditorDocument.write(bodyTag);
			this.mEditorDocument.close();
		}
  }

   if(this.mIFrameElement.contentWindow != null)
		this.mIFrameElement.contentWindow.focus();

}

function alertMessage(message)
{
    errorHandler(message);
}

function loadContactUsTemplate(){
    var contactUs=document.getElementById('contact');
    if(contactUs){
        showDIV('contact');
    }else{

        AjaxFacadeCommon.getContactInfoTemplate(loadContactUsTemplateCB);
    }

}


function loadContactUsTemplateCB(sTemplate){
    var contactUs=document.createElement('DIV');
    contactUs.setAttribute("id","contact");
    contactUs.style.position="absolute";
    contactUs.style.left="551px";
    contactUs.style.top="218px";
    contactUs.style.width="300px";
    contactUs.style.zIndex="9000";
    contactUs.style.visibility="hidden";
    contactUs.innerHTML=sTemplate;
    var footerPH=document.getElementById("staticFooter");
    footerPH.appendChild(contactUs);
    var contactInfo=document.getElementById('contactInfSend');
    var contactUs=document.getElementById('contact');
    if(contactUs){
        contactUs.removeChild(document.getElementById('contactInfSend'));
    }
    footerPH.appendChild(contactInfo);
    showDIV('contact');

}

function showDIV(obj) {
    var o = document.getElementById(obj);
	if(o.style.visibility){
		if (o.style.visibility=='hidden') o.style.visibility = 'visible';
		else o.style.visibility = 'hidden';
	}

    if(o.style.display){
		if (o.style.display=='none') o.style.display = 'block';
		else o.style.display = 'none';
	}

    if(obj == 'contact'){
		var fNameId = "firstName";
        if(document.getElementById('txtFName') != null)
		{
			fNameId = "txtFName";
			document.getElementById('txtFName').value="";
		}
		else if(document.getElementById('firstName') != null)
		{
			fNameId = "firstName";
			document.getElementById('firstName').value="";
		}


        if(document.getElementById('txtLName') != null)
			document.getElementById('txtLName').value="";
		else if(document.getElementById('firstName') != null)
			document.getElementById('lastName').value="";

        if(document.getElementById('txtCEmail') != null)
			document.getElementById('txtCEmail').value="";
		else if(document.getElementById('firstName') != null)
			document.getElementById('contactUsEmail').value="";

        var commentsFrame = null;
		if(document.getElementById('txtUComments') != null)
			commentsFrame = document.getElementById('txtUComments');
		else
			commentsFrame = document.getElementById('comments');

        if(o.style.visibility == 'visible'){
            commentsFrame.style.display = '';
            if(document.getElementById('ContactLink'))
                document.getElementById('ContactLink').focus();

            setTimeout(function(){xbDesignMode(commentsFrame);commentsFrame.value="";setFocus(fNameId);},200);
        }else{
            commentsFrame.style.display = 'none';
        }
    }
}

function setFocus(eleName)
{
    try{
        var ele = document.getElementById(eleName);
        if(ele != null){
            if(ele.disabled == false){
                if(eleName == 'txtSearch' && ele.value == "Enter keywords, documents, tags, or individuals"){
                    ele.value = "";
                }
                ele.focus();
            }
        }
    }
    catch(ex){
    }
}

function setMenuPositions(){
	//	Set all menu locations
	var left = 0, top = 0;

	if(Ext.get('pomenusub')!= null && Ext.get('par_pomenusub') != null){
		left = Ext.get('par_pomenusub').getLeft();
		bottom = Ext.get('par_pomenusub').getBottom();
		if(Ext.isIE){ left -=3; bottom-=2; }
		Ext.get('pomenusub').setLeft(left);
		Ext.get('pomenusub').setTop(bottom);
	}

	if(Ext.get('pomenu')!= null && Ext.get('par_pomenu') != null){
		left = Ext.get('par_pomenu').getLeft();
		bottom = Ext.get('par_pomenu').getBottom();
		if(Ext.isIE){ left -=3; bottom-=2; }
		Ext.get('pomenu').setLeft(left);
		Ext.get('pomenu').setTop(bottom);
	}

	if(Ext.get('pdmenusub')!= null && Ext.get('par_pdmenusub') != null){
		left = Ext.get('par_pdmenusub').getLeft();
		bottom = Ext.get('par_pdmenusub').getBottom();
		if(Ext.isIE){ left -=3; bottom-=2; }
		Ext.get('pdmenusub').setLeft(left);
		Ext.get('pdmenusub').setTop(bottom);
	}

	if(Ext.get('pdmenu')!= null && Ext.get('par_pdmenu') != null){
		left = Ext.get('par_pdmenu').getLeft();
		bottom = Ext.get('par_pdmenu').getBottom();
		if(Ext.isIE){ left -=3; bottom-=2; }
		Ext.get('pdmenu').setLeft(left);
		Ext.get('pdmenu').setTop(bottom);
	}

	if(Ext.get('aumenu')!= null && Ext.get('par_aumenu') != null){
		left = Ext.get('par_aumenu').getLeft();
		bottom = Ext.get('par_aumenu').getBottom();
		if(Ext.isIE){ left -=3; bottom-=2; }
		Ext.get('aumenu').setLeft(left);
		Ext.get('aumenu').setTop(bottom);
	}

	//	For new home page
	if(Ext.select('div#menu div.mid')){
		Ext.get('pomenu').setTop(102);
		Ext.get('pdmenu').setTop(102);
		Ext.get('aumenu').setTop(102);
	}
}

function trimAll(sString)
{
   try{
        return sString.trim();
    }
    catch(ex){

    }
    return sString;
}

function showHideContactErrorDiv(obj,w) {
        var width=500;
        if(w){
            width=w;
        }
        popWin(obj, width);
        var o = document.getElementById(obj);
        o.style.position = 'absolute';

        if (o.style.display=='none') {
            o.style.display = '';
            modifyPopDialogAttributes(obj);
        }
        else
            o.style.display = 'none';

        adjustParentShadowHeight(obj);

}

function adjustParentShadowHeight(obj) {
    var o = document.getElementById(obj);
    if(o) {
        var oHeight = o.scrollHeight;
        resize(obj, oHeight);
    }
}

function modifyPopDialogAttributes(obj) {

    var o = document.getElementById(obj);
    var page = '';
    if(o.getAttribute('page'))
        page = o.getAttribute('page');

    if(obj == 'datePickerError') return o;
    var oHeight = o.scrollHeight;

    resize(obj,oHeight);

    if(obj != 'unlockAlert' && obj != 'unlockConfirm' && obj != 'noCollections' && obj != 'deleteConfirm' && obj != 'confirmDelete' && obj != 'tagConfirm' && obj != 'msgboxAlert' && obj != 'template_tagConfirm' && (obj != 'genericError') && obj != 'template_global_confirm_modal'  && obj != 'confirmSave') {

        var sHeight = getScrollHeight();
        var wHeight = getWindowHeight();
        var y = ((wHeight - oHeight)/2) + sHeight;
        if (oHeight > wHeight) y = sHeight + 15;
        o.style.top = y + 'px';
    }else {
        if (document.getElementById('collectionManager') && document.getElementById('collectionManager').style.visibility == 'visible') {
            var parentDiv = document.getElementById('collectionManager');

            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 70 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';
            o.style.left = eval(pLeft) - 250 + 'px';
        }
        else if (document.getElementById('contactManager') && document.getElementById('contactManager').style.visibility == 'visible') {
            var parentDiv = document.getElementById('contactManager');

            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 20 + 'px';
            o.style.left = eval(pLeft) - 300 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';

        }
        else if (document.getElementById('tagManager') && document.getElementById('tagManager').style.visibility == 'visible') {
            var parentDiv = document.getElementById('tagManager');

            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);
            if(obj == 'genericError'){
                o.style.top = eval(pTop) + 70 + 'px';
                o.style.left = eval(pLeft) + 10 + 'px';
            }
            else {
                o.style.top = eval(pTop) + 70 + 'px';
                o.style.left = eval(pLeft) + 'px';
            }

            o.style.width = eval(pWidth) - 40 + 'px';

        }
        else if (document.getElementById('CD1') && document.getElementById('CD1').style.display == '') {

            var parentDiv = document.getElementById('CD1');
            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 60 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';
            o.style.left = eval(pLeft) - 300 + 'px';

        }
        else if (document.getElementById('TD2') && document.getElementById('TD2').style.visibility == 'visible') {

            var parentDiv = document.getElementById('TD2');
            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 40 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';
            o.style.left = eval(pLeft) - 210 + 'px';
        }
         else if (document.getElementById('TDU2') && document.getElementById('TDU2').style.visibility == 'visible') {

            var parentDiv = document.getElementById('TDU2');
            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 40 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';
            o.style.left = eval(pLeft) - 210 + 'px';
        }
        else if (document.getElementById('emailDialog') && document.getElementById('emailDialog').style.visibility == 'visible') {
            var parentDiv = document.getElementById('emailDialog');
            var pTop = parentDiv.style.top.substring(0, parentDiv.style.top.length - 2);
            var pLeft = parentDiv.style.left.substring(0, parentDiv.style.left.length - 2);
            var pWidth = parentDiv.style.width.substring(0, parentDiv.style.width.length - 2);

            o.style.top = eval(pTop) + 40 + 'px';
            o.style.width = eval(pWidth) - 40 + 'px';
            o.style.left = eval(pLeft) - 250 + 'px';
        }
        else if (page == 'setup'){
            if(navigator.appName != 'Netscape') {
                if(document.getElementById("genericError")){
                    gError = document.getElementById("genericError");
                    if(gError.getAttribute("parentPop")) {
                        var cmb = gError.getAttribute("parentPop");
                        if(document.getElementById(cmb))
                            document.getElementById(cmb).style.visibility = 'hidden';
                    }
                }
            }

            var oHeight = o.scrollHeight;
            var sHeight = getScrollHeight();
            var wHeight = getWindowHeight();

            var y = ((wHeight - oHeight)/2) + sHeight;
            if (oHeight > wHeight) y = sHeight + 15;

            o.style.top = y + 'px';
            o.style.width = '500px';
            o.style.left = '25%';
        }
        else {
            var oHeight = o.scrollHeight;
            var sHeight = getScrollHeight();
            var wHeight = getWindowHeight();

            var y = ((wHeight - oHeight)/2) + sHeight;
            if (oHeight > wHeight) y = sHeight + 15;

            o.style.top = y + 'px';
            o.style.width = '550px';
            o.style.left = '25%';
        }

    }
    return o;

}

function validateEmail(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str==''){
       return false
    }
    if (str.indexOf(at)==-1){
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
        return false
     }

     if (str.indexOf(" ")!=-1){
        return false
     }

     return true

}

function displayDIV(obj) {
	var o = document.getElementById(obj);
	if (o.style.display=='none') o.style.display = 'block';
	else o.style.display = 'none';
	}

function displayMenu(obj) {
	if(Ext.get(obj)){
		if (Ext.get(obj).isVisible()){
			Ext.get(obj).hide();
		}
		else{
			//Ext.get(obj).setX(Ext.get('par_'+obj).getX());
			//Ext.get(obj).setTop(Ext.get('par_'+obj).getBottom());
			Ext.get(obj).show();
		}
	}
}

function setMenuPosForFFonMac(left, normalLeft){
	return;
	if ('Mac' == self.navigator.platform.substring(0, 3) && self.navigator.userAgent.indexOf('Firefox') > 0){
		// this is Firefox on Mac so build that class here
		document.getElementById("aumenu").style.marginLeft = left + "px";
	}
	if(normalLeft != null){
		document.getElementById("aumenu").style.marginLeft = normalLeft + "px";
	}
}

function setMenuWidthForFFonMac(width){
	if ('Mac' == self.navigator.platform.substring(0, 3) && self.navigator.userAgent.indexOf('Firefox') > 0){
		if(document.getElementById("pomenu") != null){
			document.getElementById("pomenu").style.width = width + "px";
			//alert("pomenu width= " + document.getElementById("pomenusub").style.width);
		}
		if(document.getElementById("pomenusub") != null){
			document.getElementById("pomenusub").style.width = width + "px";
			//alert("pomenusub width= " + document.getElementById("pomenusub").style.width);
		}
	}
}
