var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
               && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
               && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
isIE=document.all;
var e = new Object();
var url = window.location.href;
var hostPort = url.split('index.php')[0]
var image_loading = '<img style="border:0" src='+hostPort+'images/common/loading2.gif>';

function GetXmlHttpObject(){
	var xmlHttp=null;
	try
	{
 		// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 	}
	catch (e){
	 	//Internet Explorer
	 	try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  	}
	 	catch (e){
	  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
 	}
	return xmlHttp;
}


function HS_FTCitiesPopulate(FormHandler,AllowEmpty){
    for(var k = FormHandler.city.options.length-1; k>=0; k--){
        FormHandler.city.options[k] = null;
    }
    FormHandler.city.options[0] = new Option("...loading...");
    var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {// Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {// IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
            HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
        }
    }
    self.xmlHttpReq.send("handler=geo&action=ftcities&country="+Country+"&allow_empty="+AllowEmpty);
}

function HS_PastEventsPopulate(FormHandler,AllowEmpty,DateFormat){
    for(var k = FormHandler.id.options.length-1; k>=0; k--){
        FormHandler.id.options[k] = null;
    }
    FormHandler.id.options[0] = new Option("...loading...");
    var City = FormHandler.city.options[FormHandler.city.selectedIndex].value;
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            HS_PullData(self.xmlHttpReq.responseXML,FormHandler.id,'event');
            //Fix #1417: show the search result when a city is selected in the drop down list
            FormHandler.submit();
        }
    }

    self.xmlHttpReq.send("handler=geo&action=events&city="+City+"&allow_empty="+AllowEmpty+"&date_format="+DateFormat);
}

function HS_UpcomingEventsAllowRegisterPopulate(FormHandler,AllowEmpty,DateFormat){
    for(var k = FormHandler.id.options.length-1; k>=0; k--){
        FormHandler.id.options[k] = null;
    }
    FormHandler.id.options[0] = new Option("...loading...");
    var City = FormHandler.city.options[FormHandler.city.selectedIndex].value;
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            HS_PullData(self.xmlHttpReq.responseXML,FormHandler.id,'event');
            //Fix #1417: show the search result when a city is selected in the drop down list
            FormHandler.submit();
        }
    }
    self.xmlHttpReq.send("handler=geo&action=show_upcoming_events_allow_register&city="+City+"&allow_empty="+AllowEmpty+"&date_format="+DateFormat);
}

function HS_EventsAllowOrderServicesPopulate(FormHandler,AllowEmpty,DateFormat){
    for(var k = FormHandler.event.options.length-1; k>=0; k--){
        FormHandler.event.options[k] = null;
    }
    FormHandler.event.options[0] = new Option("...loading...");
    var City = FormHandler.city.options[FormHandler.city.selectedIndex].value;
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            HS_PullData(self.xmlHttpReq.responseXML,FormHandler.event,'event');
            //Fix #1417: show the search result when a city is selected in the drop down list
            FormHandler.submit();
        }
    }

    self.xmlHttpReq.send("handler=geo&action=show_events_allow_order_services&city="+City+"&allow_empty="+AllowEmpty+"&date_format="+DateFormat);
}

function HS_EventsPopulate(FormHandler,AllowEmpty,DateFormat,ModuleType){
    for(var k = FormHandler.event.options.length-1; k>=0; k--){
        FormHandler.event.options[k] = null;
    }
    FormHandler.event.options[0] = new Option("...loading...");
    var City = FormHandler.city.options[FormHandler.city.selectedIndex].value;
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
            HS_PullData(self.xmlHttpReq.responseXML,FormHandler.event,'event');
            //Fix #1417: show the search result when a city is selected in the drop down list
            FormHandler.submit();
        }
    }
    self.xmlHttpReq.send("handler=geo&action=events&city="+City+"&allow_empty="+AllowEmpty+"&date_format="+DateFormat+"&module_type="+ModuleType);
}

function HS_PullData(XMLData,FieldHandler,ItemName){
    for(var k = FieldHandler.options.length-1; k>=0; k--){
        FieldHandler.options[k] = null;
    }
    var Items = XMLData.getElementsByTagName(ItemName);
    for(var i=0;i<Items.length;i++){
        var ItemID = Items[i].firstChild.firstChild.nodeValue;
        var ItemName = Items[i].firstChild.nextSibling.firstChild.nodeValue;
        FieldHandler.options[i] = new Option(ItemName,ItemID);
    }
}

function HS_AddItemToCart(evn_id,item_id,item_quantity){
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=concierge&action=add&evn_id="+evn_id+"&item_id="+item_id+"&item_quantity="+item_quantity);
}

function HS_ConfirmSendingBonjour(){
    var send = confirm("Do you want to send a Bonjour to this member?");
    if(send){
        return true;
    }
    return false;
}

function HS_SendBonjour(mem_id){
    document.location.href = "index.php?page=my_handshakes&action=send_back_bonjour&mem_id="+mem_id;
/*
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=bonjour&action=send&mem_id="+mem_id);
*/
}

function HS_StatesPopulate(FormHandler,AllowEmpty){

	for(var k = FormHandler.state.options.length-1; k>=0; k--){
		FormHandler.state.options[k] = null;
	}//for
	for(var k = FormHandler.city.options.length-1; k>=0; k--){
		FormHandler.city.options[k] = null;
	}//for
	FormHandler.state.options[0] = new Option("...loading...");
	FormHandler.city.options[0] = new Option("...loading...");
	var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
    	self.xmlHttpReq = new XMLHttpRequest();
	}//if
	// IE
	else if (window.ActiveXObject) {
    	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}//else if
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {

        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.state,'state');
        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
        HS_ZipcodePopulate(FormHandler);
	}//if
    }//function
	self.xmlHttpReq.send("handler=geo&action=states&country="+Country+"&allow_empty="+AllowEmpty);

}//HS_StatesPopulate

function HS_StatesPopulate_non_zipcode(FormHandler,AllowEmpty,All){
	for(var k = FormHandler.state.options.length-1; k>=0; k--){
		FormHandler.state.options[k] = null;
	}//for
	for(var k = FormHandler.city.options.length-1; k>=0; k--){
		FormHandler.city.options[k] = null;
	}//for
	FormHandler.state.options[0] = new Option("...loading...");
	FormHandler.city.options[0] = new Option("...loading...");
	var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
    	self.xmlHttpReq = new XMLHttpRequest();
	}//if
	// IE
	else if (window.ActiveXObject) {
    	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}//else if
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.state,'state');
        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.state,'state');
       //@1656 HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
       FormHandler.city.options[0] = new Option("All");
	}//if
    }//function
	self.xmlHttpReq.send("handler=geo&action=states&country="+Country+"&allow_empty="+AllowEmpty+"&all="+All);
}//HS_StatesPopulate

function HS_CitiesPopulate_non_zipcode(FormHandler,AllowEmpty,All){
	for(var k = FormHandler.city.options.length-1; k>=0; k--){
		FormHandler.city.options[k] = null;
	}//for
	FormHandler.city.options[0] = new Option("...loading...");
	var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
	var State = FormHandler.state.options[FormHandler.state.selectedIndex].value;
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
    	self.xmlHttpReq = new XMLHttpRequest();
	}//if
	// IE
	else if (window.ActiveXObject) {
    	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}//else if
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
	    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
	        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
		}//if
    }//function
	self.xmlHttpReq.send("handler=geo&action=cities&&country="+Country+"&state="+State+"&allow_empty="+AllowEmpty+"&all="+All);
}//HS_CitiesPopulate

function HS_CitiesPopulate(FormHandler,AllowEmpty){
	for(var k = FormHandler.city.options.length-1; k>=0; k--){
		FormHandler.city.options[k] = null;
	}//for
	FormHandler.city.options[0] = new Option("...loading...");
	var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
	var State = FormHandler.state.options[FormHandler.state.selectedIndex].value;
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
    	self.xmlHttpReq = new XMLHttpRequest();
	}//if
	// IE
	else if (window.ActiveXObject) {
    	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}//else if
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
	    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
	        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
	        HS_ZipcodePopulate(FormHandler);
		}//if
    }//function
	self.xmlHttpReq.send("handler=geo&action=cities&&country="+Country+"&state="+State+"&allow_empty="+AllowEmpty);
}//HS_CitiesPopulate

function HS_ZipcodePopulate(FormHandler){
	var con = FormHandler.country.options[FormHandler.country.selectedIndex].value;
	var sta = FormHandler.state.options[FormHandler.state.selectedIndex].value;
    var cty = FormHandler.city.options[FormHandler.city.selectedIndex].value;

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(FormHandler.zipcode){
            	FormHandler.zipcode.value = self.xmlHttpReq.responseText;
        	}
        }
    }
    self.xmlHttpReq.send("handler=profile&action=zipcode&country="+con+"&state="+sta+"&city="+cty);
}

/**
 * Send the member message to the registered members
 */
function message_all_member(evn_id,FormHandler){
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	alert(self.xmlHttpReq.responseText);
            pop_exit(FormHandler.subject,FormHandler.content);
        }
    }

    var subject = "";
    var content = "";
    if(FormHandler.subject){
        subject = FormHandler.subject.value;
    }
    if(FormHandler.content){
        content = FormHandler.content.value;
    }
    self.xmlHttpReq.send("handler=member_events&action=message_all_member&evn_id="+evn_id+"&subject="+subject+"&content="+content);
}

function showForm(e,id,event_id){
	if(event_id){
		document.getElementById('pic_id').value=event_id;
	}
	if(!is_ie){
	    mouseXStartPos = e.clientX + document.body.scrollLeft;
	    mouseYStartPos = e.clientY + document.body.scrollTop;
	}else{
	    mouseXStartPos = event.x + document.body.scrollLeft;
	    mouseYStartPos = event.y + document.body.scrollTop;
	}
    element = document.getElementById(id);
   	if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
    element.style.position  = "absolute";
    element.style.visibility = "visible";
    element.style.display = "";
		element.focus=true;
		if(element != null)	{
			element.style.left = mouseXStartPos + 20;
			element.style.top = mouseYStartPos;
}
	}
}

function showFormEmailToFriend(e,id,deltaleft,deltatop){
    if(!is_ie){
        mouseXStartPos = e.clientX + document.body.scrollLeft;
        mouseYStartPos = e.clientY + document.body.scrollTop;
    }
    else{
        mouseXStartPos = event.x + document.body.scrollLeft;
        mouseYStartPos = event.y + document.body.scrollTop;
    }
    element = document.getElementById(id);
    if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
        element.style.position  = "absolute";
        element.style.visibility = "visible";
        element.style.display = "";
        element.focus=true;
        if(element != null){
            element.style.left = mouseXStartPos + deltaleft;
            element.style.top = mouseYStartPos + deltatop;
        }
    }
}

function exitForm(id,FormHandler){
    element = document.getElementById(id);
    element.style.display = "none";
    FormHandler.comment.value = "";
    FormHandler.email_addresses.value = "";
}

function exitMailCityGuide(id,FormHandler){
    element = document.getElementById(id);
    element.style.display = "none";
    FormHandler.message.value = "";
}

function closePage(id){
    element = document.getElementById(id);
    element.style.display = "none";
}

function send_email(FormHandler,event_pic_id,event_id,emails,comment,style){
    if(emails.length == 0){
        alert("Email is required.");
    }
    else if(comment.length == 0){
        alert("Comment is required.");
    }
    else{
        var xmlHttpReq = false;
        var self = this;

        if(window.XMLHttpRequest){//Mozilla/Safari
            self.xmlHttpReq = new XMLHttpRequest();
        }
        else if(window.ActiveXObject) {//IE
            self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        self.xmlHttpReq.open('POST', "index.php", true);
        self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        self.xmlHttpReq.onreadystatechange = function(){
            if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
                alert(self.xmlHttpReq.responseText);

                element = document.getElementById('popup_email');
                element.style.display = "none";
                FormHandler.comment.value = "";
                FormHandler.email_addresses.value = "";

				// Google Analytics tracking
				if(pageTracker){
					pageTracker._trackPageview();
					// debug
					// alert("URL tracked");
				}

				/*
				 * Here's the a trick for AJAX-based call of Quantcast
				 */
				var objXmlHttp_qoptions = null;
				try{objXmlHttp_qoptions = new XMLHttpRequest();}
				catch(e){
					try{objXmlHttp_qoptions = new ActiveXObject("Msxml2.XMLHTTP");}
					catch(e){objXmlHttp_qoptions = new ActiveXObject("Microsoft.XMLHTTP");}
				}
				objXmlHttp_qoptions.onreadystatechange = function() {
					if(objXmlHttp_qoptions.readyState == 4){
						strResultValue = '' + objXmlHttp_qoptions.responseText;
						// Execute
						eval(strResultValue);
						if(_qoptions){
							var objXmlHttp_quantcast = null;
							try{objXmlHttp_quantcast = new XMLHttpRequest();}
							catch(e){
								try{objXmlHttp_quantcast = new ActiveXObject("Msxml2.XMLHTTP");}
								catch(e){objXmlHttp_quantcast = new ActiveXObject("Microsoft.XMLHTTP");}
							}
							objXmlHttp_quantcast.onreadystatechange = function() {
								if(objXmlHttp_quantcast.readyState == 4){
									strResultValue = '' + objXmlHttp_quantcast.responseText;
									// Execute
									eval(strResultValue);
								}
							}
							objXmlHttp_quantcast.open("GET","./jscript/quantcast/quant.js",true);
							objXmlHttp_quantcast.send("");
						}
					}
				}
				objXmlHttp_qoptions.open("GET","./jscript/quantcast/quant_qoptions.js",true);
				objXmlHttp_qoptions.send("");

            }
        }
        if(style == 'pictures_contests'){
            self.xmlHttpReq.send("handler=events&action=send_mail&style="+style+"&email="+emails+"&comment="+comment+"&event_pic_id="+event_pic_id+"&event_id="+event_id);
        }
        if(style == 'event_pictures'){
            self.xmlHttpReq.send("handler=events&action=send_mail&style="+style+"&email="+emails+"&comment="+comment+"&event_pic_id="+event_pic_id+"&gal_id="+event_id);
        }
        else{
            self.xmlHttpReq.send("handler=events&action=send_mail&style="+style+"&email="+emails+"&comment="+comment+"&event_pic_id="+event_pic_id);
        }
    }
}

var nextHiddenIndex = 2;

function AddMessageMore(number_of_message){
    document.getElementById("addTo"+nextHiddenIndex).style.display = "";
    if(nextHiddenIndex==number_of_message){
        document.getElementById("addMore").style.display = "none";
    }
    nextHiddenIndex++;
}

var nextImageIndex = 2;
var ImageDisplay = 2;
var ImagesRemove = 0;

function AddImageMore(number_of_message){
	if(ImagesRemove>0){
		for(var i=2;i<=nextImageIndex;i++){
			if(document.getElementById("addTo"+i).style.display == "none"){
				document.getElementById("addTo"+i).style.display = "";
				ImagesRemove--;
				ImageDisplay++;
				break;
			}
		}
	}
	else{
		document.getElementById("addTo"+nextImageIndex).style.display = "";
		if(nextImageIndex<number_of_message){
			nextImageIndex++;
		}

		if(ImageDisplay==number_of_message){
	        document.getElementById("addMore").style.display = "none";
	    }
		else{
			if(ImageDisplay<number_of_message){
				ImageDisplay++;
			}
		}
	}
}

function RemoveImage(index,number_of_message){
	if(document.getElementById("file"+index).value==""){
		document.getElementById("addTo"+index).style.display = "none";
	}
	ImageDisplay--;
    ImagesRemove++;
    if(ImageDisplay<number_of_message){
		document.getElementById("addMore").style.display = "";
	}
}

function lookup(inputString,id){
    if(inputString.length == 0){
        $('#suggestions').hide();//hide the suggestion box.
    }
    else{
        $.get("index.php?page=mailbox_recipient&action=search_email&id="+id,{queryString: ""+inputString+""}, function(data){
            if(data.length >0){
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
        });

    }
}

function lookup2(inputString,id,suggestions,autoSuggestionsList,id_hid){

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', MainURL + "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
	     if(inputString.length == 0){
	        document.getElementById(suggestions).style.display = "none";
	    }else{
			if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
				document.getElementById(suggestions).style.display = "";

		    	document.getElementById(autoSuggestionsList).innerHTML = self.xmlHttpReq.responseText;
				if(!self.xmlHttpReq.responseText){
					document.getElementById(suggestions).style.display = "none";
				}
			    }
		}
    }

    self.xmlHttpReq.send("handler=mailbox&action=search_email&id="+id+"&suggestions="+suggestions+"&name="+inputString+"&id_hid="+id_hid);
}

function fill2(thisValue,id,suggestions,id_hid,mem_id){
	document.getElementById(id_hid).value = mem_id ;
    $('#'+id).val(thisValue);
//    setTimeout("document.getElementById("+suggestions+").style.display = 'none';", 200);
    setTimeout("$('#"+suggestions+"').hide();", 200);
}

function fill_member(thisValue,id,mem_id){
	document.getElementById("id_hidden").value = mem_id ;
    $('#'+id).val(thisValue);
    setTimeout("$('#suggestions').hide();", 200);
}

function fill(thisValue,id){
    $('#'+id).val(thisValue);
    setTimeout("$('#suggestions').hide();", 200);
}



	function lookup_block(inputString,id) {
//alert(id);
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
		$.get("index.php?handler=privacy_email&action=search_mem_id&id="+id,{queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});

		}
	} // lookup

	function un_block(blocked_id){
//alert(blocked_id);
	    var xmlHttpReq = false;
	    var self = this;

	    if(window.XMLHttpRequest){//Mozilla/Safari
	        self.xmlHttpReq = new XMLHttpRequest();
	    }
	    else if(window.ActiveXObject) {//IE
	        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq.open('POST', "index.php", true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	document.getElementById("blocked").innerHTML = self.xmlHttpReq.responseText;
    	    }
	    }

	    self.xmlHttpReq.send("handler=privacy_email&action=un_block&blocked_id="+blocked_id);
	}

	function block_member(blocked_id,name){

	    var xmlHttpReq = false;
	    var self = this;

	    if(window.XMLHttpRequest){//Mozilla/Safari
	        self.xmlHttpReq = new XMLHttpRequest();
	    }
	    else if(window.ActiveXObject) {//IE
	        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq.open('POST', "index.php", true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	document.getElementById("blocked").innerHTML = self.xmlHttpReq.responseText;
        	document.getElementById("id_hidden").value = "";
    	    }
	    }

	    self.xmlHttpReq.send("handler=privacy_email&action=block_member&blocked_id="+blocked_id+"&name="+name);
	}

function submit_privacy(FormHandler){
	var allow = FormHandler.allow_all_members.checked;
	var disable = FormHandler.disable_tag.checked;
	var show = FormHandler.show_registered_for.checked;
	var hide_status = FormHandler.hide_status.checked;
	//@1510
	var allow_glass_of_champagne = FormHandler.allow_glass_of_champagne.checked;

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=privacy_email&action=submit_privacy&allow="+allow+"&disable="+disable+"&show="+show+"&hide_status="+hide_status+"&allow_glass_of_champagne="+allow_glass_of_champagne);
}

function submit_email(FormHandler){
	//1572 (Remove new_event) var new_event = FormHandler.new_event.checked;
	var new_mm = FormHandler.new_mm.checked;
	var friend_req = FormHandler.friend_req.checked;
	var new_comment = FormHandler.new_comment.checked;
	var friend_tag = FormHandler.friend_tag.checked;

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    //1572 (Remove new_event) self.xmlHttpReq.send("handler=privacy_email&action=submit_email&new_event="+new_event+"&new_mm="+new_mm+"&friend_req="+friend_req+"&new_comment="+new_comment+"&friend_tag="+friend_tag);
    self.xmlHttpReq.send("handler=privacy_email&action=submit_email&new_mm="+new_mm+"&friend_req="+friend_req+"&new_comment="+new_comment+"&friend_tag="+friend_tag);
}

function submit_pass(FormHandler){
	var old_pass = FormHandler.old_pass.value;
	var pw1 = FormHandler.new_pass.value;
	var pw2 = FormHandler.re_new_pass.value;
	var tmp = 0;
	if(FormHandler.tmp){
		tmp = FormHandler.tmp.value;
	}

	if(old_pass == '') {
		alert('Please enter your old password.');
		FormHandler.old_pass.focus();
		return false;
	}

	if(pw1.length < 6){
		alert('The password should be at least 6 characters long.');
		FormHandler.new_pass.focus();
		return false;
	}
	if (pw1 == '' || pw2 == '') {
		alert('Please type new password in both text boxes.');
		FormHandler.new_pass.focus();
		return false;
	}

	if (pw1 != pw2) {
		alert ("The passwords you typed do not match. Type the new password in both text boxes.");
		FormHandler.new_pass.focus();
		return false;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		if(self.xmlHttpReq.responseText == '1')
       			alert("Old password is incorrect. Letters in password must be typed using the correct case.");
       		else{
       			alert("Your password has been changed. Please login again.");
   		 		document.location.href="index.php?handler=login&action=do_logout";
   			}
        }
    }
    self.xmlHttpReq.send("handler=privacy_email&action=submit_pass&new_pass="+pw1+"&old_pass="+old_pass+"&tmp="+tmp);
}

function submit_journal(FormHandler){
	var my_quantity = FormHandler.my_quantity.value;
	var my_homepage = FormHandler.my_homepage.checked;

	if(my_quantity == '' || my_quantity == '0') {
		alert('Please enter the Number of news items to show in my member profile.');
		FormHandler.my_quantity.focus();
		return false;
	}

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }

    self.xmlHttpReq.send("handler=privacy_email&action=submit_journal&my_quantity="+my_quantity+"&my_homepage="+my_homepage);
}

function send_report(module,param,action){

	var strConfirmQuestion = "";

	strConfirmQuestion += "Are you sure you would like to report this ";
	switch(module){
		case "forum":
			switch(action){
				case "report":
					strConfirmQuestion += "Discussion";
				break;
				case "report_post":
				    strConfirmQuestion += "Reply";
				break;
			}
		break;
		case "classifieds":
        	strConfirmQuestion += "Classified";
		break;
		case "city":
            strConfirmQuestion += "Review";
		break;
	}
	strConfirmQuestion += " an adminsitrator?";

	if(!confirm(strConfirmQuestion)){
		return;
	}

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler="+module+"&action="+action+"&"+param);
}

function send_report_picture_contest(module,event_id,photo_id,action){

    var xmlHttpReq = false;
    var self = this;
	var param ="&event_id="+event_id+"&evn_pic="+photo_id;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler="+module+"&action="+action+"&"+param);
}



function send_message(FormHandler,mess,city,category){
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
		   FormHandler.message.value = '';
        }
    }
    self.xmlHttpReq.send("handler=city&action=send_message&message="+mess+"&city="+city+"&category="+category);
}

function disable_button(checked,id_button){
	if (checked==true){
		document.getElementById(id_button).disabled = false;
	}
	else{
		document.getElementById(id_button).disabled = true;
	}
}
function HS_ConvertNumber(FormHandler){
//	alert(FormHandler.salary.value);
//	alert(num);
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            FormHandler.value = self.xmlHttpReq.responseText;
//            alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=employments&action=convert_number_format&num="+FormHandler.value);
}

function check_require_field_pro(i){

	//var a = document.forms[i].elements["company"].value;
    //var b = document.forms[i].elements["title"].value;
	
	//alert(document.getElementById("company").value);
	
	var a = document.forms["pro_info_add"].company.value;
	var b = document.forms["pro_info_add"].title.value;

	if(!a.length){
		alert("Company is require field");
		return;
	}
	if(!b.length){
		alert("Position is require field");
		return;
	}
	
    document.forms["pro_info_add"].submit();
}

function check_require_field_edu(i){
		var a = document.forms["edu_info_add"].elements["sch_name"].value;

        if(!a.length){
        	alert("School name is require field");
			return;
		}
    document.forms["edu_info_add"].submit();
}

function check_require_field_private_info(){
		var email = document.forms["private_information"].elements["email"].value;
		/*
		var home_phone = document.forms[0].elements["home_phone"].value;
		var office_phone = document.forms[0].elements["office_phone"].value;
		var cell_phone = document.forms[0].elements["cell_phone"].value;
		var address_line1 = document.forms[0].elements["address_line1"].value;
		*/
		var zipcode = document.forms["private_information"].elements["zipcode"].value;

        if(!email.length){
        	alert("Email is require field");
			return;
		}
		/*
		if(!home_phone.length){
        	alert("Home Phone is require field");
			return;
		}
		if(!office_phone.length){
        	alert("Work Phone is require field");
			return;
		}
		if(!cell_phone.length){
        	alert("Mobile Phone is require field");
			return;
		}
		if(!address_line1.length){
        	alert("Street Address is require field");
			return;
		}
		*/
		if(!zipcode.length){
        	alert("Zipcode is require field");
			return;
		}

    document.forms["private_information"].submit();
}

function agree_send_invite(){
		var a = document.forms[0].elements["emails"].value;

        if(!a.length){
        	alert("Email is require field");
			return;
		}
		else{
			alert("Invitation will be sent");
		}
    document.forms[0].submit();
}

function ConvertPhoneNumber(FormHandler){
//	alert(FormHandler.salary.value);
//	alert(num);
    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
            FormHandler.value = self.xmlHttpReq.responseText;
//            alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=profile&action=convert_phone_number_format&num="+FormHandler.value);
}

function get_position_club(e,clb_id){

if(!is_ie){
    mouseXStartPos = e.clientX + document.body.scrollLeft;
    mouseYStartPos = e.clientY + document.body.scrollTop;
  }else{
    mouseXStartPos = event.x + document.body.scrollLeft;
    mouseYStartPos = event.y + document.body.scrollTop;
	}
	var view   = document.getElementById('send_suggestion');
	var clb_id = document.getElementById('clb_id').value = clb_id ;

	document.getElementById("subject").value="Join this group on FT!";
	document.getElementById("content_invitation").value="";
	//document.getElementById("message").innerHTML="";

	if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
		view.style.display="";
		view.focus=true;
		if(view != null)	{
			view.style.left = mouseXStartPos-35;
			view.style.top = mouseYStartPos-35;
		}
	}
}
function hidden_send_suggestion(){

	var view = document.getElementById('send_suggestion');
	document.getElementById("message").innerHTML="";
	view.style.display="none";

}

function invitations_club(){
	xmlHttp=GetXmlHttpObject();
	var subject = document.getElementById('subject').value;
	var content = document.getElementById('content_invitation').value;
	var clb_id = document.getElementById('clb_id').value;
	var to_id = document.getElementById('id_hidden1').value;
	var email = document.getElementById('eml1').value;

	var xmlHttpReq = false;
    var self = this;

	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(content.length <1700){
		if(subject.length < 1){
			//@1354
			subject = "None";
		}
	}
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(self.xmlHttpReq.responseText == '1'){
				alert('Your invitation has been sent');
				document.getElementById('content_invitation').value = '';
				document.getElementById('clb_id').value = '';
				document.getElementById('id_hidden1').value = '';
				document.getElementById('eml1').value = '';
				element = document.getElementById("send_suggestion");
			    element.style.display = "none";
			}
       		else{
       			alert("This member's name doesn't exist");
   			}
        }
    }
    self.xmlHttpReq.send("handler=clubs&action=invitation_club&clb_id="+clb_id+"&sub="+subject+"&body="+content+"&to_id="+to_id+"&name="+email);
}
/**
	Search by Category for Discussion
*/
function search_by_category_1(frm_id){
	if(frm_id){
		document.forum_qsearch.category.value = frm_id;
		document.forum_qsearch.submit();
	}
}

/**
	Search by Category for My Discussion
*/
function search_by_category_2(frm_id){
	if(frm_id){
		document.forum_my_discussion.category.value = frm_id;
		document.forum_my_discussion.submit();
	}
}

/**
	Search by Category for Classifieds
*/
function search_by_category_3(category){
	if(category){
		document.classifieds_search.category.value = category;
		document.classifieds_search.submit();
	}
}
/**
	Search by Industry for Career
*/
function search_by_category_4(ind_id,FormHandler){
	if(ind_id){
		FormHandler.industry_id.value = ind_id;
		FormHandler.submit();
	}
}

function submit_decline(FormHandler){
	xmlHttp=GetXmlHttpObject();

	var inv_id = FormHandler.inv_id.value;

	var xmlHttpReq = false;
    var self = this;

	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(self.xmlHttpReq.responseText == '1'){
				element = document.getElementById("content1");
			    element.style.display = "none";
				element = document.getElementById("content2");
			    element.style.display = "";
				element = document.getElementById("yes_no_button");
			    element.style.display = "none";
			}
        }
    }
    self.xmlHttpReq.send("handler=featured&action=decline&inv_id="+inv_id);
}

function cancel_decline(FormHandler){
	var inv_id = FormHandler.inv_id.value;
	document.location.href = "index.php?page=member_registration&inv_id="+inv_id;
}
function check_submit(flag){
	var a = document.getElementById("con1").checked;
	var b = document.getElementById("con2").checked;

	if ((a==true)&&(b==true)){
		if(flag==1){
			document.mem_reg5.submit();
		}
		else{
			document.pro_picture.submit();
		}
	}
	else{
		alert('Please check both cells to be able to upload a profile picture');
	}
}
function HS_ViewPhotoNext(alb_id,limit_pic,status){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0];
	var offset = document.getElementById("offset").value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}
 	if(offset.length < 1){
		offset=0;
	}
	if(status == 'next'){
		if(offset >= limit_pic-1){
			document.getElementById("offset").value=limit_pic-1
		}
		else{
			document.getElementById("offset").value=parseInt(offset)+1;
		}
	}
	if(status == 'prev'){
		if(offset <= 0){
			document.getElementById("offset").value=0;
		}
		else{
			document.getElementById("offset").value=parseInt(offset)-1;
		}
	}
	offset = document.getElementById("offset").value;
	var url="index.php?page=photos&section=album&action=photo_view_slide"
	url=url+"&alb_id="+alb_id+"&offset="+offset+"&limit_pic="+limit_pic+"&t="+new Date().getTime();
	xmlHttp.onreadystatechange=view_photo
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function view_photo(){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0]
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("images_pic").innerHTML=xmlHttp.responseText;
 	}
}



function HS_ViewClubPhotoNext(clb_id,limit_pic,status){

	var url = window.location.href;
	var hostPort = url.split('index.php')[0];
	var offset = document.getElementById("offset").value;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}
 	if(offset.length < 1){
		offset=0;
	}
	if(status == 'next'){
		if(offset >= limit_pic-1){
			document.getElementById("offset").value=limit_pic-1
		}
		else{
			document.getElementById("offset").value=parseInt(offset)+1;
		}
	}
	if(status == 'prev'){
		if(offset <= 0){
			document.getElementById("offset").value=0;
		}
		else{
			document.getElementById("offset").value=parseInt(offset)-1;
		}
	}
	offset = document.getElementById("offset").value;
	var url="index.php?page=clubs&section=photos&action=photo_club_slide"
	url=url+"&clb_id="+clb_id+"&offset="+offset+"&limit_pic="+limit_pic+"&t="+new Date().getTime();

	xmlHttp.onreadystatechange=view_club_photo
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}
function view_club_photo(){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0]
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("images_pic").innerHTML=xmlHttp.responseText;
 	}
}




function view_city_ft_team(e,form_view){

	var els = document.getElementsByName("ft-popup[]");
	
	for(i=0;i<els.length;i++)
	{
		//city_ft_team2
		var ft_team_popup = document.getElementById('city_ft_team'+i);
		ft_team_popup.style.display="none";
	}

	var ft_team = document.getElementById(form_view);

	if(!is_ie){
	    mouseXStartPos = e.clientX + document.body.scrollLeft;
	    mouseYStartPos = e.clientY + document.body.scrollTop;
  	}else{
	    mouseXStartPos = event.x + document.body.scrollLeft;
	    mouseYStartPos = event.y + document.body.scrollTop;
	}


	//document.getElementById("message").innerHTML="";

	if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
	ft_team.style.display="";
		//ft_team.focus=true;
		if(ft_team != null)	{
			ft_team.style.left = mouseXStartPos+20;
			ft_team.style.top = mouseYStartPos-230;
		}
	}

}


function hidden_detail_ft_team(form_view){
	var ft_team = document.getElementById(form_view);
	ft_team.style.display="none";
}

function edit_business_profile(pro_id,description,company_name,job_title,industry,from_year,to_year,FormHandler){
	element = document.getElementById('update');
    element.style.display = "";
    element = document.getElementById('update_title');
    element.style.display = "";
    element = document.getElementById('add');
    element.style.display = "none";
    element = document.getElementById('add_title');
    element.style.display = "none";

    FormHandler.company.value = company_name;
    FormHandler.description.value = description;
    FormHandler.title.value = job_title;
	FormHandler.pro_id.value = pro_id;
	FormHandler.f_year.value = from_year;
	FormHandler.t_year.value = to_year;
	FormHandler.industry.value = industry;
}

function check_require_field_and_submit_pro_info(i){

	//var a = document.forms[i].elements["company"].value;
   	//var b = document.forms[i].elements["title"].value;
	var a = document.forms["pro_info_update"].company.value;
   	var b = document.forms["pro_info_update"].title.value;
	//alert(document.forms["pro_info_update"].company.value);	
    if(!a.length){
    	alert("Company is require field");
		return;
	}
	if(!b.length){
		alert("Position is require field");
		return;
	}

	element = document.getElementById('update');
    element.style.display = "none";
    element = document.getElementById('update_title');
    element.style.display = "none";
    element = document.getElementById('add');
    element.style.display = "";
    element = document.getElementById('add_title');
    element.style.display = "";

    document.forms["pro_info_update"].submit();
}

function edit_academic_profile(aca_id,edu,field_of_study,sch_name,country,gra_year,FormHandler){
	element = document.getElementById('update');
    element.style.display = "";
    element = document.getElementById('update_title');
    element.style.display = "";
    element = document.getElementById('add');
    element.style.display = "none";
    element = document.getElementById('add_title');
    element.style.display = "none";

    FormHandler.edu.value = edu;
    FormHandler.field_of_study.value = field_of_study;
    FormHandler.sch_name.value = sch_name;
	FormHandler.country.value = country;
	FormHandler.gra_year.value = gra_year;
	FormHandler.aca_id.value = aca_id;
}

function check_require_field_and_submit_academic(i){
    //var a = document.forms[i].elements["sch_name"].value;
	var a = document.forms["edu_info_update"].elements["sch_name"].value;
    if(!a.length){
    	alert("School name is require field");
		return;
	}

	element = document.getElementById('update');
    element.style.display = "none";
    element = document.getElementById('update_title');
    element.style.display = "none";
    element = document.getElementById('add');
    element.style.display = "";
    element = document.getElementById('add_title');
    element.style.display = "";

    document.forms["edu_info_update"].submit();
}
function add_a_job_education(){
	element = document.getElementById('update');
    element.style.display = "none";
    element = document.getElementById('update_title');
    element.style.display = "none";
    element = document.getElementById('add');
    element.style.display = "";
    element = document.getElementById('add_title');
    element.style.display = "";
}

function submit_privacy_reg(FormHandler,mem_id){
	var allow = FormHandler.allow_all_members.checked;
	var disable = FormHandler.disable_tag.checked;
	var show = FormHandler.show_registered_for.checked;
	var hide_status = FormHandler.hide_status.checked;

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=featured&action=submit_privacy&allow="+allow+"&disable="+disable+"&show="+show+"&hide_status="+hide_status+"&mem_id="+mem_id);
}

function submit_email_reg(FormHandler,mem_id){
	var new_event = FormHandler.new_event.checked;
	var new_mm = FormHandler.new_mm.checked;
	var friend_req = FormHandler.friend_req.checked;
	var new_comment = FormHandler.new_comment.checked;

    var xmlHttpReq = false;
    var self = this;

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
       		alert(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send("handler=featured&action=submit_email&new_event="+new_event+"&new_mm="+new_mm+"&friend_req="+friend_req+"&new_comment="+new_comment+"&mem_id="+mem_id);
}

function MailboxCheckBoxSelect(thisForm){
	var field = thisForm.elements['messages[]'];
	var isChecked = false;

	if (field.value == undefined){
		for (i = 0; i < field.length; i++){
			if (field[i].checked){
				isChecked = true ;
				break;
			}
		}
	}else{
		if (field.checked) isChecked = true ;
	}
	if (isChecked){
		if (document.getElementById("btnMailboxDelete")!= undefined)
			document.getElementById("btnMailboxDelete").style.display = "inline";
		if (document.getElementById("btnMailboxAdd")!=undefined)
			document.getElementById("btnMailboxAdd").style.display = "inline";
	}else{
		if (document.getElementById("btnMailboxDelete")!=undefined)
			document.getElementById("btnMailboxDelete").style.display = "none";
		if (document.getElementById("btnMailboxAdd")!=undefined)
			document.getElementById("btnMailboxAdd").style.display = "none";
	}
}

function MailboxTrashCheckBoxSelect(thisForm){
	var field = thisForm.elements['messages[]'];
	var isChecked = false;

	if (field.value == undefined){
		for (i = 0; i < field.length; i++){
			if (field[i].checked){
				isChecked = true ;
				break;
			}
		}
	}else{
		if (field.checked) isChecked = true ;
	}
	if (isChecked){
		if (document.getElementById("btnMailboxRestore")!= undefined)
			document.getElementById("btnMailboxRestore").style.display = "inline";
	}else{
		if (document.getElementById("btnMailboxRestore")!=undefined)
			document.getElementById("btnMailboxRestore").style.display = "none";
	}
}

function CheckAndUncheckAll(thisForm){
	if(thisForm.chkAll.checked){
		checkAll(thisForm.elements['messages[]']);
	}
	else{
		uncheckAll(thisForm.elements['messages[]']);
	}
	 MailboxCheckBoxSelect(thisForm);
}

function checkAll(field)
{
	for (i = 0; i < field.length; i++){
		field[i].checked = true ;
	}
}

function uncheckAll(field)
{
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
}

function hide_invitation(inv_id){
	document.location.href = "index.php?page=invite&action=hide_invitation&inv_id="+inv_id;
}

function HS_ViewMessage(mes_id,total,status,kind){

	var url = window.location.href;
	var hostPort = url.split('index.php')[0];
	var offset = document.getElementById("offset").value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}
 	if(offset.length < 1){
		offset=0;
	}
	if(status == 'next'){
		if(offset >= total-1){
			document.getElementById("offset").value=total-1
		}
		else{
			document.getElementById("offset").value=parseInt(offset)+1;
		}
	}
	if(status == 'prev'){
		if(offset <= 0){
			document.getElementById("offset").value=0;
		}
		else{

			document.getElementById("offset").value=parseInt(offset)-1;
		}
	}
	offset = document.getElementById("offset").value;
	var url="index.php?page=mailbox&section=view_message&action=view_message"
	url=url+"&mes_id="+mes_id+"&offset="+offset+"&kind="+kind+"&total="+total+"&t="+new Date().getTime();
	xmlHttp.onreadystatechange=view_message
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function view_message(){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0]
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			document.getElementById("message_view").innerHTML=xmlHttp.responseText;
			//1611
			var is_cham = document.getElementById("is_champagne").value;
			if(is_cham ==1){
				document.getElementById("is_cham").style.display="none";
			}
			else{
				document.getElementById("is_cham").style.display="";
			}
 	}
}


function HS_ViewInvitation(mes_id,total,status,kind){

	var url = window.location.href;
	var hostPort = url.split('index.php')[0];
	var offset = document.getElementById("offset").value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}
 	if(offset.length < 1){
		offset=0;
	}
	if(status == 'next'){
		if(offset >= total-1){
			document.getElementById("offset").value=total-1
		}
		else{
			document.getElementById("offset").value=parseInt(offset)+1;
		}
	}
	if(status == 'prev'){
		if(offset <= 0){
			document.getElementById("offset").value=0;
		}
		else{

		document.getElementById("offset").value=parseInt(offset)-1;
		}
	}
	offset = document.getElementById("offset").value;
	var url="index.php?page=mailbox&section=view_invitation&action=view_invitation"
	url=url+"&mes_id="+mes_id+"&offset="+offset+"&kind="+kind+"&total="+total+"&t="+new Date().getTime();
	xmlHttp.onreadystatechange=view_invitation
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function view_invitation(){
	var url = window.location.href;
	var hostPort = url.split('index.php')[0]
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			document.getElementById("invitation_view").innerHTML=xmlHttp.responseText;
 	}
}

/*
Note: This script works send contact ft about order
Create by :QUOCBAO
*/
function HS_ContactFtAboutOrder(){

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}
 	var city_id = document.getElementById("city_id").value;
 	var subject = document.getElementById("subject").value;
 	var content = document.getElementById("content_invitation").value;

 	var url="index.php?page=view_payment&action=contact_ft_about_order"
	url=url+"&city_id="+city_id+"&subject="+subject+"&content="+content+"&t="+new Date().getTime();

	xmlHttp.onreadystatechange=function(){
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		 	document.getElementById("subject").value="";
		 	document.getElementById("content_invitation").value="";
		 	pop_exit();
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

/*
Note: This script works well on IE, Firefox
Usage:
*/
function revealModal(divID)
{
    window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
    document.getElementById(divID).style.display = "none";
}

//Fix #1494: In "Share your video" et "Manage My Videos" windows, when a city is selected, only the list of the events of this city should be displayed in the drop-down menu of "Event"
function HS_EventsMemberPicturePopulate(FormHandler,AllowEmpty,DateFormat){
	for(var k = FormHandler.event_pic.options.length-1; k>=0; k--){
		FormHandler.event_pic.options[k] = null;
	}

	FormHandler.event_pic.options[0] = new Option("...loading...");
	var City = FormHandler.city_pic.options[FormHandler.city_pic.selectedIndex].value;
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest){// Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){// IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', "index.php", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
			HS_PullData(self.xmlHttpReq.responseXML,FormHandler.event_pic,'event');
		}
	}
	self.xmlHttpReq.send("handler=geo&action=events&city="+City+"&allow_empty="+AllowEmpty+"&date_format="+DateFormat);
}

/*
@1355
Alert when member wants to join groups
*/
function join_group_confirm(membership, msg){

	if(confirm('Do you confirm you want to join the group ' + msg +'?')){
		return true;
	}
	return false;
}

/* Note : This script works call pop_pup contact ft team about order
Create by:Quoc Bao
*/

var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;

/* Show pop_pup*/
function HS_ShowPopPup(id, drag_id,x, y){

	element      = document.getElementById(id);
	drag_element = document.getElementById(drag_id);

	element.style.position   = "absolute";
	element.style.visibility = "visible";
	element.style.display    = "block";
	element.style.left = (document.documentElement.scrollLeft+x)+'px';
	element.style.top  = (document.documentElement.scrollTop +y)+'px';

	popup_target = id;
	drag_element['target']   = id;
	drag_element.onmousedown = popup_mousedown;

}

/* Show pop_pup confirmation*/
function HS_ShowPopPupConfirmation(id, drag_id,id_message,message,x, y){

	element      = document.getElementById(id);
	drag_element = document.getElementById(drag_id);
	element_message = document.getElementById(id_message).innerHTML=message;

	element.style.position   = "absolute";
	element.style.visibility = "visible";
	element.style.display    = "block";
	element.style.left = (document.documentElement.scrollLeft+x)+'px';
	element.style.top  = (document.documentElement.scrollTop +y)+'px';

	popup_target = id;
	drag_element['target']   = id;
	drag_element.onmousedown = popup_mousedown;

}

/*	Popup_mousedown*/
function popup_mousedown(e)
{
	var ie = navigator.appName == "Microsoft Internet Explorer";

	if( ie && window.event.button != 1){
		return;
	}
	if(!ie && e.button != 0){
	return;
	}

	popup_dragging = true;
	popup_target   = this['target'];
	popup_mouseX   = ie ? window.event.clientX : e.clientX;

	popup_mouseY   = ie ? window.event.clientY : e.clientY;


	if (ie){
		popup_oldfunction      = document.onselectstart;
	}
	else{
		popup_oldfunction      = document.onmousedown;
	}

	if (ie){
		document.onselectstart = new Function("return false;");
	}
	else{
		document.onmousedown   = new Function("return false;");
	}
}

/*popup_mousepos*/
function popup_mousepos(e)
{
	var ie = navigator.appName == "Microsoft Internet Explorer";

	popup_mouseposX = ie ? window.event.clientX : e.clientX;
	popup_mouseposY = ie ? window.event.clientY : e.clientY;
}

/*popup_mousemove*/
function popup_mousemove(e)
{

	if(!popup_dragging){
		return;
	}

	var ie      = navigator.appName == "Microsoft Internet Explorer";
	var element = document.getElementById(popup_target);

	var mouseX = ie ? window.event.clientX : e.clientX;
	var mouseY = ie ? window.event.clientY : e.clientY;

	element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
	element.style.top  = (element.offsetTop +mouseY-popup_mouseY)+'px';

	popup_mouseX = ie ? window.event.clientX : e.clientX;
	popup_mouseY = ie ? window.event.clientY : e.clientY;
}

/*popup_mouseup*/
function popup_mouseup(e)
{
  if (!popup_dragging) return;
  popup_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);

  if (ie)
       document.onselectstart = popup_oldfunction;
  else document.onmousedown   = popup_oldfunction;
}

/* popup_exit*/
function pop_exit(e)
{
	var ie      = navigator.appName == "Microsoft Internet Explorer";
	var element = document.getElementById(popup_target);

	document.getElementById("subject").value="";
	document.getElementById("content_invitation").value="";

	popup_mouseup(e);
    element.style.visibility = 'hidden';
	element.style.display    = 'none';
}

/* popup_exit */
function pop_exit(e,subject,content){
    var ie      = navigator.appName == "Microsoft Internet Explorer";
    var element = document.getElementById(popup_target);

    if(subject){
        subject.value = "";
    }

    if(content){
        content.value = ""
    }

    popup_mouseup(e);
    element.style.visibility = 'hidden';
    element.style.display    = 'none';
}

function gup(name)
{
	name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
	var regexS = "[\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
	return "";
	else
	return results[1];
}


/*Exit popup confirmation*/
function hidden_confirmation(id)
{
	var gPage = gup("page");
	//var page = id.split("|");
	var browser=navigator.appName;
	var view = document.getElementById(id);
	view.style.visibility = 'hidden';
	
	if(browser=="Microsoft Internet Explorer")
	{
		if (gPage=="city") // city page loaded
		{
			view.style.display    = 'block';
		}
		else
		{
			view.style.display    = 'none';
		}
	}
	else
	{
		view.style.display    = 'none';
	}
	view.style.zIndex = -9999;
}

if (navigator.appName == "Microsoft Internet Explorer"){
	document.attachEvent('onmousedown', popup_mousepos);
}
else{
	document.addEventListener('mousedown', popup_mousepos, false);
}

if(navigator.appName == "Microsoft Internet Explorer"){
	document.attachEvent('onmousemove', popup_mousemove);
}
else{
	document.addEventListener('mousemove', popup_mousemove, false);
}

if(navigator.appName == "Microsoft Internet Explorer"){
	document.attachEvent('onmouseup', popup_mouseup);
}
else{
	document.addEventListener('mouseup', popup_mouseup, false);
}




function invitations_club_recommendation(){
	xmlHttp=GetXmlHttpObject();
	var subject = document.getElementById('r_subject').value;
	var content = document.getElementById('r_content_invitation').value;
	var clb_id = document.getElementById('r_clb_id').value;
	var to_id = document.getElementById('r_id_hidden1').value;
	var email = document.getElementById('r_eml1').value;

	var xmlHttpReq = false;
    var self = this;

	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(content.length <1700){
		if(subject.length < 1){
			//@1354
			subject = "None";
		}
	}
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(self.xmlHttpReq.responseText == '1'){
				alert('Your recommendation has been sent');
				document.getElementById('r_content_invitation').value = '';
				document.getElementById('r_clb_id').value = '';
				document.getElementById('r_id_hidden1').value = '';
				document.getElementById('r_eml1').value = '';
				element = document.getElementById("send_club_recommendation");
			    element.style.display = "none";
			}
       		else{
       			alert("This member's name doesn't exist");
   			}

			// Google Analytics tracking
			if(pageTracker){
				pageTracker._trackPageview();
				// debug
				// alert("URL tracked");
			}

			/*
			 * Here's the a trick for AJAX-based call of Quantcast
			 */
			var objXmlHttp_qoptions = null;
			try{objXmlHttp_qoptions = new XMLHttpRequest();}
			catch(e){
				try{objXmlHttp_qoptions = new ActiveXObject("Msxml2.XMLHTTP");}
				catch(e){objXmlHttp_qoptions = new ActiveXObject("Microsoft.XMLHTTP");}
			}
			objXmlHttp_qoptions.onreadystatechange = function() {
				if(objXmlHttp_qoptions.readyState == 4){
					strResultValue = '' + objXmlHttp_qoptions.responseText;
					// Execute
					eval(strResultValue);
					if(_qoptions){
						var objXmlHttp_quantcast = null;
						try{objXmlHttp_quantcast = new XMLHttpRequest();}
						catch(e){
							try{objXmlHttp_quantcast = new ActiveXObject("Msxml2.XMLHTTP");}
							catch(e){objXmlHttp_quantcast = new ActiveXObject("Microsoft.XMLHTTP");}
						}
						objXmlHttp_quantcast.onreadystatechange = function() {
							if(objXmlHttp_quantcast.readyState == 4){
								strResultValue = '' + objXmlHttp_quantcast.responseText;
								// Execute
								eval(strResultValue);
							}
						}
						objXmlHttp_quantcast.open("GET","./jscript/quantcast/quant.js",true);
						objXmlHttp_quantcast.send("");
					}
				}
			}
			objXmlHttp_qoptions.open("GET","./jscript/quantcast/quant_qoptions.js",true);
			objXmlHttp_qoptions.send("");

        }
    }

    self.xmlHttpReq.send("handler=clubs&action=invitation_club&clb_id="+clb_id+"&i_type=club_recommendation&sub="+subject+"&body="+content+"&to_id="+to_id+"&name="+email);
}

function get_form_club_recommendation(e,clb_id,difL,difT){

	if(!is_ie){
		mouseXStartPos = e.clientX + document.body.scrollLeft;
		mouseYStartPos = e.clientY + document.body.scrollTop;
	}else{
		mouseXStartPos = event.x + document.body.scrollLeft;
		mouseYStartPos = event.y + document.body.scrollTop;
	}
	var view   = document.getElementById('send_club_recommendation');
	var clb_id = document.getElementById('r_clb_id').value = clb_id ;

	document.getElementById("r_subject").value="Join this group on FT!";
	document.getElementById("r_content_invitation").value="";
	//document.getElementById("message").innerHTML="";

	if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
		view.style.display="";
		view.focus=true;
		if(view != null)	{
			view.style.left = mouseXStartPos-difL;
			view.style.top = mouseYStartPos-difT;
		}
	}
}

function hidden_send_club_recommendation(){

	var view = document.getElementById('send_club_recommendation');
	document.getElementById("r_message").innerHTML="";
	view.style.display="none";

}



function invitations_discussion_recommendation(){
	xmlHttp=GetXmlHttpObject();
	var subject = document.getElementById('rd_subject').value;
	var content = document.getElementById('rd_content_invitation').value;
	var discussion_id = document.getElementById('rd_discussion_id').value;
	var to_id = document.getElementById('rd_id_hidden1').value;
	var email = document.getElementById('rd_eml1').value;

	var xmlHttpReq = false;
    var self = this;

	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(content.length <1700){
		if(subject.length < 1){
			//@1354
			subject = "None";
		}
	}
    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(self.xmlHttpReq.responseText == '1'){
				alert('Your recommendation has been sent');
				document.getElementById('rd_content_invitation').value = '';
				document.getElementById('rd_discussion_id').value = '';
				document.getElementById('rd_id_hidden1').value = '';
				document.getElementById('rd_eml1').value = '';
				element = document.getElementById("send_discussion_recommendation");
			    element.style.display = "none";

				// Google Analytics tracking
				if(pageTracker){
					pageTracker._trackPageview();
					// debug
					// alert("URL tracked");
				}

				/*
				 * Here's the a trick for AJAX-based call of Quantcast
				 */
				var objXmlHttp_qoptions = null;
				try{objXmlHttp_qoptions = new XMLHttpRequest();}
				catch(e){
					try{objXmlHttp_qoptions = new ActiveXObject("Msxml2.XMLHTTP");}
					catch(e){objXmlHttp_qoptions = new ActiveXObject("Microsoft.XMLHTTP");}
				}
				objXmlHttp_qoptions.onreadystatechange = function() {
					if(objXmlHttp_qoptions.readyState == 4){
						strResultValue = '' + objXmlHttp_qoptions.responseText;
						// Execute
						eval(strResultValue);
						if(_qoptions){
							var objXmlHttp_quantcast = null;
							try{objXmlHttp_quantcast = new XMLHttpRequest();}
							catch(e){
								try{objXmlHttp_quantcast = new ActiveXObject("Msxml2.XMLHTTP");}
								catch(e){objXmlHttp_quantcast = new ActiveXObject("Microsoft.XMLHTTP");}
							}
							objXmlHttp_quantcast.onreadystatechange = function() {
								if(objXmlHttp_quantcast.readyState == 4){
									strResultValue = '' + objXmlHttp_quantcast.responseText;
									// Execute
									eval(strResultValue);
								}
							}
							objXmlHttp_quantcast.open("GET","./jscript/quantcast/quant.js",true);
							objXmlHttp_quantcast.send("");
						}
					}
				}
				objXmlHttp_qoptions.open("GET","./jscript/quantcast/quant_qoptions.js",true);
				objXmlHttp_qoptions.send("");

			}
       		else{
       			alert("This member's name doesn't exist");
   			}
        }
    }

    self.xmlHttpReq.send("handler=forum&action=invitation_discussion&discussion_id="+discussion_id+"&i_type=discussion_recommendation&sub="+subject+"&body="+content+"&to_id="+to_id+"&name="+email);
}

function get_form_discussion_recommendation(e,discussion_id,difL,difT){

	if(!is_ie){
		mouseXStartPos = e.clientX + document.body.scrollLeft;
		mouseYStartPos = e.clientY + document.body.scrollTop;
	}else{
		mouseXStartPos = event.x + document.body.scrollLeft;
		mouseYStartPos = event.y + document.body.scrollTop;
	}
	var view   = document.getElementById('send_discussion_recommendation');
	var discussion_id = document.getElementById('rd_discussion_id').value = discussion_id ;

	document.getElementById("rd_subject").value="Participate in this discussion!";
	document.getElementById("rd_content_invitation").value="";
	//document.getElementById("message").innerHTML="";

	if(mouseXStartPos != 0 && mouseYStartPos !=0  ){
		view.style.display="";
		view.focus=true;
		if(view != null)	{
			view.style.left = mouseXStartPos-difL;
			view.style.top = mouseYStartPos-difT;
		}
	}
}

function hidden_send_discussion_recommendation(){

	var view = document.getElementById('send_discussion_recommendation');
	document.getElementById("rd_message").innerHTML="";
	view.style.display="none";

}
//@1510 Send glass of Champagne invitation
function glass_of_champagne_invitation(sender_id, receiver_id){

	//alert(sender_id);
	//alert(receiver_id);
	xmlHttp=GetXmlHttpObject();
	var xmlHttpReq = false;
    var self = this;

	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
		return;
	}

    if(window.XMLHttpRequest){//Mozilla/Safari
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) {//IE
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', "index.php", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function(){
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200){
        	if(self.xmlHttpReq.responseText == '1'){
				alert('Your invitation has been sent');
			}
       		else if(self.xmlHttpReq.responseText == '0'){
       			alert("You already invited this member to a glass of Champagne!");
   			}
			else if(self.xmlHttpReq.responseText == '-1'){
				alert("This feature is disabled");
			}else if (self.xmlHttpReq.responseText == '2'){
				alert("This member does not want to receive message");
			}
        }
    }
    self.xmlHttpReq.send("handler=profile&action=send_glass_champagne&sender_id="+sender_id+"&receiver_id="+receiver_id);
}

//@1553
function close_discussion(top_id, top_name){
	if(confirm("Do you confirm you want to close the discussion "+top_name+" ?")){
		document.location.href = "index.php?handler=forum&action=close&top_id="+top_id;
	}
}

//@1554
function leave_club(group_name){
	if(confirm("Do you confirm you want to leave the group "+group_name+" ?")){
		return true;
	}
	return false;
}

function HS_ShowPopPupMemPreview(mem_id,id,drag_id,x,y){

	element      = document.getElementById(id);
	drag_element = document.getElementById(drag_id);
	var url = window.location.href;
	var hostPort = url.split('index.php')[0]



	element.style.position   = "absolute";
	element.style.visibility = "visible";
	element.style.display    = "block";
	/* hack */
	element.style.zIndex = 1;
	//LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
	//TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
	//alert(screen.height);
	element.style.left = x;//LeftPosition;//(document.documentElement.scrollLeft+x)+'px';
	element.style.top  = y;//screen.height;(document.documentElement.scrollTop +y)+'px';

	popup_target = id;
	drag_element['target']   = id;
	drag_element.onmousedown = popup_mousedown;

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}

	var url="index.php?page=my_homepage&action=loadmemberpreview"
	url=url+"&mem_id="+mem_id+"&t="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

			var xmlDoc = xmlHttp.responseXML;
			//alert(xmlHttp.responseText);
			document.getElementById("name_member_title").innerHTML = xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue+'&nbsp;'+xmlDoc.getElementsByTagName("lname")[0].childNodes[0].nodeValue;
			document.getElementById("name_member").innerHTML = xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue+'&nbsp;'+xmlDoc.getElementsByTagName("lname")[0].childNodes[0].nodeValue;

			pw = xmlDoc.getElementsByTagName("photomem_width")[0].childNodes[0].nodeValue;
			ph = xmlDoc.getElementsByTagName("photomem_height")[0].childNodes[0].nodeValue;
			objPhotoContainer = document.getElementById("picture_member");
			lngContWidth = 140;
			lngContHeight = 140;
			if(pw > lngContWidth || ph > lngContHeight){
				if(pw > lngContWidth && ph <= lngContHeight){
					objPhotoContainer.width = lngContWidth;
				}
				if(pw <= lngContWidth && ph > lngContHeight){
					objPhotoContainer.height = lngContHeight;
				}
				if(pw > lngContWidth && ph > lngContHeight){
					if(ph/lngContHeight > pw/lngContWidth){
	                    objPhotoContainer.height = lngContHeight;
					}else{
	                    objPhotoContainer.width = lngContWidth;
					}
				}
			}else{
				objPhotoContainer.width = pw;
				objPhotoContainer.height = ph;
			}
			objPhotoContainer.src = hostPort+'photos/'+xmlDoc.getElementsByTagName("photomem")[0].childNodes[0].nodeValue;

			if(xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue=='0'){
				document.getElementById("city").innerHTML = "";
			}else{
				document.getElementById("city").innerHTML = xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue;
			}
			document.getElementById("bonjour").href = xmlDoc.getElementsByTagName("bt_bonjour")[0].childNodes[0].nodeValue;
			document.getElementById("mem_id_fr").value = mem_id;
			document.getElementById("sendmessage").href = xmlDoc.getElementsByTagName("bt_message")[0].childNodes[0].nodeValue;
			document.getElementById("champagne").href = xmlDoc.getElementsByTagName("bt_champ")[0].childNodes[0].nodeValue;
			var count_fr = xmlDoc.getElementsByTagName("count_fr")[0].childNodes[0].nodeValue;
			var myCars=new Array();

			if(count_fr > 0){
				if(xmlDoc.getElementsByTagName("title_fr")[0].childNodes.length > 0){
					document.getElementById("title_friends").innerHTML=xmlDoc.getElementsByTagName("title_fr")[0].childNodes[0].nodeValue;
				}
				for(var i=0;i<=count_fr-1;i++){
					myCars[i]= '<a href="index.php?page=my_homepage&mem_id=' + xmlDoc.getElementsByTagName("mem_id")[i].childNodes[0].nodeValue + '"><img src="'+hostPort+'photos/'+xmlDoc.getElementsByTagName("photo_small")[i].childNodes[0].nodeValue+'" alt="" /><br>'+xmlDoc.getElementsByTagName("name_fr")[i].childNodes[0].nodeValue+'</a>'
				}
				var string_cars = myCars.join("");
				document.getElementById("friends").innerHTML =string_cars;
			}
			else{
				document.getElementById("friends").innerHTML="";
				document.getElementById("title_friends").innerHTML="";
			}
    	}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}

function HS_NextPreviousMember(number_most_friends,total_most_friends,status){

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}

 	var offset = parseInt(document.getElementById("offset").value);
 	var bt_next = document.getElementById("next");
 	var bt_prev = document.getElementById("prev");
	var i=1;
   	var j;
   	var iNode;

 	for(j=1;j<=number_most_friends;j++){
		document.getElementById('member'+j).innerHTML=image_loading;
	}

 	if(status =="next"){

 		if(offset >= Math.floor(total_most_friends/number_most_friends)){
 			document.getElementById("offset").value = Math.floor(total_most_friends/number_most_friends);
 			bt_next.style.display='none';
 		}
 		else{
 			document.getElementById("offset").value=offset+1;
 			bt_prev.style.display='';
 		}

 	}
 	if(status =="prev"){

 		if(offset == 0){
 			document.getElementById("offset").value=0;
 			bt_prev.style.display='none';
 		}
 		else{
 			document.getElementById("offset").value=offset-1;
 			bt_next.style.display='';
 		}
 	}
 	offset = parseInt(document.getElementById("offset").value)
	var url="index.php?page=search&section=members&action=next_previous_member"
	url=url+"&number_most_friends="+number_most_friends+"&total_most_friends="+total_most_friends+"&offset="+offset+"&status="+status+"&t="+new Date().getTime();

	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){

			for(j=1;j<=number_most_friends;j++){
				document.getElementById('member'+j).innerHTML="";
			}

			if(offset==4){
				bt_next.style.display='none';
			}
			if(offset==0){
				bt_prev.style.display='none';
			}

			var xmlDoc = xmlHttp.responseXML;
	    	var root = xmlDoc.getElementsByTagName('data').item(0);

	    	for (iNode = 0; iNode <= root.childNodes.length-1; iNode++) {
    			document.getElementById('member'+i).innerHTML = xmlDoc.getElementsByTagName('member')[iNode].childNodes[0].nodeValue;
				i++;
			}
		}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send("")
}


function MemberPreview(e,mem_id,id,grs){


	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}


	mouseXStartPos = 200 + document.body.scrollLeft;
   	mouseYStartPos = 300 + document.body.scrollTop;

	var url="index.php?page=my_homepage&action=memberpreview"
	url=url+"&mem_id="+mem_id+"&t="+new Date().getTime();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			if(xmlHttp.responseText=='0'){
				HS_ShowPopPupMemPreview(mem_id,id,grs,mouseXStartPos+150,mouseYStartPos-100);
			}
			else{
				location.href="index.php?page=my_homepage&mem_id="+mem_id;
			}
    	}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send("")

}

function SendMessage(mem_id){
	location.href="index.php?page=mailbox&section=message&recipient="+mem_id;
}

//@1606 START bubble tooltip

function showToolTip(e,text){
	if(checkCookie('FrenchTuesdaysMavieBalloon')){
		if(document.all)e = event;

		var obj = document.getElementById('bubble_tooltip');
		var obj2 = document.getElementById('bubble_tooltip_content');
		obj2.innerHTML = text;
		obj.style.display = 'block';
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
		var leftPos = e.clientX - 100;
		if(leftPos<0)leftPos = 0;
		obj.style.left = leftPos + 'px';
		obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
	}
}
/**
	@param: div_id: Div ID
	@param: c_name: Cookie name
*/
function hideToolTip()
{
	setTimeout("delayMavie()", 45000);
}

function delayMavie(){
	document.getElementById('bubble_tooltip').style.display = 'none';
	setCookie('FrenchTuesdaysMavieBalloon','',1);
}

/*
	@1606 GeraIT - Balloon modify
*/


function showBalloon(e,mem_id,balloon){
  	var x=e.clientX
	var y=e.clientY

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) 	{
		 alert ("Browser does not support HTTP Request")
 		return
 	}

	var url="index.php?page=my_homepage&action=get_balloon_flag"
	url=url+"&mem_id="+mem_id+"&balloon="+balloon;
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			//alert(xmlHttp.responseText);
			var text = xmlHttp.responseText;
			/* Show Balloon */

			if (text != '1')
			{
				if(document.all)e = event;
				var obj = document.getElementById('bubble_tooltip');
				var obj2 = document.getElementById('bubble_tooltip_content');
				obj2.innerHTML = text;
				obj.style.display = 'block';
				var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
				if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
				var leftPos = x - 100;
				if(leftPos<0)leftPos = 0;
				obj.style.left = leftPos + 'px';
				obj.style.top = y - obj.offsetHeight -1 + st + 'px';
				setTimeout("hideBalloon('"+mem_id+"','"+balloon+"')", 45000);			// delay
			}
			/*--------------*/
    	}else{
			return false;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send("");
}

function hideBalloon(mem_id,balloon){
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) 	{
			 alert ("Browser does not support HTTP Request")
			return
		}

		var url="index.php?page=my_homepage&action=set_balloon_flag"
		url=url+"&mem_id="+mem_id+"&balloon="+balloon;
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				var text = xmlHttp.responseText;
				document.getElementById('bubble_tooltip').style.display = 'none';
			}else{
				return false;
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send("");
}


function showToolTipChampagne(e,text){
	if(checkCookie('FrenchTuesdaysGlassOfChampagneBalloon')){
		if(document.all)e = event;

		var obj = document.getElementById('bubble_tooltip');
		var obj2 = document.getElementById('bubble_tooltip_content');
		obj2.innerHTML = text;
		obj.style.display = 'block';
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
		var leftPos = e.clientX - 100;
		if(leftPos<0)leftPos = 0;
		obj.style.left = leftPos + 'px';
		obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
	}
}
/**
	@param: div_id: Div ID
	@param: c_name: Cookie name
*/
function hideToolTipChampagne()
{
	setTimeout("delayChampagne()", 45000);
}

function delayChampagne(){
	document.getElementById('bubble_tooltip').style.display = 'none';
	//setCookie('FrenchTuesdaysGlassOfChampagneBalloon','',1);
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie(c_name){
	value=getCookie(c_name);
	if (value!=null && value!="") {
		return true;
	}
	return false;
}

function getCookie(c_name){
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)  {
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;

	    	return unescape(document.cookie.substring(c_start,c_end));
	    }
	}
	return "";
}
//END bubble tooltip

function HS_viewPhotoAlbum (per_id, pho_id,alb_id){
   url = MainURL+"index.php?page=photos&section=album&per_id="+per_id+"&pho_id="+pho_id+"&alb_id="+alb_id;
   phowin = window.open(url, "PHOTOALBUM", "width=700,height=700,scrollbars=yes,menubar=no,resizable=no,location=no");
   phowin.focus();
}


// ADDED FOR JOIN FT COMMUNITY FORM TO CHECK EMAILS & MESSAGE_INVITE FIELDS
function checkfields()
{
	var emails = document.forms["invite"].emails.value;
	var messageInvite = document.forms["invite"].message_invite.value;
	
	if(emails.length ==0 || emails==null || emails=='')
	{
		alert("Email(s) is a required field.\nPlease enter Recepient's email address.");
		document.forms["invite"].emails.focus();
		return false;
	}
	
	if(messageInvite.length==0 || messageInvite==null || messageInvite=='')
	{
		alert("Message is a required field.");
		document.forms["invite"].message_invite.focus();
		return false;
	}
}
