/*

(C) AEwebworks Software Development Ltd., 2002-2003

IMPORTANT: This is a commercial software product and any kind of using it must agree

to the AEwebworks Software Development Ltd. license agreement. It can be found at

http://www.aewebworks.com/license.htm

This notice may not be removed from the source code.

*/



/**

 * Checks/unchecks all tables

 *

 * @param   string   the form name

 * @param   boolean  whether to check or to uncheck the element

 *

 * @return  boolean  always true

 */

var openPopup = "" ;

 function deleteBanner( delid , pkgid )
 {
	var agree = confirm( "Are you sure you want to remove this banner?" ) ;

	if( agree )
	 {
		window.location = "bannerpreview.php?packageId=" + pkgid + "&bannerId=" + delid + "&action=removebanner" ;
	 }
 }

function validateBannerUpload( pkgId )
{
	if( pkgId == 7 )
	{
		if( document.frmbannerupload.studentcountry.value == "" )
		{
			alert( "Please select country." ) ;
			return false ;
		}

		if( document.frmbannerupload.institutionlist.value == "" )
		{
			alert( "Please select Institution." ) ;
			return false ;
		}
	}

	return true ;
}

function loadbanner( bannerSection , bannerarea )
{
	if( document.getElementById( bannerSection ) )
	{
		if( document.getElementById( bannerSection ).innerHTML == "" )
			document.getElementById( bannerSection ).innerHTML = "<center>Loading Banner....</center>" ;
		
		showbannerID = bannerSection ;
		showBannerSection = bannerarea ;
		sendBannerReq( "banner.php?section=" + bannerarea ) ;
	}
}

function loadMemberControlBanner()
{
	loadbanner( "loadBannerPageMemberControlSection" , "2" ) ;
}

function loadNewsBanner()
{
	loadbanner( "loadBannerPageNewsSection" , "10" ) ;
}

function loadLastVideosBanner()
{
	loadbanner( "loadBannerPageLastVideosSection" , "9" ) ;
}

function loadRecentPostingBanner()
{
	loadbanner( "loadBannerPageRecentPostingSection" , "3" ) ;
}

function loadMemberPersonalEffectiveBanner()
{
	loadbanner( "loadBannerPagePersonalEffectiveSection" , "5" ) ;
}

function loadMemberNetworkingBanner()
{
	loadbanner( "loadBannerPageNetworkingSection" , "5" ) ;
}

function loadMemberMyTimeLineBanner()
{
	loadbanner( "loadBannerPageMyTimelineSection" , "5" ) ;
}

function loadMemberSelfPromotionBanner()
{
	//alert( showbannerID ) ;
	if( showbannerID == "" || showbannerID == "loadBannerPageMySelfPromotionSection" )
		loadbanner( "loadBannerPageSelfPromotionSection" , "5" ) ;
	else
		loadbanner( "loadBannerPageMySelfPromotionSection" , "5" ) ;
}

function loadMemberLifeStyleBanner()
{
	loadbanner( "loadBannerPageLifeStyleSection" , "6" ) ;
}

function loadS2sCommentBanner()
{
	loadbanner( "loadBannerPageS2SCommentSection" , "7&schools=" + instituteId ) ;
}

function loadTravelBanner()
{
	loadbanner( "loadBannerTravelSection" , "8" ) ;
}

function getinstitutionlist( elem )
{
	document.getElementById( "loadingMsg" ).innerHTML = "Loading institution...." ;

	//alert( 'inc/institution.php?country=' + elem.value ) ;
	sendReq( 'institution.php?country=' + elem.value ) ;
}

function sendNudge( nudgeId )
{
  openPopup = "" ;
  openPopup = window.open( "network_nudges.php?sendto=" + nudgeId , "Send_Nudge" , "width=600,height=200,menubar=no,status=no,resizable=yes,scrollbars=yes,toolbar=no, location=no" ) ;

  setTimeout( "closePopUps()" , 8000 ) ;
}

function saveName()
{
  document.myform.savetype.value = "savename" ;
  document.myform.submit() ;
}

function validateUser()
{
	if( loggedinMember )
	{
		return true ;
	}
	else
	{
		alert( "Please logged in to view this section." ) ;
		return false ;
	}
}

function openPopUpWindow( pageId , pageTitle )
{
  window.open( pageId , pageTitle , "width=600,height=200,menubar=no,status=no,resizable=yes,scrollbars=yes,toolbar=no, location=no" ) ;
}

function backToPage()
{
	window.close() ;
	window.opener.focus() ;
}

function subscribe( nId , nType )
{
	var loc = location.href ;
	var locarr = loc.split( '&notify=' ) ;
    var notifyOpt = "" ;

	if( document.getElementById( "gostudentgo" ).checked == true )
		notifyOpt = document.getElementById( "gostudentgo" ).value ;
	else if( document.getElementById( "privateEmail" ).checked == true )
		notifyOpt = document.getElementById( "privateEmail" ).value ;
	else if( document.getElementById( "bothnotify" ).checked == true )
		notifyOpt = document.getElementById( "bothnotify" ).value ;
	
	if( notifyOpt == "" )
	{
		alert( "select notification option." ) ;
		return false ;
	}
	
	window.location = locarr[0] + "&notify=" + nType + "&notifyId=" + notifyOpt + "&notID=" + nId ;
}

function closePopUps()
{
	if( openPopup )
	{
		openPopup.close() ;
		openPopup = "" ;
	}
}

function showHide(ids)

{

	if( document.getElementById(ids).style.display == "none" ) {

    document.getElementById(ids).style.display = "block";

  } else {

    document.getElementById(ids).style.display = "none"; }

}

	





function setCheckboxes(the_form, do_check)

{

    var elts      = document.forms[the_form].elements;

    var elts_cnt  = elts.length;

	

    for (var i = 0; i < elts_cnt; i++) {

        elts[i].checked = do_check;

		if (the_form + "_submit" == elts[i].name) {

			elts[i].disabled = !do_check;

		}

    } // end for



    return true;

} // end of the 'setCheckboxes()' function



function setCheckbox(the_form)

{

    var elts      = document.forms[the_form].elements;

    var elts_cnt  = elts.length;

    

    var allUnchecked = true;

	

    for (var i = 0; i < elts_cnt; i++)

    {

        if(elts[i].checked) allUnchecked = false;

    }

    

    for (var i = 0; i < elts_cnt; i++)

    {

        if(elts[i].name == (the_form + "_submit")) elts[i].disabled = allUnchecked;

    }



    return true;

}





var win = "width=400,height=500,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

function get_gallery(id_prof)

{

   window.open("photos_gallery.php?ID="+id_prof,'gallery',win);

}

var win22 = "width=600,height=600,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

function get_vgallery(id_prof)

{

   window.open("videos_gallery.php?ID="+id_prof,'gallery',win22);

}

var win55 = "width=800,height=800,left=50,top=50,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

function get_ggallery(g_id)

{

   window.open("gallery.php?action=popupgallery&owner="+g_id,'gallery',win55);

}

var win23 = "width=780,height=800,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

function profile_pops(id_prof)

{

   //window.open("profile_pop.php?ID="+id_prof,'Profile',win23);
   
   window.open("profile.php?ID="+id_prof+"&profileview=preview",'Profile',win23);

}



function launchTellFriend ()

{   

    var win = "width=250,height=260,left=200,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=no";

    window.open("tellfriend.php",'tellfriend',win);

    return false;

}



function launchTellFriendProfile ( sID )

{

    var win = "width=300,height=300,left=0,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);

    return false;

}



function ShowShowHide ( show_name, show_name2, hide_name )

{

    if (hide_name) hide_name.style.display = 'none';

    if (show_name) show_name.style.display = 'inline';

    if (show_name2) show_name2.style.display = 'inline';

}



function ShowHideHide ( show_name, hide_name, hide_name2 )

{

    if (hide_name) hide_name.style.display = 'none';

    if (hide_name2) hide_name2.style.display = 'none';

    if (show_name) show_name.style.display = 'inline';

}





/**

 * change images onHover mouse action

 */

function show(FileName,jpg1Name)

{

	document.images[FileName].src = jpg1Name;

}



/**

 * set status of the browser window to 's'

 */

function ss(s) 

{

	window.status = s;

	return true;

}



/**

 * set status of the browser window to empty

 */

function ce()

{

	window.status='';

}





/**

 * insert emotion item

 */

function emoticon( txtarea, text ) {



	text = ' ' + text + ' ';

	if (txtarea.createTextRange && txtarea.caretPos) {

		var caretPos = txtarea.caretPos;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;

		txtarea.focus();

	} else {

		txtarea.value  += text;

		txtarea.focus();

	}

}



function launchAddToIM (id)

{

    var win = "width=600,height=160,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";

    window.open("explanation.php?explain=imadd&ID="+id,'add_to_im',win);

    return false;

}



function docOpen(text)

{

	newWindow=window.open('','','toolbar=no,resizable=yes,scrollbars=yes,width=400,height=300');

	newWindow.document.open("text/html");

	newWindow.document.write(unescape(text));

	newWindow.document.close();

}



// declare a global  XMLHTTP Request object

var XmlHttpObj;

var fl_country;

var fl_region;

var fl_city;

var fl_insti_country;

var fl_insti_region;

var fl_insti_city;

// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla

function CreateXmlHttpObj()

{

	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)

	try

	{

		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");

	}

	catch(e)

	{

		try

		{

			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");

		} 

		catch(oc)

		{

			XmlHttpObj = null;

		}

	}

	// if unable to create using IE specific code then try creating for Mozilla (FireFox) 

	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 

	{

		XmlHttpObj = new XMLHttpRequest();

	}

}



// called from onChange or onClick event of the continent dropdown list

function CountryListOnChange(pfl_country,pfl_region,pfl_city) 

{

    fl_country = pfl_country;

    fl_region  = pfl_region;

    fl_city    = pfl_city;

    window.status = "Loading Regions .....";	

    //var Geo_Country = document.getElementById("Geo_Country");

    var Geo_Country = document.getElementById(fl_country);

    // get selected continent from dropdown list

    var selectedCountry = Geo_Country.options[Geo_Country.selectedIndex].value;

    

    // url of page that will send xml data back to client browser

    var requestUrl;

    

    // use the following line if using php

    s = current_date_txt();

    requestUrl = "modmysite/worldcities/xml_data_provider.php" + "?action=r&country=" + encodeURIComponent(selectedCountry) + "&date=" + s;

    

	CreateXmlHttpObj();

	

	// verify XmlHttpObj variable was successfully initialized

	if(XmlHttpObj)

	{

        // assign the StateChangeHandler function ( defined below in this file)

        // to be called when the state of the XmlHttpObj changes

        // receiving data back from the server is one such change

		XmlHttpObj.onreadystatechange = RegionStateChangeHandler;

		

		// define the iteraction with the server -- true for as asynchronous.

		XmlHttpObj.open("GET", requestUrl,  true);

		

		// send request to server, null arg  when using "GET"

		XmlHttpObj.send(null);		

	}

}





// this function called when state of  XmlHttpObj changes

// we're interested in the state that indicates data has been

// received from the server

function RegionStateChangeHandler()

{

	//alert(fl_country + fl_region + fl_city);

	// state ==4 indicates receiving response data from server is completed

	if(XmlHttpObj.readyState == 4)

	{

		// To make sure valid response is received from the server, 200 means response received is OK

		if(XmlHttpObj.status == 200)

		{			

			PopulateRegionList(XmlHttpObj.responseXML.documentElement);

		}

		else

		{

			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);

		}

	}

}



// populate the contents of the Region dropdown list

function PopulateRegionList(RegionNode)

{

	

    	//var RegionList = document.getElementById("Geo_Region");

    	var RegionList = document.getElementById(fl_region);

	// clear the Region list 	

	for (var count = RegionList.options.length-1; count >-1; count--)

	{

		RegionList.options[count] = null;

	}

		

	var CityList = document.getElementById(fl_city);

	

	// clear the city list 	

	for (var count = CityList.options.length-1; count >-1; count--)

		{

		CityList.options[count] = null;

		}

	

	var RegionNodes = RegionNode.getElementsByTagName('region');

	

	var idValue;

	var textValue; 

	var optionItem;

	// populate the dropdown list with data from the xml doc

	

	for (var count = 0; count < RegionNodes.length; count++)

	{

   		textValue = GetInnerText(RegionNodes[count]);

		idValue = RegionNodes[count].getAttribute("id");

		optionItem = new Option( textValue, idValue,  false, false);

		RegionList.options[RegionList.length] = optionItem;

	}

	window.status = "";

}





function RegionListOnChange(pfl_country,pfl_region,pfl_city) 

{

    fl_country = pfl_country;

    fl_region  = pfl_region;

    fl_city    = pfl_city;

	

    window.status = "Loading Cities .....";	

    var Geo_Country = document.getElementById(fl_country);    



    var selectedCountry = Geo_Country.options[Geo_Country.selectedIndex].value;

    

    var Geo_Region = document.getElementById(fl_region);

    

    // get selected continent from dropdown list

    var selectedRegion = Geo_Region.options[Geo_Region.selectedIndex].value;

    

    // url of page that will send xml data back to client browser

    var requestUrl;

    

    // use the following line if using php

    s = current_date_txt();

    requestUrl = "modmysite/worldcities/xml_data_provider.php" + "?action=c&region=" + encodeURIComponent(selectedRegion) + "&country=" + encodeURIComponent(selectedCountry) + "&date=" + s;

    

	CreateXmlHttpObj();

	

	// verify XmlHttpObj variable was successfully initialized

	if(XmlHttpObj)

	{

        // assign the StateChangeHandler function ( defined below in this file)

        // to be called when the state of the XmlHttpObj changes

        // receiving data back from the server is one such change

		XmlHttpObj.onreadystatechange = CityStateChangeHandler;

		

		// define the iteraction with the server -- true for as asynchronous.

		XmlHttpObj.open("GET", requestUrl,  true);

		

		// send request to server, null arg  when using "GET"

		XmlHttpObj.send(null);		

	}

	

}





// this function called when state of  XmlHttpObj changes

// we're interested in the state that indicates data has been

// received from the server

function CityStateChangeHandler()

{

	// state ==4 indicates receiving response data from server is completed

	if(XmlHttpObj.readyState == 4)

	{

		// To make sure valid response is received from the server, 200 means response received is OK

		if(XmlHttpObj.status == 200)

		{			

			PopulateCityList(XmlHttpObj.responseXML.documentElement);

		}

		else

		{

			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);

		}

	}

}



// populate the contents of the Region dropdown list

function PopulateCityList(CityNode)

{

    var CityList = document.getElementById(fl_city);

	// clear the Region list 

	

	

	for (var count = CityList.options.length-1; count >-1; count--)

	{

		CityList.options[count] = null;

	}



	var CityNodes = CityNode.getElementsByTagName('city');

	

	var idValue;

	var textValue; 

	var optionItem;

	// populate the dropdown list with data from the xml doc

	//alert(CityNodes.length);

	for (var count = 0; count < CityNodes.length; count++)

	{

	    

   		textValue = GetInnerText(CityNodes[count]);

   		if ( typeof textValue == "undefined" )

   		   {

   		   textValue='';

   		   }

   		   

   	//alert(textValue);	   

   		   

		idValue = CityNodes[count].getAttribute("id");

		optionItem = new Option( textValue, idValue,  false, false);

		CityList.options[CityList.length] = optionItem;

	}

	window.status = "";

	

}





// returns the node text value 

function GetInnerText (node)

{

	 return (node.textContent || node.innerText || node.text) ;

}



function yesno(msg)

{

var truthBeTold = confirm(msg);

if (!truthBeTold)

   {

   alert("CANCELLED!");

   return false;

   }

return true;

}



function current_date_txt()

{

	 var d,s;

	 d = new Date();

	 s = (d.getMonth() + 1) + '_' ;

  	 s += d.getDate()  + '_' ;

  	 s += d.getFullYear() + '_' ;

	 s += d.getHours() + '_' ;

  	 s += d.getMinutes() + '_' ;

  	 s += d.getSeconds();

  	 return s;

}	





// WORLDCITIES INSTITUTE START



function insti_CountryListOnChange(pfl_insti_country,pfl_insti_region,pfl_insti_city) 

{

    fl_insti_country = pfl_insti_country;

    fl_insti_region  = pfl_insti_region;

    fl_insti_city    = pfl_insti_city;

    window.status = "Loading Regions .....";	

    //var Geo_Country = document.getElementById("Geo_Country");

    var Geo_insti_Country = document.getElementById(fl_insti_country);

    // get selected continent from dropdown list

    var selectedCountry = Geo_insti_Country.options[Geo_insti_Country.selectedIndex].value;

    

    // url of page that will send xml data back to client browser

    var requestUrl;

    

    // use the following line if using php

    s = current_date_txt();

    requestUrl = "modmysite/worldcities/xml_data_provider_insti.php" + "?action=r&country=" + encodeURIComponent(selectedCountry) + "&date=" + s;

    

	CreateXmlHttpObj();

	

	// verify XmlHttpObj variable was successfully initialized

	if(XmlHttpObj)

	{

        // assign the StateChangeHandler function ( defined below in this file)

        // to be called when the state of the XmlHttpObj changes

        // receiving data back from the server is one such change

		XmlHttpObj.onreadystatechange = insti_RegionStateChangeHandler;

		

		// define the iteraction with the server -- true for as asynchronous.

		XmlHttpObj.open("GET", requestUrl,  true);

		

		// send request to server, null arg  when using "GET"

		XmlHttpObj.send(null);		

	}

}





function insti_RegionStateChangeHandler()

{

	//alert(fl_country + fl_region + fl_city);

	// state ==4 indicates receiving response data from server is completed

	if(XmlHttpObj.readyState == 4)

	{

		// To make sure valid response is received from the server, 200 means response received is OK

		if(XmlHttpObj.status == 200)

		{			

			insti_PopulateRegionList(XmlHttpObj.responseXML.documentElement);

		}

		else

		{

			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);

		}

	}

}





// populate the contents of the Region dropdown list

function insti_PopulateRegionList(RegionNode)

{

	

    	//var RegionList = document.getElementById("Geo_Region");

    	var RegionList = document.getElementById(fl_insti_region);

	// clear the Region list 	

	for (var count = RegionList.options.length-1; count >-1; count--)

	{

		RegionList.options[count] = null;

	}

		

	var CityList = document.getElementById(fl_insti_city);

	

	// clear the city list 	

	for (var count = CityList.options.length-1; count >-1; count--)

		{

		CityList.options[count] = null;

		}

	

	var RegionNodes = RegionNode.getElementsByTagName('region_insti');

	

	var idValue;

	var textValue; 

	var optionItem;

	// populate the dropdown list with data from the xml doc

	

	for (var count = 0; count < RegionNodes.length; count++)

	{

   		textValue = GetInnerText(RegionNodes[count]);

		idValue = RegionNodes[count].getAttribute("id");

		optionItem = new Option( textValue, idValue,  false, false);

		RegionList.options[RegionList.length] = optionItem;

	}

	window.status = "";

}



function insti_RegionListOnChange(pfl_insti_country,pfl_insti_region,pfl_insti_city) 

{

    fl_insti_country = pfl_insti_country;

    fl_insti_region  = pfl_insti_region;

    fl_insti_city    = pfl_insti_city;

	

    window.status = "Loading Cities .....";	

    var Geo_insti_Country = document.getElementById(fl_insti_country);    



    var selectedCountry = Geo_insti_Country.options[Geo_insti_Country.selectedIndex].value;

    

    var Geo_insti_Region = document.getElementById(fl_insti_region);

    

    // get selected continent from dropdown list

    var selectedRegion = Geo_insti_Region.options[Geo_insti_Region.selectedIndex].value;

    

    // url of page that will send xml data back to client browser

    var requestUrl;

    

    // use the following line if using php

    s = current_date_txt();
	//alert( selectedRegion + "---" + selectedCountry + "--" + s ) ;
    requestUrl = "modmysite/worldcities/xml_data_provider_insti.php" + "?action=c&region=" + encodeURIComponent(selectedRegion) + "&country=" + encodeURIComponent(selectedCountry) + "&date=" + s;

    

	CreateXmlHttpObj();

	

	// verify XmlHttpObj variable was successfully initialized

	if(XmlHttpObj)

	{

        // assign the StateChangeHandler function ( defined below in this file)

        // to be called when the state of the XmlHttpObj changes

        // receiving data back from the server is one such change

		XmlHttpObj.onreadystatechange = insti_CityStateChangeHandler;

		

		// define the iteraction with the server -- true for as asynchronous.

		XmlHttpObj.open("GET", requestUrl,  true);

		

		// send request to server, null arg  when using "GET"

		XmlHttpObj.send(null);		

	}

	

}





function insti_CityStateChangeHandler()

{

	// state ==4 indicates receiving response data from server is completed

	if(XmlHttpObj.readyState == 4)

	{

		// To make sure valid response is received from the server, 200 means response received is OK

		if(XmlHttpObj.status == 200)

		{			

			insti_PopulateCityList(XmlHttpObj.responseXML.documentElement);

		}

		else

		{

			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);

		}

	}

}





// populate the contents of the Region dropdown list

function insti_PopulateCityList(CityNode)

{

	//alert('shit');

    var CityList = document.getElementById(fl_insti_city);

	// clear the Region list 

	

	

	for (var count = CityList.options.length-1; count >-1; count--)

	{

		CityList.options[count] = null;

	}



	var CityNodes = CityNode.getElementsByTagName('city_insti');

	

	var idValue;

	var textValue; 

	var optionItem;

	// populate the dropdown list with data from the xml doc

	//alert(CityNodes.length);

	for (var count = 0; count < CityNodes.length; count++)

	{

   		textValue = GetInnerText(CityNodes[count]);   			

   		if ( typeof textValue == "undefined" )

   		   {

   		   textValue='';

   		   }

		idValue = CityNodes[count].getAttribute("id");

		optionItem = new Option( textValue, idValue,  false, false);

		CityList.options[CityList.length] = optionItem;

	}

	window.status = "";

	

}



// WORLDCITIES INSTITUTE END

function forum_collapse(forum_id,sSwitch)
{
if ( sSwitch == "+")
   {
   document.getElementById("topic_" + forum_id).style.display='block';
   
   document.getElementById("topic_switch_" + forum_id).innerHTML = '<a href=\"javascript: void(0);\" onclick=\"forum_collapse(\'' + forum_id +'\',\'-\')\">[-]</a>';
   
   }
else
   {
   
   document.getElementById("topic_" + forum_id).style.display='none';
   
   document.getElementById("topic_switch_" + forum_id).innerHTML = '<a href=\"javascript: void(0);\" onclick=\"forum_collapse(\'' + forum_id +'\',\'+\')\">[+]</a>';
   
   }
}

