$(document).ready(function(){
	$('.glitter').find('input').click(copyToClipboard).end().find('textarea').focus(copyToClipboard);
	$('.msg').hide();
	$('a.sel,.code').click(selCode);
	$('.emailGlitter').nyroModal({width:530});
	/*
	$('.emailGlitter').click(function(){
	
	});*/
});
function selCode(){
	$(this).parents('.codeWrapper').find('textarea')[0].select();
	return false;
}
function copyToClipboard(){
	if(navigator.userAgent.indexOf('Mac') != -1) return false;
	var p = $(this).parent().parent();
	copy(p.find('textarea:first').select()[0]);
	p.parent().find('.msg').html('Code copied succesfully!!!').addClass('hilite').fadeIn();
	setTimeout("$('.msg').html('&nbsp;').fadeOut();", 3000);
}
function copy(inElement) {
	if( window.clipboardData && clipboardData.setData )	{
		clipboardData.setData("text", inElement.value);
	} else {
		if (inElement.createTextRange) {
			var range = inElement.createTextRange();
			if (range)range.execCommand('Copy');
		} else {
			var flashcopier = 'flashcopier';
			if(!document.getElementById(flashcopier)) {
			  var divholder = document.createElement('div');
			  divholder.id = flashcopier;
			  document.body.appendChild(divholder);
			}
			document.getElementById(flashcopier).innerHTML = '';
			var divinfo = '<embed src="/imgs/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
			document.getElementById(flashcopier).innerHTML = divinfo;
		}
	}
}