/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function bzmjg__bind__sociable() {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: bzmjg__bind__sociable');
		}

		return true; // stubbed for now
		
		$.prettySociable({
			animationSpeed:		'fast', 			// fast/slow/normal
			opacity:			0.90, 				// Value between 0 and 1
			share_label:		'Drag to share', 	// Text displayed when a user rollover an item
			share_on_label: 	'Share on ', 		// Text displayed when a user rollover a website to share
			hideflash: 			false, 				// Hides all the flash object on a page, set to TRUE if flash appears over prettySociable
			hover_padding: 		0,
			websites: {
				facebook : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'Facebook',
					'url': 'http://www.facebook.com/share.php?u=',
					'icon':'images/prettySociable/large_icons/facebook.png',
					'sizes':{'width':70,'height':70}
				},
				twitter : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'Twitter',
					'url': 'http://twitter.com/home?status=',
					'icon':'images/prettySociable/large_icons/twitter.png',
					'sizes':{'width':70,'height':70}
				},
				delicious : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'Delicious',
					'url': 'http://del.icio.us/post?url=',
					'icon':'images/prettySociable/large_icons/delicious.png',
					'sizes':{'width':70,'height':70}
				},
				digg : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'Digg',
					'url': 'http://digg.com/submit?phase=2&url=',
					'icon':'images/prettySociable/large_icons/digg.png',
					'sizes':{'width':70,'height':70}
				},
				linkedin : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'LinkedIn',
					'url': 'http://www.linkedin.com/shareArticle?mini=true&ro=true&url=',
					'icon':'images/prettySociable/large_icons/linkedin.png',
					'sizes':{'width':70,'height':70}
				},
				reddit : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'Reddit',
					'url': 'http://reddit.com/submit?url=',
					'icon':'images/prettySociable/large_icons/reddit.png',
					'sizes':{'width':70,'height':70}
				},
				stumbleupon : {
					'active': true,
					'encode':false, // If sharing is not working, try to turn to false
					'title': 'StumbleUpon',
					'url': 'http://stumbleupon.com/submit?url=',
					'icon':'images/prettySociable/large_icons/stumbleupon.png',
					'sizes':{'width':70,'height':70}
				},
				tumblr : {
					'active': true,
					'encode':true, // If sharing is not working, try to turn to false
					'title': 'tumblr',
					'url': 'http://www.tumblr.com/share?v=3&u=',
					'icon':'images/prettySociable/large_icons/tumblr.png',
					'sizes':{'width':70,'height':70}
				}
			},
			urlshortener : {
//
//	To get started you'll need a free bit.ly user account and API key - sign up at:
//
//	http://bit.ly/account/register?rd=/
//
//	Quickly access your private API key once you are signed in at:
//
//	http://bit.ly/account/your_api_key
//
				bitly : {
					'active' : false
				}
			},
			tooltip: {
				offsetTop:0,
				offsetLeft: 15
			},
			popup: {
				width: 900,
				height: 500
			},
			callback: function(){} /* Called when prettySociable is closed */
		});

	}; // end bzmjg__bind__sociable() {

/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

Note:

	Functions, setDocSection, setDocSectionSecondaryNavigation,setDocSection_a_to_z, setDocSection_search, and
	setDocSectionArticleReview can be consolidated later.
	
History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function setDocSection( target_url, target_container ) {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: setDocSection');
		}

		target_container = '#' + target_container;

		$.ajax({
			type: 'GET', // change to POST later
			url: target_url,
//			data: { primary_doc_group_id: $('#primary_doc_group_id').val(), process_desc: 'Articles', lookup_type_desc: 'All Articles', view_by_identifier_1: '%', category_doc_group_id: '-1', subcategory_doc_group_id: '-1', results_doc_id: '-1', lookup_location_id: '-1', lookup_dept_id: '-1' },
			success: function(response) {
				$(target_container).html(response)

//
//	linkify() might be applied by function call, but
//	seems to be required here.
//
//	NOT YET in this situation.
//
//				.linkify().find('a').attr('target','_blank')
				.fadeIn(800, function() {
					bzmjg__bind__sociable();
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
					alert('readyState: ' + xhr.readyState + '\nstatus: ' + xhr.status);
					alert('responseText: ' + xhr.responseText);
					alert(thrownError);
				}
   			}
		});
	}; // end function setDocSection( target_url, target_container ) {

/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

Note:

	Functions, setDocSection, setDocSectionSecondaryNavigation, setDocSection_a_to_z, setDocSection_search, and
	setDocSectionArticleReview can be consolidated later.
	
History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function setDocSectionSecondaryNavigation( target_url, target_container ) {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: setDocSectionSecondaryNavigation');
		}

		target_container = '#' + target_container;

		$.ajax({
			type: 'GET', // change to POST later
			url: target_url,
//			data: { primary_doc_group_id: $('#primary_doc_group_id').val(), process_desc: 'Articles', lookup_type_desc: 'All Articles', view_by_identifier_1: '%', category_doc_group_id: '-1', subcategory_doc_group_id: '-1', results_doc_id: '-1', lookup_location_id: '-1', lookup_dept_id: '-1' },
			success: function(response) {
				$(target_container).html(response)

//
//	linkify() might be applied by function call, but
//	seems to be required here.
//
//	NOT YET in this situation.
//
//				.linkify().find('a').attr('target','_blank')
				.fadeIn(800, function() {
					bzmjg__bind__sociable();
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
					alert('readyState: ' + xhr.readyState + '\nstatus: ' + xhr.status);
					alert('responseText: ' + xhr.responseText);
					alert(thrownError);
				}
   			}
		});
	}; // end function setDocSectionSecondaryNavigation( target_url, target_container ) {

/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

Note:

	Functions, setDocSection, setDocSectionSecondaryNavigation, setDocSection_a_to_z, setDocSection_search, and
	setDocSectionArticleReview can be consolidated later.
	
History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function setDocSection_a_to_z( target_url, target_container ) {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: setDocSection_a_to_z');
		}

		target_container = '#' + target_container;
		target_url = target_url + "&process_desc=Membership Directory&lookup_type_desc=All Members A To Z";

		$.ajax({
			type: 'GET', // change to POST later
			url: target_url,
//			data: { primary_doc_group_id: $('#primary_doc_group_id').val(), process_desc: 'Articles', lookup_type_desc: 'All Articles', view_by_identifier_1: '%', category_doc_group_id: '-1', subcategory_doc_group_id: '-1', results_doc_id: '-1', lookup_location_id: '-1', lookup_dept_id: '-1' },
			success: function(response) {
				$(target_container).html(response)

//
//	linkify() might be applied by function call, but
//	seems to be required here.
//
//	NOT YET in this situation.
//
//				.linkify().find('a').attr('target','_blank')
				.fadeIn(800, function() {
					bzmjg__bind__sociable();
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
					alert('readyState: ' + xhr.readyState + '\nstatus: ' + xhr.status);
					alert('responseText: ' + xhr.responseText);
					alert(thrownError);
				}
   			}
		});
	}; // end function setDocSection_a_to_z( target_url, target_container ) {

/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

Note:

	Functions, setDocSection, setDocSectionSecondaryNavigation, setDocSection_a_to_z, setDocSection_search, and
	setDocSectionArticleReview can be consolidated later.
	
History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function setDocSection_search( target_url, target_container ) {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: setDocSection_search');
		}

		target_container = '#' + target_container;
		target_url = target_url + "&view_by_identifier_1=" + document.forms["bzmjg__form__party_directory__search"].view_by_identifier_1.value + "&lookup_location_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_location_id.value + "&lookup_dept_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_dept_id.value;
		
		$.ajax({
			type: 'GET', // change to POST later
			url: target_url,
//			data: { primary_doc_group_id: $('#primary_doc_group_id').val(), process_desc: 'Articles', lookup_type_desc: 'All Articles', view_by_identifier_1: '%', category_doc_group_id: '-1', subcategory_doc_group_id: '-1', results_doc_id: '-1', lookup_location_id: '-1', lookup_dept_id: '-1' },
			success: function(response) {
				$(target_container).html(response)

//
//	linkify() might be applied by function call, but
//	seems to be required here.
//
//	NOT YET in this situation.
//
//				.linkify().find('a').attr('target','_blank')
				.fadeIn(800, function() {
					bzmjg__bind__sociable();
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
					alert('readyState: ' + xhr.readyState + '\nstatus: ' + xhr.status);
					alert('responseText: ' + xhr.responseText);
					alert(thrownError);
				}
   			}
		});
	}; // end function setDocSection_search( target_url, target_container ) {

/*
********************************************************************************************************************************

Purpose:
	
	Supply content by request.

Note:

	Functions, setDocSection, setDocSectionSecondaryNavigation, setDocSection_a_to_z, setDocSection_search, and
	setDocSectionArticleReview can be consolidated later.
	
History:

	ver		date			notes																				name
	----------------------------------------------------------------------------------------------------------------------------
	1.1		11-01-2010		Creation.																			billy

Testing:

********************************************************************************************************************************
*/

	function setDocSectionArticleReview( target_url, target_container ) {
		if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
			alert('ONCLICK: setDocSectionArticleReview');
		}

		target_container = '#' + target_container;
		target_url = target_url + "&view_by_identifier_1=" + document.forms["bzmjg__form__party_directory__search"].view_by_identifier_1.value + "&lookup_location_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_location_id.value + "&lookup_dept_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_dept_id.value;
		
		$.ajax({
			type: 'GET', // change to POST later
			url: target_url,
//			data: { primary_doc_group_id: $('#primary_doc_group_id').val(), process_desc: 'Articles', lookup_type_desc: 'All Articles', view_by_identifier_1: '%', category_doc_group_id: '-1', subcategory_doc_group_id: '-1', results_doc_id: '-1', lookup_location_id: '-1', lookup_dept_id: '-1' },
			success: function(response) {
				$(target_container).html(response)

//
//	linkify() might be applied by function call, but
//	seems to be required here.
//
//	NOT YET in this situation.
//
//				.linkify().find('a').attr('target','_blank')
				.fadeIn(800, function() {
					bzmjg__bind__sociable();
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				if (bzmjg__config.bzmjg__debug__bind_behaviors == 'Y') {
					alert('readyState: ' + xhr.readyState + '\nstatus: ' + xhr.status);
					alert('responseText: ' + xhr.responseText);
					alert(thrownError);
				}
   			}
		});
	}; // end setDocSectionArticleReview( target_url, target_container ) {

// --------------------------------------------------------------------------------------------------
//
//	Purpose:
//		This function is used to update the page title.
//
//	History:
//		ver		date			notes												name
// 		-------------------------------------------------------------------------------------------
//		1.0		09-28-2009		Creation, on Halima's 17th earth day.				jahlife
//
// --------------------------------------------------------------------------------------------------

function changeTitle( title ) {
	document.title = title;
}

// --------------------------------------------------------------------------------------------------
//
//	Purpose:
//		Shipping a function call by url.  We are using this function to handle primary navigation
//		menu events.
//
//	History:
//		ver		date			notes												name
// 		-------------------------------------------------------------------------------------------
//		1.0		11-13-2007		Creation.											jahlife
//
// --------------------------------------------------------------------------------------------------

function processPrimaryNavigationMenu(url,callback) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	try {
		req.open("GET", url, true);
		req.onreadystatechange = function() {
// if req shows "loaded"
			if (req.readyState == 4) {
// if "OK"
				if (req.status == 200) {
					var temp = new Array();
					temp.push(req.responseText);
					callback.apply(callback,temp);
				} else {
					alert("Please refresh your browser window. \n" + req.statusText);
				}
			}
		};
	req.send(null);
	} catch(e) {
		alert(e.message);
	}
}

function setDocSection__PRE_JQUERY(url,id) {
	var callback = function(result) {
	document.getElementById(id).innerHTML = result;
	}
	processPrimaryNavigationMenu(url, callback);
}

function setDocSection_search__PRE_JQUERY(url, id) {
	var urlString = url + "&view_by_identifier_1=" + document.forms["bzmjg__form__party_directory__search"].view_by_identifier_1.value + "&lookup_location_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_location_id.value + "&lookup_dept_id=" + document.forms["bzmjg__form__party_directory__search"].lookup_dept_id.value;
//	var urlString = url + "&view_by_identifier_1=" + document.forms[bzmjg__formname].view_by_identifier_1.value + "&lookup_location_id=" + document.forms[bzmjg__formname].lookup_location_id.value + "&lookup_dept_id=" + document.forms[bzmjg__formname].lookup_dept_id.value;
	var callback = function(result) {
	document.getElementById(id).innerHTML = result;
	}
	processPrimaryNavigationMenu(urlString, callback);
}

function setDocSection_a_to_z__PRE_JQUERY(url,id) {
	var urlString = url + "&process_desc=Membership Directory&lookup_type_desc=All Members A To Z";
	var callback = function(result) {
	document.getElementById(id).innerHTML = result;
	}
	processPrimaryNavigationMenu(urlString, callback);
}

// --------------------------------------------------------------------------------------------------
//
//	Purpose:
//		Shipping a function call by url.  We are using this function to handle secondary navigation
//		menu events.
//
//	History:
//		ver		date			notes												name
// 		-------------------------------------------------------------------------------------------
//		1.0		11-13-2007		Creation.											jahlife
//
// --------------------------------------------------------------------------------------------------

// javascript Document
function processSecondaryNavigationMenu(url,callback) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	try {
		req.open("GET", url, true);
		req.onreadystatechange = function() {
// only if req shows "loaded"
			if (req.readyState == 4) {
// only if "OK"
				if (req.status == 200) {
					var temp = new Array();
					temp.push(req.responseText);
					callback.apply(callback,temp);
				} else {
					alert("Please refresh your browser window. \n" + req.statusText);
				}
			}
		};
	req.send(null);
	} catch(e) {
		alert(e.message);
	}
}

function setDocSectionSecondaryNavigation__PRE_JQUERY(url,id) {
      var callback = function(result) {
 
            var divId = document.getElementById(id);
            divId.innerHTML = result;
            var x = divId.getElementsByTagName("script");
            var h = document.getElementsByTagName("head")[0];
//            alert(x.length + ' script blocks found');
            for(var i=0;i<x.length;i++)
            {
                  var s = document.createElement("script");
                  s.type="text/javascript";
                   if(x[i].src)
                   {
                     s.src = x[i].src;
                   }
                   if(x[i].text)
                   {
                      //check for IE
                      if(window.ActiveXObject)
                     {
                        s.text=x[i].text;
                     }
                     else
                     {
                       s.appendChild(document.createTextNode(x[i].text));
                     }
                   }
                  h.appendChild(s);
            }

      }
      processArticleCategoryReview(url, callback);
}

function processArticleCategoryReview(url,callback) {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	try {
		req.open("GET", url, true);
		req.onreadystatechange = function() {
// only if req shows "loaded"
			if (req.readyState == 4) {
// only if "OK"
				if (req.status == 200) {
					var temp = new Array();
					temp.push(req.responseText);
					callback.apply(callback,temp);
				} else {
					alert("Please refresh your browser window. \n" + req.statusText);
				}
			}
		};
	req.send(null);
	} catch(e) {
		alert(e.message);
	}
}

function setDocSectionArticleReview__PRE_JQUERY(url,id) {
      var callback = function(result) {
 
            var divId = document.getElementById(id);
            divId.innerHTML = result;
            var x = divId.getElementsByTagName("script");
            var h = document.getElementsByTagName("head")[0];
//            alert(x.length + ' script blocks found');
            for(var i=0;i<x.length;i++)
            {
                  var s = document.createElement("script");
                  s.type="text/javascript";
                   if(x[i].src)
                   {
                     s.src = x[i].src;
                   }
                   if(x[i].text)
                   {
                      //check for IE
                      if(window.ActiveXObject)
                     {
                        s.text=x[i].text;
                     }
                     else
                     {
                       s.appendChild(document.createTextNode(x[i].text));
                     }
                   }
                  h.appendChild(s);
            }
      }
      processArticleCategoryReview(url, callback);
}


