// JSON Parsing
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3(!l.m){m={}}(5(){5 f(n){7 n<10?\'0\'+n:n}3(6 S.w.p!==\'5\'){S.w.p=5(a){7 l.1o()+\'-\'+f(l.1p()+1)+\'-\'+f(l.1q())+\'T\'+f(l.1r())+\':\'+f(l.1s())+\':\'+f(l.1t())+\'Z\'};M.w.p=1u.w.p=1v.w.p=5(a){7 l.1w()}}q e=/[\\1x\\U\\V-\\W\\X\\Y\\11\\12-\\13\\14-\\15\\17-\\18\\19\\1a-\\1b]/g,G=/[\\\\\\"\\1y-\\1z\\1A-\\1B\\U\\V-\\W\\X\\Y\\11\\12-\\13\\14-\\15\\17-\\18\\19\\1a-\\1b]/g,8,x,1c={\'\\b\':\'\\\\b\',\'\\t\':\'\\\\t\',\'\\n\':\'\\\\n\',\'\\f\':\'\\\\f\',\'\\r\':\'\\\\r\',\'"\':\'\\\\"\',\'\\\\\':\'\\\\\\\\\'},o;5 H(b){G.1d=0;7 G.N(b)?\'"\'+b.y(G,5(a){q c=1c[a];3(6 c===\'I\'){7 c}7\'\\\\u\'+(\'1e\'+a.1f(0).1g(16)).1h(-4)})+\'"\':\'"\'+b+\'"\'}5 z(a,b){q i,k,v,9,A=8,h,2=b[a];3(2&&6 2===\'B\'&&6 2.p===\'5\'){2=2.p(a)}3(6 o===\'5\'){2=o.J(b,a,2)}1C(6 2){C\'I\':7 H(2);C\'K\':7 1D(2)?M(2):\'D\';C\'1E\':C\'D\':7 M(2);C\'B\':3(!2){7\'D\'}8+=x;h=[];3(6 2.9===\'K\'&&!2.1F(\'9\')){9=2.9;E(i=0;i<9;i+=1){h[i]=z(i,2)||\'D\'}v=h.9===0?\'[]\':8?\'[\\n\'+8+h.L(\',\\n\'+8)+\'\\n\'+A+\']\':\'[\'+h.L(\',\')+\']\';8=A;7 v}3(o&&6 o===\'B\'){9=o.9;E(i=0;i<9;i+=1){k=o[i];3(6 k===\'I\'){v=z(k,2);3(v){h.1i(H(k)+(8?\': \':\':\')+v)}}}}O{E(k 1j 2){3(1k.1l.J(2,k)){v=z(k,2);3(v){h.1i(H(k)+(8?\': \':\':\')+v)}}}}v=h.9===0?\'{}\':8?\'{\\n\'+8+h.L(\',\\n\'+8)+\'\\n\'+A+\'}\':\'{\'+h.L(\',\')+\'}\';8=A;7 v}}3(6 m.P!==\'5\'){m.P=5(a,b,c){q i;8=\'\';x=\'\';3(6 c===\'K\'){E(i=0;i<c;i+=1){x+=\' \'}}O 3(6 c===\'I\'){x=c}o=b;3(b&&6 b!==\'5\'&&(6 b!==\'B\'||6 b.9!==\'K\')){1m 1n 1G(\'m.P\');}7 z(\'\',{\'\':a})}}3(6 m.Q!==\'5\'){m.Q=5(c,d){q j;5 R(a,b){q k,v,2=a[b];3(2&&6 2===\'B\'){E(k 1j 2){3(1k.1l.J(2,k)){v=R(2,k);3(v!==1H){2[k]=v}O{1I 2[k]}}}}7 d.J(a,b,2)}e.1d=0;3(e.N(c)){c=c.y(e,5(a){7\'\\\\u\'+(\'1e\'+a.1f(0).1g(16)).1h(-4)})}3(/^[\\],:{}\\s]*$/.N(c.y(/\\\\(?:["\\\\\\/1J]|u[0-1K-1L-F]{4})/g,\'@\').y(/"[^"\\\\\\n\\r]*"|1M|1N|D|-?\\d+(?:\\.\\d*)?(?:[1O][+\\-]?\\d+)?/g,\']\').y(/(?:^|:|,)(?:\\s*\\[)+/g,\'\'))){j=1P(\'(\'+c+\')\');7 6 d===\'5\'?R({\'\':j},\'\'):j}1m 1n 1Q(\'m.Q\');}}})();',62,115,'||value|if||function|typeof|return|gap|length||||||||partial||||this|JSON||rep|toJSON|var||||||prototype|indent|replace|str|mind|object|case|null|for||escapeable|quote|string|call|number|join|String|test|else|stringify|parse|walk|Date||u00ad|u0600|u0604|u070f|u17b4|||u17b5|u200c|u200f|u2028|u202f||u2060|u206f|ufeff|ufff0|uffff|meta|lastIndex|0000|charCodeAt|toString|slice|push|in|Object|hasOwnProperty|throw|new|getUTCFullYear|getUTCMonth|getUTCDate|getUTCHours|getUTCMinutes|getUTCSeconds|Number|Boolean|valueOf|u0000|x00|x1f|x7f|x9f|switch|isFinite|boolean|propertyIsEnumerable|Error|undefined|delete|bfnrt|9a|fA|true|false|eE|eval|SyntaxError'.split('|'),0,{}));

// Global
function confirm(message, callback)
{   
	messageSplit = message.split("|");
	//     // confirmMessageObj.hideSelects(event);
	jQuery("#vPromptTextarea").hide();
	jQuery("#vPromptInput").hide();
	jQuery('#confirm_message .cancel').show();
	jQuery('#confirm_message_wrap').show();
	jQuery('#confirm_message_wrap').bind('click', function(event) { confirmMessage.hideOverlay(false); });
	jQuery('#confirm_message h2').html(messageSplit[0]);
    
    if (messageSplit[1])
    {
        jQuery('#confirm_message h3').html(messageSplit[1]);
    }
    else
    {
        jQuery('#confirm_message h3').html('');
    }

	jQuery(document).keyup(function(event)
	{
		if (jQuery(confirmMessage.overlay).is(":visible"))
		{
			if (event.keyCode == 13)
			{
				confirmMessage.hideOverlay(true);
			}
			else if (event.keyCode == 27)
			{
				confirmMessage.hideOverlay(false);			
			}			
		}
	});

	pageSize = confirmMessage.getPageSize();

	if (confirmMessage.overlay)
	{
		confirmMessage.overlay.style.width = pageSize[0] + 'px';
		confirmMessage.overlay.style.height = pageSize[1] + 'px';		
	}

	confirmMessage.setOverlaySize();
	jQuery(window).scroll(function() { confirmMessage.setOverlaySize(); });
	jQuery(window).resize(function() { confirmMessage.setOverlaySize(); });
	confirmMessage.callback = callback;
	hideObjectEmbedTags();
}

function hideGlobalErrorAnnouncement()
{
    x_hideGlobalAnnouncement('', function(result){});    
}
function hideGlobalFeatureAnnouncement()
{
    x_hideGlobalAnnouncement(':feature',function(result){});    
}
function hideGlobalActivityAnnouncement()
{
    x_hideGlobalAnnouncement(':activity',function(result){});    
}

function toggleLayers(event)
{
	swapText    = event.target.title;
	currentText = event.target.innerHTML;
	
	event.target.title     = currentText;
	event.target.innerHTML = swapText;
	clickTarget = jQuery(event.target);

	if (clickTarget.hasClass('visible'))
	{
		clickTarget.addClass('hidden').removeClass('visible');
	}	
	else
	{
		clickTarget.addClass('visible').removeClass('hidden');
	}
	
	layerArray = event.target.id.split(',');
	
	for (var i in layerArray)
	{		
		jQuery(layerArray[i]).toggle();
	}
}

function showDropdown ()
{
    jQuery('#vnav_5').addClass('open');
	jQuery('#vnav_5 ul').show();
}

function hideDropdown ()
{
    jQuery('#vnav_5').removeClass('open');
	jQuery('#vnav_5 ul').hide();
}

function fadeObjects()
{
    eventTimeout = window.setTimeout("jQuery('.fade').fadeOut('slow');window.clearTimeout(eventTimeout);", 3000);
	
	return false;
}

function ffSearch()
{
   if (jQuery.browser.mozilla)
   {
       // alert(jQuery.browser.mozilla);
       jQuery('.search_wrapper').addClass('firefox');
   }
}

function reattachDeleteEvents()
{
    jQuery('.delete_link').unbind();
    jQuery('.delete_link_2').unbind();
    
    attachDeleteEvents();
}

delete_link = function()
{
    document.getElementById('delete_form').delete_id.value = attachDeleteEvents.deleteId;
    document.getElementById('delete_form').submit();            
};

delete_link_2 = function()
{
    document.getElementById('delete_form_2').delete_id.value = attachDeleteEvents.deleteId;
    document.getElementById('delete_form_2').submit();                
};

function AttachDeleteEvents()
{
    attachDeleteEventsObj = this;
    previewImageArray     = [];

	pic = new Image(35,35);
	
	pic.src = '/_assets/_graphics/_hub/bg-preview_top_left.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-preview_top_right.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-preview_bottom_left.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-preview_bottom_right.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-preview_bottom_middle.png';
	previewImageArray.push(pic);

	pic.src = '/_assets/_graphics/_global/bg-plus_bar.gif';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-profile_type_overlay_top.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-profile_type_overlay_repeat.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_global/bg-profile_type_overlay_bottom_blue.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_global/plus_buttons.jpg';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_frontend/bg-index_subhead.gif';
	previewImageArray.push(pic);

	// Object Deletion
    jQuery('.delete_link').click(function(event)
    {
		actionWord                     = 'delete this';
		attachDeleteEventsObj.deleteId = event.target.id.replace('delete_id_', '');
		
		messageSplit = this.title.split("|");
		subMessage   = '';
		
		if (messageSplit[0])
		{
			actionWord = messageSplit[0];   
		}

		if (messageSplit[1])
		{
			subMessage = '|'+messageSplit[1];   
		}
		
		confirm('Are you sure you want to '+actionWord+'?'+subMessage, delete_link);
		        
        return false;
    });
    
    jQuery('.delete_link_2').click(function(event)
    {
		actionWord                     = 'delete this';
		attachDeleteEventsObj.deleteId = event.target.id.replace('delete_id_', '');
				
		if (this.title)
		{
			actionWord = this.title;   
		}
			
		confirm('Are you sure you want to '+actionWord+'?', delete_link_2);
	           
        return false;
    });

	// Preview Image
	jQuery('.preview_link').mouseover(function(event)
	{	
		coords       = getMouseCoords(event);		
		previewId    = this.id.replace('preview_link_', '');
		previewImage = jQuery('#preview_image_'+previewId);
		imageWidth   = previewImage.css('width').replace('px', '');
		imageHeight  = previewImage.css('height').replace('px', '');
		imageX       = this.offsetLeft + this.parentNode.offsetLeft + (this.offsetWidth/2) - (imageWidth/2) - 11;
		imageY       = this.parentNode.offsetTop - (imageHeight) - 25;

		previewImage.css({visibility:'visible',left:imageX,top:imageY});        
		
		// previewImage.show();
				
		return false;
	});
	
	jQuery('.preview_link').mouseout(function(event)
	{
		previewId = this.id.replace('preview_link_', '');
		jQuery('#preview_image_'+previewId).css({visibility:'hidden'});
		
		return false;
	});
}      

getMouseCoords = function (e)
{
    e = window.event ? window.event : e;

    // Mozilla or Safari
    if(e.pageX || e.pageY)
    {
        return {
            x:e.pageX,
            y:e.pageY
        };
    }

    // IE6+
    if( document.documentElement)
    {
        return {
            x:e.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft,
            y:e.clientY + document.documentElement.scrollTop  - document.documentElement.clientTop
        };
    }

    // Other 
    return {
        x:e.clientX + document.body.scrollLeft - document.body.clientLeft,
        y:e.clientY + document.body.scrollTop  - document.body.clientTop
    };
};

// Please Update
characterCount = function (textarea, countField, limit)
{	
	if (textarea.value.length > limit)
	{
		document.getElementById(countField).innerHTML = 0;		
				
		textarea.value = textarea.value.substr(0,limit); 
	}
	else
	{
		document.getElementById(countField).innerHTML = limit - textarea.value.length;   
	}
};

function resizeImages()
{
    jQuery('.column_left img').each(function()
    {
        // alert(this.width);
        if (this.width > 500 && (jQuery(this).hasClass('no_resize')) == false)
        {
            this.style.width = '500px';
            this.style.height = 'auto';
        }
    });
    jQuery('#topic img').each(function()
    {
        // alert(this.width);
        if (this.width > 500)
        {
            this.style.width = '500px';
            this.style.height = 'auto';
        }
    });
}

window.onload = function ()
{
    resizeImages();
};

function preventNav(msg)
{
	if (!msg)
	{
		msg = 'If so, your changes will be lost.';
	}

    window.onbeforeunload = function(evt) { 
        e = window.event ? window.event : evt;
        e.returnValue = msg;
    
        return msg;
    };
}

function clearPreventNav()
{
    window.onbeforeunload = function(){};    
}

function ConfirmMessage(wrap, form)
{
    confirmMessageObj = this;
    this.overlay     = jQuery(wrap).get(0);
    this.overlayForm = jQuery(form).get(0);
    
    previewImageArray     = [];

	pic = new Image(35,35);
	
	pic.src = '/_assets/_graphics/_hub/bg-confirm_overlay_bottom.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-confirm_overlay_top.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_hub/bg-confirm_overlay_repeat.png';
	previewImageArray.push(pic);
	pic.src = '/_assets/_graphics/_global/bg-transparent_90.png';
	previewImageArray.push(pic);

	jQuery(wrap).click(function(event) { confirmMessageObj.hideOverlay(false); });
	jQuery('.custom_message').click(function(event) { event.stopPropagation(); });
	jQuery('#confirm_message').click(function(event) { event.stopPropagation(); });

	pageSize = this.getPageSize();

	if (this.overlay)
	{
		this.overlay.style.width = pageSize[0] + 'px';
		this.overlay.style.height = pageSize[1] + 'px';		
	}
}

function prompt(message, textarea, callback)
{	
	messageSplit = message.split("|");

	jQuery("#vPromptInput").hide();
	jQuery("#vPromptTextarea").show();
	jQuery("#vPromptTextarea").html(textarea); 
	jQuery('#confirm_message .cancel').show();
	jQuery('#confirm_message_wrap').show();
	jQuery('#confirm_message_wrap').bind('click', function(event) { confirmMessage.hideOverlay();jQuery("#vPromptTextarea").hide(); });
	jQuery('#confirm_message h2').html(messageSplit[0]);

    if (messageSplit[1])
    {
        jQuery('#confirm_message h3').html(messageSplit[1]);
    }
    else
    {
        jQuery('#confirm_message h3').html('');
    }
	
    confirmMessage.setOverlaySize();
    jQuery(window).scroll(function() { confirmMessage.setOverlaySize(); });
    jQuery(window).resize(function() { confirmMessage.setOverlaySize(); });

	if (typeof callback !== undefined)
	{
		confirmMessage.callback = callback;
	}
	
	jQuery(document).keyup(function(event)
	{
		if (jQuery(confirmMessage.overlay).is(":visible"))
		{
			if (event.keyCode == 13)
			{
				confirmMessage.hideOverlay(true);
			}
			else if (event.keyCode == 27)
			{
				confirmMessage.hideOverlay(false);			
			}			
		}
	});

	jQuery("#vPromptTextarea").focus();
	hideObjectEmbedTags();
}

function vPrompt(message, callback, defaultText)
{
	messageSplit = message.split("|");
	
	jQuery("#vPromptTextarea").hide();
	jQuery("#vPromptInput").show();
	jQuery("#vPromptInput").val(''); 

	if (defaultText)
	{
		jQuery("#vPromptInput").val(defaultText); 
	}
	
	jQuery('#confirm_message .cancel').show();
    jQuery('#confirm_message_wrap').show();
    jQuery('#confirm_message_wrap').bind('click', function(event) { confirmMessage.hideOverlay(); });
    jQuery('#confirm_message h2').html(messageSplit[0]);
    
    if (messageSplit[1])
    {
        jQuery('#confirm_message h3').html(messageSplit[1]);
    }
    else
    {
        jQuery('#confirm_message h3').html('');
    }

	jQuery(document).keyup(function(event)
	{
		if (jQuery(confirmMessage.overlay).is(":visible"))
		{
			if (event.keyCode == 13)
			{
				confirmMessage.hideOverlay(true);
			}
			else if (event.keyCode == 27)
			{
				confirmMessage.hideOverlay(false);			
			}			
		}
	});

    confirmMessage.setOverlaySize();
    jQuery(window).scroll(function() { confirmMessage.setOverlaySize(); });
    jQuery(window).resize(function() { confirmMessage.setOverlaySize(); });
    confirmMessage.callback = callback;
	jQuery("#vPromptInput").focus();
	hideObjectEmbedTags();
}

function vAlert(message, callback, linkObj)
{   
	ConfirmMessage.linkObj = linkObj;
	messageSplit = message.split("|");
    // confirmMessageObj.hideSelects(event);
    
	jQuery("#vPromptInput").hide();
	jQuery('#confirm_message .cancel').hide();
    jQuery('#confirm_message_wrap').show();
    jQuery('#confirm_message_wrap').bind('click', function(event) { confirmMessage.hideOverlay(); });
    jQuery('#confirm_message h2').html(messageSplit[0]);
    
    if (messageSplit[1])
    {
        jQuery('#confirm_message h3').html(messageSplit[1]);
    }
    else
    {
        jQuery('#confirm_message h3').html('');
    }


	jQuery(document).keyup(function(event)
	{
		if (jQuery(confirmMessage.overlay).is(":visible"))
		{
			if (event.keyCode == 13)
			{
				confirmMessage.hideOverlay(true);
			}
			else if (event.keyCode == 27)
			{
				confirmMessage.hideOverlay(false);			
			}			
		}
	});
	
    confirmMessage.setOverlaySize();
    jQuery(window).scroll(function() { confirmMessage.setOverlaySize(); });
    jQuery(window).resize(function() { confirmMessage.setOverlaySize(); });

	if (typeof(callback) != 'undefined')
	{
		confirmMessage.callback = callback;   
	}
	
	hideObjectEmbedTags();
}   

ConfirmMessage.prototype.hideOverlay = function (hideStatus)
{
    jQuery(window).scroll(function() {  });
    jQuery(window).resize(function() {  });

    jQuery(this.overlay).hide();  
	showObjectEmbedTags();
    
    if (hideStatus == true)
    {
		if (typeof this.callback == 'function')
		{
			this.callback();   
		}
    }
};

useHref = function()
{
	window.location = ConfirmMessage.linkObj;
};

ConfirmMessage.prototype.setOverlaySize = function ()
{
	if(this.overlay)
	{
		var overlayStyle           = this.overlay.style;
		var arrWinSizeAndScroll    = this.getWinSizeAndScroll();
		// overlayStyle.width         = arrWinSizeAndScroll[0] + arrWinSizeAndScroll[2] + "px";
		// overlayStyle.height        = arrWinSizeAndScroll[1] + arrWinSizeAndScroll[3] + "px";
		this.overlayForm.style.top = (arrWinSizeAndScroll[1]/2 + arrWinSizeAndScroll[3] - this.overlayForm.offsetHeight/2) + "px";
	}
};

ConfirmMessage.prototype.getWindowSize = function()
{
	var windowWidth, windowHeight;
	
	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		}
		else
		{
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth  = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth  = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	return [windowWidth,windowHeight];
};

ConfirmMessage.prototype.getPageSize = function()
{
        
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
};

ConfirmMessage.prototype.getWinSizeAndScroll = function ()
{
	// pageSize = this.getPageSize();
	// this.overlay.style.width = pageSize[0] + 'px';
	// this.overlay.style.height = pageSize[1] + 'px';
	
	var intWidth   = document.body.offsetWidth;
	var intHeight  = (typeof window.innerHeight != "undefined")? window.innerHeight : (document.documentElement && document.documentElement.clientHeight > 0)? document.documentElement.clientHeight : document.body.clientHeight;		
	var intXScroll = (typeof window.pageXOffset != "undefined")? window.pageXOffset : document.body.scrollLeft;		
	var intYScroll = (typeof window.window.pageYOffset != "undefined")? window.window.pageYOffset : (document.documentElement && document.documentElement.scrollTop > 0)? document.documentElement.scrollTop : document.body.scrollTop;
	
	return [intWidth, intHeight, intXScroll, intYScroll];
};

function addslashes(str)
{
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str)
{
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

function getFlashMovie (movieName)
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function showContributePopup ()
{
	if (jQuery('.custom_message_wrap.contribute_to_virb').is(":visible"))
	{
		jQuery('.custom_message_wrap.contribute_to_virb').hide();	
	}
	else
	{
		jQuery('.custom_message_wrap').hide();
	    contributePopup = new ConfirmMessage('.custom_message_wrap.contribute_to_virb','.custom_message_wrap.contribute_to_virb .custom_message');
	    jQuery('.custom_message_wrap.contribute_to_virb').show();
	    contributePopup.setOverlaySize();
	    jQuery(window).scroll(function() { contributePopup.setOverlaySize(); });
	    jQuery(window).resize(function() { contributePopup.setOverlaySize(); });			
	}
}

function checkKeycode(e)
{
	var keycode;
	
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	
	switch(keycode)
	{
		case 187:

		showContributePopup ();

		break;
		
		case 61:

		showContributePopup ();

		break;

   }
}


//////////////////////////////////////////////////
// SUBMIT A BUG REPORT
//////////////////////////////////////////////////

function bugReport()
{
	var form = jQuery('#bug_report').find('form');
	var textarea = form.find('textarea');
	var default_value = textarea.val();
	var submit = form.find('#submit_bug_report');
	var more = jQuery('p.more');
	var inputs = form.find('input.text');
	var cancel = form.find('p.cancel');
	var responseWrap = form.find('#response_wrap');
	var captchaText = form.find('#captcha_right p');
	var captchaImage = form.find('#recaptcha_image');
	
	var cssOn = {
		'background' : '#fff', 
		'border-color' : '#fff', 
		'color' : '#000'
	};
	var cssOff = {
		'background' : '#282828',
		'border-color' : '#4a4a4a',
		'color' : '#666'
	};
    
	if (default_value == "Submit a bug report")
	{
	 	textarea.height(20);
		submit.hide();
		more.hide();
		inputs.hide();
		cancel.hide();
		responseWrap.hide();
		captchaImage.hide();   
	}	
	else
	{
		textarea.css(cssOn);	
		captchaImage.css('display','block');
	}
  
	textarea.click(function(e) {
		if (textarea.height() < 50) {
			textarea.animate({ height: "100px" }, 200).val('').css(cssOn);
			submit.fadeIn(500);
			more.fadeIn(500);
			inputs.fadeIn(500);
			cancel.show();
			// captchaText.fadeIn(500);
			responseWrap.fadeIn(500);
			captchaImage.css('display','block');
		}
	});
  
	cancel.click(function(e) {
		e.preventDefault();
		textarea.css(cssOff);
		textarea.height(20).val(default_value);
		submit.hide();
		more.hide();
		inputs.hide();
		cancel.hide();
		captchaText.hide();
		captchaImage.hide();
		responseWrap.hide();
	});
}

function attachSelectAllEvents()
{
	selectBoxes = jQuery('.select_checkbox');
    selectAll = jQuery('#select_all');
    
    selectAll.click(function()
    {
        selectBoxes.each(function()
        {
            if (selectAll.attr('checked') == true)
            {
                this.checked = true;
            }
            else
            {
                this.checked = false;
            }
        });
    });
}

function hideObjectEmbedTags()
{
	for (var i=0; i<objectTags.length;i++)
	{
		objectTags[i].style.visibility = "hidden";
	}

	for (var i=0; i<embedTags.length;i++)
	{
		embedTags[i].style.visibility = "hidden";
	}
}

function showObjectEmbedTags()
{
	for (var i=0; i<objectTags.length;i++)
	{
		objectTags[i].style.visibility = "visible";
	}

	for (var i=0; i<embedTags.length;i++)
	{
		embedTags[i].style.visibility = "visible";
	}
}


//////////////////////////////////////////////////
// INIT
//////////////////////////////////////////////////
var objectTags;
var embedTags;

jQuery(document).ready(function()
{
	objectTags = document.getElementsByTagName('object');
	embedTags  = document.getElementsByTagName('embed');

	jQuery(document).keydown(checkKeycode);
	
	jQuery('textarea').focus(function()
	{
		jQuery(document).unbind('keydown', checkKeycode);
	});

	jQuery('input').focus(function()
	{
		jQuery(document).unbind('keydown', checkKeycode);
	});
	
	jQuery('textarea').blur(function()
	{
		jQuery(document).keydown(checkKeycode);		
	});

	jQuery('input').blur(function()
	{
		jQuery(document).keydown(checkKeycode);		
	});
	
    confirmMessage = new ConfirmMessage('#confirm_message_wrap','#confirm_message');
	attachDeleteEvents = new AttachDeleteEvents();
	
	jQuery('#vnav_6.contribute').click(function(){showContributePopup ();});          
    jQuery('#hud_contribute').click(function(){showContributePopup ();});
	    
	jQuery(".show_hide_link").bind('click', toggleLayers);
	jQuery(".hide_global_activity_announcement").bind('click', hideGlobalActivityAnnouncement);
	jQuery(".hide_global_feature_announcement").bind('click', hideGlobalFeatureAnnouncement);
	jQuery(".hide_global_error_announcement").bind('click', hideGlobalErrorAnnouncement);
	fadeObjects();
	ffSearch();
	bugReport(); 
	attachSelectAllEvents();
	jQuery("#vnav_5").bind('mouseover', showDropdown);
	jQuery("#vnav_5").bind('mouseout', hideDropdown);
    jQuery('body.virb').css({backgroundColor:'#333333'});
	jQuery('#virb_banner li').click(function(event)
	{
		aTags = event.target.getElementsByTagName('a');
		if (aTags[0])
		{
			window.location = aTags[0].href;	
		}
	});
});
