var targetFadeElement;
s_hp_disableSurvey = true;
	var isIE = document.all ? true : false;

//------------------------------------------------------------------------------------------------------------------
// AJAX Calls
//------------------------------------------------------------------------------------------------------------------
function GetXMLPostObject(){
    var xmlhttp=false;
    if ( window.XMLHttpRequest){
        xmlhttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){ xmlhttp = false; } 
        }
    } 
   return xmlhttp; 
}
function fnShowCalendar(ObjectName,Left,Top){
        ObjectName = document.getElementById(ObjectName);
		window.showModalDialog('../Includes/Calendar.htm',ObjectName,'dialogWidth:220px; dialogheight:170px; dialogLeft:'+ Left +'px; dialogTop:'+ Top +'px; status:no; scroll:no; unadorned:yes; edge:raised; help:no');
}
function fnFindHostUser(ObjectName, Left, Top){
        ObjectName = document.getElementById(ObjectName);
		var findWindow = window.showModalDialog('../shared/FindUser.aspx?type=1&returnCtl=' + ObjectName.id,window.self,'dialogWidth:450px; dialogheight:500px; dialogLeft:'+ Left +'px; dialogTop:'+ Top +'px; status:no; scroll:no; unadorned:yes; edge:raised; help:no');
}
function fnFindPresenterUser(ObjectName, Left, Top){
        ObjectName = document.getElementById(ObjectName);
		var findWindow = window.showModalDialog('../shared/FindUser.aspx?type=2&returnCtl=' + ObjectName.id, window.self,'dialogWidth:450px; dialogheight:500px; dialogLeft:'+ Left +'px; dialogTop:'+ Top +'px; status:no; scroll:no; unadorned:yes; edge:raised; help:no');
}
function GetRoot(){
    var a = document.URL.split("//"); // split at protocol.
   var protocal = a[0]; 
    a = (a[1] ? a[1] : a[0]).split("/"); 
    // use last element of a; split at /
    // host is a[0]; path is a[1..(n-1)]; a[n] is page
   if ( a[1] && a[1].indexOf(".aspx") < 0 ){
        return  protocal + "//" + a[0] + "/" + a[1] + "/";
   } 
    return  protocal + "//" + a[0] + "/";
}
//------------------------------------------------------------------------------------------------------------------
// Universal method to open a js window in a pop-up fashion.
//------------------------------------------------------------------------------------------------------------------
function OpenPopUpWindow( url, title, h, w ){
    var params = "height=" + h + ",width=" + w + ",toolbar=no, menubar=no,scrollbars=no,location=no,directories=no,status=no'";
    var win = window.open( url, title, params );
   return false; 
}
function OpenPopUpSizeableWindow( url, title, h, w ){
    var params = "height=" + h + ",width=" + w + ",toolbar=no,menubar=no,scrollbars,resizable=1,location=no,directories=no,status=no";
    var win = window.open( url, title, params );
   return false; 
}
function OpenPopUpFullWindow( url, title ){
    var h = 768;
    var w = 1024;
    if ( window.screen ){  
        h = window.screen.availHeight / 1.25;
        w = window.screen.availWidth / 2; 
    }
    var params = "height=" + h + ",width=" + w + ", top=20,left=20,directories,location,menubar,toolbar,resizable";
    var win = window.open( url, title, params );
   return false; 
}
function RedirectMe(newPage){
    var prot = new String(window.location.protocol);
    var d = new String(window.location.host);
    var p = new Array();
    var path = new String();
    p = window.location.pathname.split('/');
    for ( var i = 1; i <= p.length - 1; i++){
        if ( p[i].toString().indexOf('.aspx', 0) == -1 ){
            path += "/" + p[i];
        } 
    }
    var queryParams = new Array();
    queryParams = window.location.href.split('?');
    var u = prot + "//" + d + path + "/" + newPage + "?" + queryParams[1];
    window.location.href = u;
}
//------------------------------------------------------------------------------------------------------------------
// Browser safe method of getting the requested DOM element.
//------------------------------------------------------------------------------------------------------------------
function GetElementById( id ){
	var elem = document.getElementById( id );
	if( document.getElementById ) 
		// this is the way the standards work    
		elem = document.getElementById( id );  
	else if( document.all ) 
		// this is the way old msie versions work      
		elem = document.all[id];  
	else if( document.layers ) 
		// this is the way nn4 works    
		elem = document.layers[id];  
		
	return elem	
}
function HideElement( el ){

    if ( el ){
		el.style.visibility = 'hidden';
		el.style.display = 'none';
	}
}
function ShowElement( el ){
    if ( el ){
		el.style.visibility = 'visible';
		el.style.display = '';
	}
}
function ToggleElementVisibility( elem, vis ){
	// if the style.display value is blank we try to figure it out here  
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function ToggleElementVisibility( elem ){
	// if the style.display value is blank we try to figure it out here  
	if(elem.style.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
		elem.style.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	
	elem.style.display = (elem.style.display==''||elem.style.display=='block')?'none':'block';
}
function GoHome(){
	self.close();
}
function checkLength(control, maximum) {
    var length = control.value.length;

    if (length > maximum) {
        alert('Please limit your message to ' + maximum + ' characters. There are currently ' + length + '.');
        control.value = control.value.substring(0, 255);
        return false;
    } else {
        return true;
    }
}
function ciLimit(maxLength)
{
    var ciObj=event.srcElement;
    if (ciObj.value.length==maxLength) return false;
}
												
function ciCount(civisCnt,maxLength) 
{ 
    var ciObj=event.srcElement;
    if (ciObj.value.length>maxLength*1) ciObj.value=ciObj.value.substring(0,maxLength*1);
    if (civisCnt) civisCnt.innerText=maxLength-ciObj.value.length;
}
//------------------------------------------------------------------------------------------------------------------
// Show the help container.
//------------------------------------------------------------------------------------------------------------------
function ShowHelpWindow( id ){
    var url = GetRoot() + "shared/help.aspx?ID=" + id;
    OpenPopUpSizeableWindow( url, "Help", 500, 450 )
}
function ShowHelp(xmlhttp){
	var helpContent = GetElementById( 'divHelpContent' );
     if ( xmlhttp.readyState  == 4 ) {
        if( xmlhttp.status  == 200 ) {
            helpContent.innerHTML = "";
            helpContent.innerHTML = xmlhttp.responseText;
        } else {
             helpContent.innerTEXT = "Error code " + xmlhttp.status;
        }
    }  
	var helpEl = GetElementById( 'divHelp' );
	helpEl.style.left = document.body.offsetWidth - (helpEl.clientWidth + 2);
	helpEl.style.display = "";
}

//------------------------------------------------------------------------------------------------------------------
// Asynchronous JS methods
//------------------------------------------------------------------------------------------------------------------
function GetHelpText( id, localeId ){
	var xhr = GetXMLPostObject();
	var data = "?ACTION=GETHELP&ID=" + id + "&LOCALE=" + localeId;
	//alert(data);
	xhr.onreadystatechange = function(){
		if ( xhr.readyState == 4 && xhr.readyState == 200 ){
		    ShowHelp( xhr );
		}
	}
	xhr.open("GET", "./Unprotected/AsynchRequest.aspx" + data, true); 
//	xhr.setRequestHeader("Content-type", "application/x-www-form-URLencoded");
//	xhr.setRequestHeader("Content-length", data.length);
	xhr.send(null);	
}


//------------------------------------------------------------------------------------------------------------------
// Hide the help container
//------------------------------------------------------------------------------------------------------------------
function HideHelp(){	
	var elem, vis;  
	elem = GetElementById( 'divHelp' );
	vis = elem.style;
	vis.left = document.body.offsetWidth - (elem.clientWidth + 2);
	vis.position = 'absolute';	
	vis.display = 'none';
}
//------------------------------------------------------------------------------------------------------------------
// Toggle method to show/hide the help container.
//------------------------------------------------------------------------------------------------------------------
function ToggleHelpCompatible( id, localId ){
	var elem, vis;  
	elem = GetElementById( 'divHelp' );

	vis = elem.style;
	vis.left = document.body.offsetWidth - (elem.clientWidth + 2);
	vis.position = 'absolute';
	GetHelpText( id, localId );
	ToggleElementVisibility( elem, vis );
}

//-------------------------------------------------------------------------------------------------------------//
// Content Viewing Operations
//-------------------------------------------------------------------------------------------------------------//
//------------------------------------------------------------------------------------------------------------------
// Show the content DIV.
//------------------------------------------------------------------------------------------------------------------
function ToggleVIewingContent( viewingId, selectionId ){
	var el = 	GetElementById( viewingId );
	var selectEl = GetElementById( selectionId );
	
	ToggleElementVisibility( el, el.style );
	ToggleElementVisibility( selectEl, selectEl.style );
}
function FadeViewingContentIn( viewingId, selectionId){
	targetFadeElement = GetElementById( viewingId );
	var selectEl = GetElementById( selectionId );
	
	// Hide the selection container.
	ToggleElementVisibility( selectEl, selectEl.style);
	FadeInit();		
}
//------------------------------------------------------------------------------------------------------------------
// Content Transition Code
//------------------------------------------------------------------------------------------------------------------
function FadeInit(){
	if ( targetFadeElement ){
		// Hide the element so it doesn't appear to flash in and out.
		if ( targetFadeElement.style.MozOpacity != null ){
			// Mozilla pre-CSS3 proprietary rule
			targetFadeElement.style.MozOpacity = 0;
		} else if ( targetFadeElement.style.opacity != null ){
			// CSS3 compatible
			targetFadeElement.style.opacity = 0;
		} else if ( targetFadeElement.style.filter != null ){
			// IE's proprietary filter
			targetFadeElement.style.filter = "alpha(opacity=0)";
			//targetFadeElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=0)";
		}
		ShowElement( targetFadeElement );
		window.setTimeout('FadeIn(0)', 500);
	}
}
//------------------------------------------------------------------------------------------------------------------
// Browser safe fade in mehod.  Requires a global variable in the JS
//------------------------------------------------------------------------------------------------------------------
function FadeIn( opacity ){
	if ( targetFadeElement ){
		if ( opacity <= 100 ){
			if ( targetFadeElement.style.MozOpacity != null){
				// Mozilla's pre-CSS3 proprietary rule
				targetFadeElement.style.MozOpacity = (opacity/100) - .001;
				// the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1
			} else if ( targetFadeElement.style.opacity != null ){
				// CSS3 compatible
				targetFadeElement.style.opacity = (opacity/100) - .001;
			} else if ( targetFadeElement.style.filter != null ){
				// IE's proprietary filter
				targetFadeElement.style.filter = "alpha(opacity=" + opacity + ")";
				//targetFadeElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=" + opacity + ")";
				// worth noting:  IE's opacity needs values in a range of 0 - 100, not 0.0 - 1.0
			}
			opacity += 10;
			window.status = 'Opacity set to [' + targetFadeElement.style.filter + ']';
			window.setTimeout("FadeIn(" + opacity + ")", 30);
		}
		if (opacity > 100 ){
			ClearOpacityFilter( targetFadeElement );
		}
	}

}
function ClearOpacityFilter( el ){
		if ( targetFadeElement.style.MozOpacity != null){
			// Mozilla's pre-CSS3 proprietary rule
			targetFadeElement.style.MozOpacity = 1
		} else if ( targetFadeElement.style.opacity != null ){
			// CSS3 compatible
			targetFadeElement.style.opacity = 1
		} else if ( targetFadeElement.style.filter != null ){
			targetFadeElement.style.removeAttribute('filter');
		}
}

//-----------------------------------------------------------------------------------------------------------------
//  Event Workflow Asynchronous Calls
//-----------------------------------------------------------------------------------------------
function SetEventWorkflowItemRejection( wfCode ){

	var xhr = GetXMLPostObject();
	// Code is already encoded for the URL
	var url =  GetRoot() + "Unprotected/AsynchRequest.aspx?ACTION=EVENTREJECT&PARAM=" + wfCode;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
			alert(xhr.responseText);
			window.location.href = unescape(window.location);
		}
	}
	xhr.send(null);				
}
function SetEventWorkflowItemApproval( wfCode ){
	var xhr = GetXMLPostObject();
	// Code is already encoded for the URL
	var url = "../Unprotected/AsynchRequest.aspx?ACTION=EVENTAPPROVE&PARAM=" + wfCode;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
			alert(xhr.responseText);
			window.location.href = unescape(window.location);
		}
	}
	xhr.send(null);				
}
function CheckHPVRAvailability( id ){
	var xhr = GetXMLPostObject();
	var url = "../Unprotected/AsynchRequest.aspx?ACTION=EVENTHPVRAVAILABLE&PARAM=" + id;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
		    if ( xhr.responseText != null ){
			    alert(xhr.responseText);
			   return false; 
			} else {
			   return true;
			}
		}		
	}
	xhr.send(null);	
}
function SetAttendeeApproval(id, chk, availDisplayCtl, sendConfirmBtn, eventId){
    
    //document.body.style.cursor='wait';
    if ( chk.checked == true ){
        ApproveAttendee( id );
        DecrementAttendeeAvailableSeats( availDisplayCtl );
    } else {
        RejectAttendee( id );
        IncrementAttendeeAvailableSeats( availDisplayCtl, sendConfirmBtn );
    }
    // Enable or disable the send button.
    EnableSendAttendeeConfirmationButton( sendConfirmBtn, eventId );
}
function ApproveAttendee( id ){
	var xhr = GetXMLPostObject();
	var url = "../Unprotected/AsynchRequest.aspx?ACTION=APPROVEATTENDEE&PARAM=" + id;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
		    if ( xhr.responseText != null ){
			    //alert(xhr.responseText);
			   return true; 
			} else {
			   return false;
			}
		}		
	}
	xhr.send(null);	
}
function RejectAttendee( id ){
	var xhr = GetXMLPostObject();
	var url = "../Unprotected/AsynchRequest.aspx?ACTION=REJECTATTENDEE&PARAM=" + id;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
		    if ( xhr.responseText != null ){
			    //alert(xhr.responseText);
			   return true; 
			} else {
			   return false;
			}
		}		
	}
	xhr.send(null);	
}
function EnableSendAttendeeConfirmationButton( btn, eventId ){
	var xhr = GetXMLPostObject();
	var isDisabled;
	var url = "../Unprotected/AsynchRequest.aspx?ACTION=ENABLEATTENDEEAPPROVEBTN&PARAM=" + eventId;
	xhr.open("GET", url, true); 
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status == 200 ){
		    if ( xhr.responseText != null ){
			    var btnElem = GetElementById( btn )
		        if ( xhr.responseText == "true" ){
		            if ( isIE ){ btnElem.disabled = true;} else { btnElem.disabled = 'true'; btnElem.style.color='#D3D3D3'; }
                } else {
                    if ( isIE ){ btnElem.disabled = false;} else { btnElem.disabled = 'false'; btnElem.style.color='#FFFFFF'; }
                } 
            } else {
                if ( isIE ){ btnElem.disabled = true;} else { btnElem.disabled = 'disabled'; btnElem.style.color='#D3D3D3'; }
            }
		}		
	}
	xhr.send(null);
	
}
function IncrementAttendeeAvailableSeats( displayCtrl, sendConfirmBtn ){
    var elem = GetElementById( displayCtrl );
    var currentCnts = elem.innerHTML.split('/');
    var current =  parseInt(currentCnts[0]);
    var available = currentCnts[1];
    var displayValue = ++current + "/" + available;
    elem.innerHTML = displayValue;     
}
function DecrementAttendeeAvailableSeats( displayCtrl ){
    var elem = GetElementById( displayCtrl );
    var currentCnts = elem.innerHTML.split('/');
    var current =  parseInt(currentCnts[0]);
    var available = currentCnts[1];
    var displayValue = --current + "/" + available;
    elem.innerHTML = displayValue;     
}
//-----------------------------------------------------------------------------------------------------------------
//  Access Log Asynchronous Calls
//-----------------------------------------------------------------------------------------------------------------
function RecordContentAccessLog( userid, contentid ){
	var xhr = GetXMLPostObject();
	var data = "<?xml version='1.0' encoding='UTF-8'?><xml ACTION='CONTENTACCESSLOG'><USER_ID>" + userid + "</USER_ID><CONTENT_ID>" + contentid + "</CONTENT_ID></xml>";
	alert(data);
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status != 200 && xhr.status != 304 ){
			return;
		}
	}
	xhr.open("POST", "/Unprotected/AsynchRequest.aspx", true); 
	xhr.setRequestHeader("Content-Type", "text/xml");
	xhr.setRequestHeader("Content-length", data.length);
	xhr.send(data);				
}
function RecordBoothAccessLog( userid, boothid ){
	var xhr = GetXMLPostObject();
	var data = "<?xml version='1.0' encoding='UTF-8'?><xml ACTION='BOOTHACCESSLOG'><USER_ID>" + userid + "</USER_ID><BOOTH_ID>" + boothid + "</BOOTH_ID></xml>";
	alert(data);
	xhr.onreadystatechange = function(){
		if ( xhr.readyState != 4 ) return;
		if ( xhr.status != 200 && xhr.status != 304 ){
			xhr.responseXML
		}
	}
	xhr.open("POST", "/Unprotected/AsynchRequest.aspx", true); 
	xhr.setRequestHeader("Content-Type", "text/xml");
	xhr.setRequestHeader("Content-length", data.length);
	xhr.send(data);				
}
function ShowFeedback(xmlhttp){
    var feedbackContainer = document.getElementById("divFeedback");
     if ( xmlhttp.readyState  == 4 ) {
        if( xmlhttp.status  == 200 ) {
            feedbackContainer.innerHTML = "";
            feedbackContainer.innerHTML = xmlhttp.responseText;
        } else {
             feedbackContainer.innerHTML = "Error code " + xmlhttp.status;
        }
    }  
} 
function ContentViewerRollover() {
  if (document.getElementById && document.createTextNode) {
    var tables=document.getElementsByTagName('table');
    for (var i=0;i<tables.length;i++)
    {
      if(tables[i].className=='ruler') {
        var trs=tables[i].getElementsByTagName('tr');
        for(var j=0;j<trs.length;j++)
        {
            trs[j].onmouseover=function(){this.className='ruled';return false}
            trs[j].onmouseout=function(){this.className='';return false}
        }
      }
    }
  }
}

function validation()
    {
        if (document.getElementById("ctl00_BodyPlaceHolder_txtName").value == "" )
        {
        alert('Please enter your name');
        }
         else if (document.getElementById("ctl00_BodyPlaceHolder_txtEmail").value == "")
        {
        alert('Please enter your Email Id');
        }
         else if (document.getElementById("ctl00_BodyPlaceHolder_txtEventId").value == "")
        {
        alert('Please enter Event key');
        }
        else if (document.getElementById("ctl00_BodyPlaceHolder_txtEventPassword").value == "")
        {
        alert('Password should not blank');
        }
    }
    // this function is used to check the terms CheckBox
 function checkTerm()
{
	if (document.aspnetForm.ctl00_BodyPlaceHolder_chkTerm.checked == true)
	{
		document.getElementById("ctl00_BodyPlaceHolder_btnGo").disabled = false;
	}
	else
	{
		document.getElementById("ctl00_BodyPlaceHolder_btnGo").disabled = true;
	}
}
       
 