/* xml */
function LoadXMLDocumentFromString(XMLString){
	Parser=new DOMParser();
	return Parser.parseFromString(XMLString, 'text/xml');
}

/* chat */
function ChatMessageButtonSendSet(KeyUpEvent, objChatMessage, objSendChatMessageButton, ChatRoomID, ChatRoomUUID, ChatNickName, ChatNickNameColor, ChatNickNameBackgroundColor, ChatMessageColor, ChatMessageBackgroundColor){
	//alert('function SetSendChatMessageButton()');
	objSendChatMessageButton.disabled=false;
	if(objChatMessage.value=='')objSendChatMessageButton.disabled=true;
	if(KeyUpEvent.keyCode==13)SendChatMessage(objChatMessage, objSendChatMessageButton, ChatRoomID, ChatRoomUUID, ChatNickName, ChatNickNameColor, ChatNickNameBackgroundColor, ChatMessageColor, ChatMessageBackgroundColor);
}

function ChatMessageSend(objChatMessage, objSendChatMessageButton, ChatRoomID, ChatRoomUUID, ChatNickName, ChatNickNameColor, ChatNickNameBackgroundColor, ChatMessageColor, ChatMessageBackgroundColor){
	//alert('function SendChatMessage(\n	ChatRoomUUID = \''+ChatRoomUUID+'\'\n)');
	objSendChatMessageButton.disabled=true;
	//prompt('URL', './sendchatmessage.php?MainContentOnly&ChatRoomID='+ChatRoomID+'&ChatRoomUUID='+ChatRoomUUID+'&ChatMessage='+objChatMessage.value+'&ChatNickName='+ChatNickName+'&ChatNickNameColor='+ChatNickNameColor+'&ChatNickNameBackgroundColor='+ChatNickNameBackgroundColor+'&ChatMessageColor='+ChatMessageColor+'&ChatMessageBackgroundColor='+ChatMessageBackgroundColor+'');
	HTTPRequest('./chatmessagesend.php?MainContentOnly&ChatRoomID='+ChatRoomID+'&ChatRoomUUID='+ChatRoomUUID+'&ChatMessage='+objChatMessage.value+'&ChatNickName='+ChatNickName+'&ChatNickNameColor='+ChatNickNameColor+'&ChatNickNameBackgroundColor='+ChatNickNameBackgroundColor+'&ChatMessageColor='+ChatMessageColor+'&ChatMessageBackgroundColor='+ChatMessageBackgroundColor+'', 'GET', true, ChatMessageSendResponseProcess);
	objChatMessage.value='';
}

function ChatMessageSendResponseProcess(HTTPResponse){
	if(HTTPResponse!='SUCCESS')alert('function ChatMessageSendResponseProcess() = '+HTTPResponse);
}

function ChatLogUpdateResponseProcess(HTTPResponse){
	if(HTTPResponse!=''){
		Message=HTTPResponse.split('<!-- Record Separator -->');
		
		for(MessageCounter=0; MessageCounter<Message.length; MessageCounter++){
			Information=Message[MessageCounter].split('<!-- Field Separator -->');
			ChatIDLatest=Information[0];
			objChatLog=document.getElementById('ChatLog');
			ListItem = document.createElement('LI');
			ListItem.innerHTML='<span class="ChatNickNameArea" style="color: '+Information[2]+'; background-color: '+Information[3]+';">'+Information[1]+':</span> <span class="ChatChatMessageArea" style="color: '+Information[5]+'; background-color: '+Information[6]+';">'+FormatChatMessageSmiley(Information[4])+'</span>';
			objChatLog.appendChild(ListItem);
		}

		objChatLog.scrollTop = objChatLog.scrollHeight;
	}
}

function ChatMessageSmileyFormat(ChatMessage){
	SmileySymbol=new Array(':)', ';)', ':o', ':(');
	SmileyIcon=new Array('happy', 'wink', 'oh', 'cry');
	SmileyMeaning=new Array('smiling', 'winking', 'amazed', 'sad');
	
	for(SmileyCounter=0; SmileyCounter<SmileySymbol.length; SmileyCounter++){
		//alert('SmileySymbol['+SmileyCounter+'] = '+SmileySymbol[SmileyCounter]+'');
		ChatMessage=ChatMessage.replace(SmileySymbol[SmileyCounter], '<img src="./theme/default/image/icon/smiley/'+SmileyIcon[SmileyCounter]+'.gif" title="'+SmileyMeaning[SmileyCounter]+'" class="DataGrid_ColumnValue_Icon">');
	}
	
	//alert('ChatMessage = '+ChatMessage+'');
	
	return ChatMessage;
}

function ChatLogUpdate(ChatRoomID, ChatRoomUUID, ChatIDLatest){
	//alert('ChatIDLatest = '+ChatIDLatest+'');
	//prompt('URL', './checkchatlog.php?MainContentOnly&ChatRoomID='+ChatRoomID+'&ChatRoomUUID='+ChatRoomUUID+'&ChatIDLatest='+ChatIDLatest+'');
	HTTPRequest('./chatlogcheck.php?MainContentOnly&ChatRoomID='+ChatRoomID+'&ChatRoomUUID='+ChatRoomUUID+'&ChatIDLatest='+ChatIDLatest+'', 'GET', true, ChatLogUpdateResponseProcess);
}


/* systemnotification */
function UserSystemNotificationProcess(HTTPResponse){
	//alert('function CheckUserSystemNotification()');
	//alert('HTTPResponse = '+HTTPResponse+'');
	
	if(HTTPResponse!=''){
		SystemNotification=HTTPResponse.split('<!-- Record Separator -->');
		
		for(SystemNotificationCounter=0; SystemNotificationCounter<SystemNotification.length; SystemNotificationCounter++){
			ThisSystemNotification=SystemNotification[SystemNotificationCounter];
			//alert('ThisSystemNotification = '+ThisSystemNotification+'');
			
			Field=ThisSystemNotification.split('<!-- Field Separator -->');
			//alert('ThisSystemNotification = '+ThisSystemNotification+'\n\nField.length = '+Field.length+'');
			
			SystemNotificationTypeName=Field[7];
			
			if(SystemNotificationTypeName == 'Chat request'){
				Detail=Field[4].split('\n');
				
				ChatRoomID=Detail[0].split('=');
				ChatRoomID=ChatRoomID[1];
				
				ChatRoomUUID=Detail[4].split('=');
				ChatRoomUUID=ChatRoomUUID[1];
				
				UserNameRequested=Detail[2].split('=');
				UserNameRequested=UserNameRequested[1];
				
				UserSystemNotificationResponse=confirm(''+UserNameRequested+' wants to talk to you.\n\nDo you want to go to the chat room?');
				if(UserSystemNotificationResponse)ChatRoomWindow=OpenChatWindow(ChatRoomID, ChatRoomUUID, 'ChatRoomWindow');

				HTTPRequest('./usersystemnotificationacknowledge.php?MainContentOnly&UserSystemNotificationID='+Field[0]+'&UserSystemNotificationUUID='+Field[1]+'&UserSystemNotificationResponse='+UserSystemNotificationResponse+'', 'get', true, null);
			}
			
			if(SystemNotificationTypeName == 'Session timed out'){
				alert('Session timed out');
				window.location.href='./home.php';

				HTTPRequest('./usersystemnotificationacknowledge.php?MainContentOnly&UserSystemNotificationID='+Field[0]+'&UserSystemNotificationUUID='+Field[1]+'&UserSystemNotificationResponse=', 'get', true, null);
			}
		}
	}
}

function UserSystemNotificationCheck(){
	//alert('function CheckUserSystemNotification()');
	URL='./usersystemnotificationcheck.php?MainContentOnly&'+Math.floor(Math.random()*99999999);
	//prompt('URL', URL);
	HTTPRequest(URL, 'get', true, UserSystemNotificationProcess);
}


/* dateselector */
function SetDaysForDateSelector(objYear, objMonth, objDay, DaySelected){
    DaysInMonth=30;
    if(objMonth.value==1||objMonth.value==3||objMonth.value==5||objMonth.value==7||objMonth.value==8||objMonth.value==10||objMonth.value==12)DaysInMonth=31;
    
    if(objMonth.value==2){
        DaysInMonth=28;
        if(objYear.value%4==0)DaysInMonth=29;
	}
	
    objDay.options.length = 0;
    //OptionHTML='';
	for(DayCounter=1;DayCounter<=DaysInMonth;DayCounter++){
		var ThisOption = document.createElement("OPTION");
		
		ThisOption.text = DayCounter;
		ThisOption.value = DayCounter;
		if(DayCounter==DaySelected)ThisOption.selected=true;
		
		objDay.options.add(ThisOption);
	}
}

function SetDateSelectorValueToSCW(objSCW, DateSelectorBaseID, DateSeperator){
	MonthNameShort='Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
	MonthNameShort=MonthNameShort.split(',');

	objSCW.value=''+document.getElementById(DateSelectorBaseID+'_Day').value+DateSeperator+MonthNameShort[document.getElementById(DateSelectorBaseID+'_Month').value-1]+DateSeperator+document.getElementById(DateSelectorBaseID+'_Year').value+'';
}

function SetSCWValueToDateSelector(objSCW, DateSelectorBaseID, DateSeperator){
	MonthNameShort='Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
	MonthNameShort=MonthNameShort.split(',');

	DatePart=objSCW.value.split(DateSeperator);
	if(DatePart[0].substring(0, 1)==0)DatePart[0]=DatePart[0].substring(1, 2)

	document.getElementById(DateSelectorBaseID+'_Year').value=DatePart[2];
	
	for(MonthCounter=0; MonthCounter<12; MonthCounter++)if(MonthNameShort[MonthCounter]==DatePart[1])break;
	if(MonthCounter<12)document.getElementById(DateSelectorBaseID+'_Month').value=MonthCounter+1;
	
	SetDaysForDateSelector(document.getElementById(DateSelectorBaseID+'_Year'), document.getElementById(DateSelectorBaseID+'_Month'), document.getElementById(DateSelectorBaseID+'_Day'), DatePart[0]);
}

function ToggleDateSelector(DateSelectorBaseID, Enabled){
	document.getElementById(DateSelectorBaseID+'_Year').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'_Month').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'_Day').disabled=!Enabled
	document.getElementById(DateSelectorBaseID+'IconCalendar').disabled=!Enabled
}

/* validation */
function Validate_IPv4Address(IPAddress) {
    //Remember, this function will validate only Class C IP.
    //change to other IP Classes as you need
    IPAddress = IPAddress.replace( /\s/g, "") //remove spaces for checking
    var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; //regex. check for digits and in
                                          //all 4 quadrants of the IP
    if (re.test(IPAddress)) {
        //split into units with dots "."
        var parts = IPAddress.split(".");
        //if the first unit/quadrant of the IP is zero
        if (parseInt(parseFloat(parts[0])) == 0) {
            return false;
        }
        //if the fourth unit/quadrant of the IP is zero
        if (parseInt(parseFloat(parts[3])) == 0) {
            return false;
        }
        //if any part is greater than 255
        for (var i=0; i<parts.length; i++) {
            if (parseInt(parseFloat(parts[i])) > 255){
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}

function Validate_PositiveInteger(Figure){
	Valid=false;

	if(Figure>0 && parseInt(Figure)==Figure)Valid=true;
	
	return Valid;
}

function Validate_Email(EmailAddress){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	return reg.test(EmailAddress);
}

function Validate_Alphanumeric(TextToValidate){
	var reg = /^\w+$/;

	return reg.test(TextToValidate);
}

function Validate_NonNegetiveNumber(Figure){
	Valid=false;
	if(Figure>=0)Valid=true;
	
	return Valid;
}

function Validate_Numeric(Figure){
	Valid=false;
	
	return !isNaN(Figure);
}

function Validate_Number(Figure){
	Valid=false;

	if(parseInt(Figure)==Figure)Valid=true;
	
	return Valid;
}

function Validate_PositiveNumber(Figure){
	Valid=false;
	
	if(!isNaN(Figure)){
		if(Figure>0){
			Valid=true;
		}
	}
		
	return Valid;
}

/* cookie */
function SetCookie(Name, Value, ExpiryDays, Path, Domain, Secure){
	var today = new Date();
	today.setTime(today.getTime()); //Set time in milliseconds
	
	if(ExpiryDays)ExpiryDays = ExpiryDays * 1000 * 60 * 60 * 24;
	var expires_date = new Date(today.getTime() + (ExpiryDays));
	
	document.cookie = Name + "=" +escape(Value) +
	((ExpiryDays)?";expires=" + expires_date.toGMTString() : "") +
	((Path)?";path=" + Path : "") +
	((Domain)?";domain=" + Domain : "") +
	((Secure)?";secure" : "");
}

function GetCookie(Name){
	/*
		First we'll split this cookie up into name/value pairs
		Note: document.cookie only returns name=value, not the other components
	*/
	
	var a_all_cookies = document.cookie.split(';');
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; //Set boolean t/f default f

	for (i = 0; i < a_all_cookies.length; i++){
		a_temp_cookie = a_all_cookies[i].split('='); //Now we'll split apart each name=value pair
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); //And trim left/right whitespace while we're at it
		
		if(cookie_name == Name){//If the extracted name matches passed Name
			b_cookie_found = true;
			
			/*
				We need to handle case where cookie has no value but exists (no = sign, that is):
				Note that in cases where cookie is initialized but no value, null is returned
			*/
			
			if(a_temp_cookie.length > 1)cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			
			return cookie_value;
			break;
		}
		
		a_temp_cookie = null;
		cookie_name = '';
	}
	
	if(!b_cookie_found)return null;
}

function DeleteCookie(Name, Path, Domain){
	if(GetCookie(Name))document.cookie = Name + "=" +
	((Path)? ";path=" + Path : "")+
	((Domain)? ";domain=" + Domain : "")+
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


/* dhtml */
/*
	Purpose: Various functions to perform DHTML tasks
	Author: Shahriar Kabir (SKJoy2001@Yahoo.Com)
	Date : Monday, November 20, 2006
	
	Funtion list:
	
	    SetVisibilityByElement(objElement, Visibility)
	    SetVisibilityByElementID(ElementID, Visibility)
	    ToggleVisibilityByElement(objElement)
	    ToggleVisibilityByElementID(ElementID)
	    WriteHTMLByElement(objElement, NewHTML)
	    WriteHTMLByElementID(ElementID, NewHTML)
*/

function SetVisibilityByElement(objElement, Visibility){
	/*
	    Set visibility of an object or element including the contained HTML.

	    objElement (object) = Tag or object to set the visibility of
	*/
	
	if(objElement==null||objElement==undefined){
		alert('./library/dhtml.js: function SetVisibilityByElement(): objElement is null or undefined!');
	}
	else{
		if(Visibility){Visibility='';}else{Visibility='none';}
		objElement.style.display = Visibility;
	}
}

function SetVisibilityByElementID(ElementID, Visibility){
	/*
	    Same as SetVisibilityByElement() except for that it takes the ID to point to the object or element
	*/

	//alert('function SetVisibilityByElementID(ElementID = '+ElementID+', Visibility = '+Visibility+')');
	//alert(ElementID);
	//alert(document.getElementById(ElementID));
    SetVisibilityByElement(document.getElementById(ElementID), Visibility);
}

function ToggleVisibilityByElement(objElement){
	/*
	    Show or hide an object or element including the contained HTML.

	    objElement (object) = Tag or object to show or hide
	*/

    Visibility=false;
    if(objElement.style.display=='none')Visibility=true;
    SetVisibilityByElement(objElement, Visibility);
}

function ToggleVisibilityByElementID(ElementID){
	/*
	    Same as ToggleVisibilityByElement() except for that it takes the ID to point to the object or element
	*/

    ToggleVisibilityByElement(document.getElementById(ElementID));
}

function WriteHTMLByElement(objElement, NewHTML){
	/*
	    Replace the contained HTML text for a given tag or element.

	    objElement (object) = Tag or object to replace the contained HTML text for
	    NewHTML (string) = The HTML text to replace with
	*/

    objElement.innerHTML=NewHTML;
}

function WriteHTMLByElementID(ElementID, NewHTML){
	/*
	    Same as WriteHTMLByElement() except for that it takes the ID to point to the object or element
	*/

    WriteHTMLByElement(document.getElementById(ElementID), NewHTML);
}

function ToglleCheckBoxArray(objForm, CheckBoxName, CheckedState, Inverse){
	if(objForm==null||objForm==undefined){
		alert('./library/dhtml.js: function ToglleCheckBoxArray(): \'objForm\' is null or undefined!');
	}
	else{
		//alert('objForm.elements.length = '+objForm.elements.length);
		
		for(ElementCounter=0; ElementCounter<objForm.elements.length; ElementCounter++){
			if(objForm.elements[ElementCounter].type=='checkbox'){
				//alert('objForm.elements['+ElementCounter+'].name = '+objForm.elements[ElementCounter].name);
				
				if(
						objForm.elements[ElementCounter].name==CheckBoxName
					||	(
								objForm.elements[ElementCounter].name.substring(0, CheckBoxName.length)==CheckBoxName
							&&	objForm.elements[ElementCounter].name.substring(CheckBoxName.length, CheckBoxName.length+1)=='['
						)
				){
					if(Inverse){
						State=true;
						if(objForm.elements[ElementCounter].checked)State=false;
					}
					else{
						State=CheckedState;
					}
					
					//alert('Setting '+objForm.name+'.'+objForm.elements[ElementCounter].name+'.checked = '+State);
					objForm.elements[ElementCounter].checked=State;
				}
			}
		}
	}
}


/* html */
function SelectOptionAdd(objSelect, OptionValue, OptionCaption){
    objSelect.options[objSelect.options.length]=new Option(OptionCaption, OptionValue);
}

function SetNumberOfDaysInDropDown(DropDownList, DropDownListWeekDays, Month, Year){
	Month=parseFloat(Month);
	Year=parseInt(Year);

	LastDayInList=parseInt(DropDownList.options[DropDownList.options.length-1].value);
	//Make sure the list has at least 30 days
	if(LastDayInList<30){for(i=LastDayInList+1;i<31;i++)AddOptionToSelectList(DropDownList, i, i);}
	//Trim the list to 30 days
	if(LastDayInList>30){for(i=DropDownList.options.length;i>30;i--)DropDownList.options[i-1]=null;}
    LastDayInList=30;

	//Add 31th days for appropriate months
	if((Month/2)>Math.floor(Month/2) && Month<8)AddOptionToSelectList(DropDownList, 31, 31);
	if((Month/2)==Math.floor(Month/2) && Month>7)AddOptionToSelectList(DropDownList, 31, 31);

    //Check for leap year and February
    if(Month==2 && parseInt(Year/4)!=(Year/4)){
        DropDownList.options[DropDownList.options.length-1]=null;
        DropDownList.options[DropDownList.options.length-1]=null;
	    LastDayInList=28;
	}
    if(Month==2 && parseInt(Year/4)==(Year/4)){
        DropDownList.options[DropDownList.options.length-1]=null;
	    LastDayInList=29;
	}
	
	SetDayOfWeekInDropDown(DropDownListWeekDays, DropDownList.value, Month, Year);
}

function SetDayOfWeekInDropDown(DropDownList, Day, Month, Year){
	DateToEvaluate=new Date(Year, Month-1, Day, 12, 0, 0, 0);
    DropDownList.value = New_DateFormat(DateToEvaluate, 'EEEE');
}

function XMLURLToSelectOption(XMLURL, ValueColumn, CaptionColumn, objSelect, BlankValue, BlankCaption, DefaultValue){
	objSelect.options.length=0;
	SelectOptionAdd(objSelect, BlankValue, BlankCaption);
	
	XMLDoc=LoadXMLDocumentFromString(HTTPRequest(XMLURL, 'get', false, null));
	
	ValueNode=XMLDoc.getElementsByTagName(ValueColumn);
	CaptionNode=XMLDoc.getElementsByTagName(CaptionColumn);
	
	for(NodeCounter=0; NodeCounter<ValueNode.length; NodeCounter++){
		SelectOptionAdd(objSelect, ValueNode[NodeCounter].childNodes[0].nodeValue, CaptionNode[NodeCounter].childNodes[0].nodeValue);
	}
	
	objSelect.value=DefaultValue;
	
	objSelect.style.display='';
	if(ValueNode.length<1)objSelect.style.display='none';
}

function UpdateChildrenSelectOption(Entity, EntityAlias, EntityParent, CaptionColumn, DefaultValue, FormName, BlankOptionCaption){
	//alert('function UpdateChildrenSelectOption(Entity, EntityAlias, EntityParent, CaptionColumn, DefaultValue, FormName, BlankOptionCaption)');
	
	for(EntityCounter=0; EntityCounter<Entity.length; EntityCounter++){
		XMLURLToSelectOption('./?Script=XMLEntitySelect&Entity='+Entity[EntityCounter]+'&Where='+EntityAlias[EntityCounter]+'.'+EntityParent[EntityCounter]+'ID = '+document.getElementById(''+FormName+'_'+EntityParent[EntityCounter]+'ID').value+'', ''+Entity[EntityCounter]+'ID', CaptionColumn[EntityCounter], document.getElementById(''+FormName+'_'+Entity[EntityCounter]+'ID'), '0', BlankOptionCaption, DefaultValue[EntityCounter]);
	}
}


/* http */
function HTTPRequest(URL, Method, Asynchronous, CallBackFunction){
	if(window.ActiveXObject){
		HTTPObject=new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	else if(window.XMLHttpRequest){
		HTTPObject=new XMLHttpRequest();
	}
	else{
		HTTPObject=null;
	}

	if(HTTPObject!=null){
		HTTPObject.open(Method, URL, Asynchronous);
		
		if(Asynchronous){
			HTTPObject.onreadystatechange = function(){
				if(HTTPObject.readyState == 4){
					if(HTTPObject.status == 200){
						HTTPResponse=HTTPObject.responseText;
					}
					else{
						Headers=HTTPObject.getAllResponseHeaders();
						Headers=Headers.replace('\n', ', ');
						HTTPResponse='URL = '+URL+'<br>Method = '+Method+'<br>Status = '+HTTPObject.status+': '+HTTPObject.statusText+'<br>Headers = '+Headers+'';
					}
						
					if(CallBackFunction!=null)CallBackFunction(HTTPResponse);
					
					return HTTPResponse;
				}
				else{
					return;
				}
			}
		}
		
		HTTPObject.send(null);
		
		if(!Asynchronous){
			HTTPResponse=HTTPObject.responseText;
			return HTTPResponse;
		}
		else{
			return null;
		}
	}
}

/*
	Purpose: Fetch contents dynamically using HTTP protocol
	Author: Shahriar Kabir (SKJoy2001@Yahoo.Com)
	Date : Monday, November 20, 2006

	Funtion list:

	    HTTPGet(HTTPURL, UseOwnDomain)
*/

function HTTPGet(HTTPURL, UseOwnDomain){//alert(HTTPURL);
	/*
	    Implementation of AJAX to fetch the output of a given URL for HTPP GET method.

	    HTTPURL (string) = URL to navigate to for HTTP output in GET method
	    UseOwnDomain (boolean) = Will prepend current domain name part before the given url and the output will be "http://" + www.domainname.com + "/" + URL
	*/

	var pageRequest = false; //variable to hold ajax object
	/*@cc_on
	   @if (@_jscript_version >= 5)
	      try {
	      pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
	      }
	      catch (e){
	         try {
	         pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
	         }
	         catch (e2){
	         pageRequest = false
	         }
	      }
	   @end
	@*/

	if(!pageRequest && typeof XMLHttpRequest != 'undefined')pageRequest = new XMLHttpRequest();
	HTTPResponse='Couldn\'t get data!';

	if(pageRequest){ //if pageRequest is not false
	    if(UseOwnDomain)HTTPURL=''+window.location.protocol+'//'+window.location.hostname+window.location.pathname+HTTPURL;

		pageRequest.open('GET', HTTPURL, false); //get page synchronously
		pageRequest.send(null);
		//if viewing page offline or the document was successfully retrieved online (status code=2000)
		if(window.location.href.indexOf("http")==-1 || pageRequest.status==200)HTTPResponse=pageRequest.responseText;
	}

	//alert(HTTPResponse);
	return HTTPResponse;
}

function GetBrowserURL(PathOnly){
	NewURL = window.location.protocol+'//'+window.location.hostname;
	if(PathOnly){
		PathArray = window.location.pathname.split('/');
		for(i=1;i<PathArray.length;i++){
			if(i !=PathArray.length-1){
				NewURL +='/';
				NewURL +=PathArray[i];
			}
		}
		NewURL +='/';
	}
	else{
		NewURL +=window.location.pathname;
	}

	return NewURL;
}

function SetRatingStar(EntityName, EntityID, Rating, StarFile, StarFileFilled, RatingAJAXURLURL){
	for(RatingCounter=1; RatingCounter<=5; RatingCounter++){
		objStar=document.getElementById('RatingStar_'+RatingCounter+'_EntityID_'+EntityID+'');
		if(RatingCounter<=Rating)objStar.src=StarFileFilled;
		objStar.className='RatingStar';
	}
		
	RatingAJAXURLURL=RatingAJAXURLURL+'&'+EntityName+'ID='+EntityID+'&'+EntityName+'Rating='+Rating+'';
	//alert(RatingAJAXURLURL);
	
	HTTPRequest(RatingAJAXURLURL, 'get', true, null);
	
	return true;
}


/* debug */
function ToggleDebugDumpValueArea(ValueAreaID){
    ToggleVisibilityByElementID(ValueAreaID);
    ToggleVisibilityByElementID(ValueAreaID+'_ClickInfo');
    if(document.getElementById(ValueAreaID).display!='none')window.location.href='#'+ValueAreaID+'_Start'+'';
}
