home = function() {
	window.location=cfg.urlRoot;
	return false;
}

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

string_trim = function (sInString) {
	if ( sInString ) {
		sInString = sInString.replace( /^\s+/g, "" );// strip leading
		return sInString.replace( /\s+$/g, "" );// strip trailing
	}
}

//Date changing handle
date_selector_handle = function(monthID, dayID, yearID) {

	theDate = new Date($F( yearID ),$F( monthID ),0);

	var dayInMonth = parseInt(theDate.getDate());

	dayObj = $( dayID );
	saveDate = $F( dayID );

	if(saveDate > dayInMonth) saveDate = dayInMonth;

	var startIndex = 1
	while( dayObj.length > startIndex)
		dayObj.options[ startIndex ] = null;

	for(var i=startIndex;i<=dayInMonth;i++) {
		dayObj.options[i] = new Option(i, i);
		if(saveDate == dayObj.options[i].value)
			dayObj.options[i].selected = true;
	}//end for loop
}

random_number = function() {
	var n = Math.floor(Math.random() * 99999);
	return n;
}

form_check_all = function( ref, formName ) {
	var checkboxes = $( formName ).getInputs( 'checkbox' );
	for(var i=0; i<checkboxes.length; i++) checkboxes[i].checked = ref.checked
}

form_check_to = function( formName, chk ) {
	var checkboxes = $( formName ).getInputs( 'checkbox' );
	for(var i=0; i<checkboxes.length; i++) checkboxes[i].checked = chk
}

ShowGlobalStatus = function( msg ) {
	$('globalStatus').show();
	$('globalStatus').update( msg );
}

HideGlobalStatus = function() {
	$('globalStatus').hide();
	$('globalStatus').update('');
}
ViewGlobalPages = function (container, page ) {
	var url = cfg.urlSrc + '/general_respond.php'
	new Ajax.Request ( url, {
		method: "get",
		parameters: {act: 'viewGlobals', page: page},
		onCreate: function() {
			$(container).setStyle({
				height: ''
			});
		},
		onComplete: function(transport) {
			if( $(container).getHeight() < 400 ) {
				$(container).setStyle({
					height: '400px'
				});
			}
			/*if( page == 'howitworks' ) {
				$(container).setStyle({
					height: '717px'
				});
			}*/
			$(container).update('<div id=contents>'+transport.responseText+'</div>');
		}
	});

	return false
}
ViewNewsPages = function (container, page ) {

	var url = cfg.urlSrc + '/general_respond.php'
	new Ajax.Request ( url, {
		method: "get",
		parameters: {act: 'viewNews', page: page},
		onCreate: function() {
			$(container).setStyle({
				height: ''
			});
		},
		onComplete: function(transport) {
			if( $(container).getHeight() < 400 ) {
				$(container).setStyle({
					height: '400px'
				});
			}
			$(container).update('<div id=contents>'+transport.responseText+'</div>');
		}
	});

	return false
}

ViewGlobalPopup = function ( page ) {

	var url = cfg.urlSrc + '/general_respond.php'
	new Ajax.Request ( url, {
		method: "get",
		parameters: {act: 'viewGlobals', page: page},
		onCreate: function() {
			ShowGlobalStatus('Loading...');
		},
		onComplete: function(transport) {
			HideGlobalStatus();
	
			if( transport.responseText ) {
				MB_ShowCenterMessage( transport.responseText, {
					width: ModalDBox.pageWidth()-150,
					height: ModalDBox.pageHeight()-200
				});
			}
		}
	});

	return false
}

swImage = function( o, imgSrc ) {
	$(o).src = imgSrc;
}

ViewYouTube = function( youID, width, height ) {
	var url = cfg.urlSrc + '/general_respond.php'
	new Ajax.Request (url, {
		method: "get",
		parameters: {act: 'viewYouTube', youID: youID, width: width, height: height},
		onComplete: function(transport) {
			if( (/object/).test( transport.responseText  ) )
				MB_ShowCenterMessage( transport.responseText, {
					width: width,
					height: height+10,
					onOK: function() {
						ModalDBox.hm();
					}
				});
		}
	});

	return false
}
ViewYouTube2 = function( youID, width, height ) {

	MB_ShowCenterMessage( "<div id=myplayer>You need Flash player 8+ and JavaScript enabled to view this video.</div>", {
		width: width,
		height: height+10,
		onCreate: function() {
			var flashvars = {};
			var params = {};
			var attributes = {};
			attributes.id = "myvideo";
			params.allowScriptAccess = "always";
			swfobject.embedSWF("http://www.youtube.com/v/"+youID+"&enablejsapi=1&playerapiid=myplayer", "myplayer", "425", "344", "9.0.0", false, flashvars, params, attributes);
		},
		onOK: function() {
			if($('myvideo')) {
				$('myvideo').stopVideo();
				$('myvideo').clearVideo();
			}
			ModalDBox.hm();
		}
	});

	return false
}


ViewFlash = function( vidURL, width, height ) {
	MB_ShowCenterMessage( "<div id=myplayer>You need Flash player 8+ and JavaScript enabled to view this video.</div>", {
		width: width,
		height: height+10,
		onCreate: function() {
			var flashvars = {};
			var params = {};
			var attributes = {};
			attributes.id = "myvideo";
			params.allowScriptAccess = "always";
			swfobject.embedSWF( vidURL, "myplayer", width, height, "9.0.0", false, flashvars, params, attributes);
		},
		onOK: function() {
			ModalDBox.hm();
		}
	});

	return false
}

/*window.onscroll = function() {
	var h = document.viewport.getHeight()
	var w = document.viewport.getWidth()
	var t = document.viewport.getScrollOffsets().top
	var l = document.viewport.getScrollOffsets().left
	var o = $(document.body).clientWidth
	var o2 = $(document.body).clientHeight
	window.status = 'w: '+w+', h: '+h+', top: '+t+', left: '+l+', w2: '+o+', h2: '+o2
}

window.onresize = function() {
	var h = document.viewport.getHeight()
	var w = document.viewport.getWidth()
	var t = document.viewport.getScrollOffsets().top
	var l = document.viewport.getScrollOffsets().left
	var o = $(document.body).clientWidth
	var o2 = $(document.body).clientHeight
	window.status = 'w: '+w+', h: '+h+', top: '+t+', left: '+l+', w2: '+o+', h2: '+o2
}*/
