var defaultText = 't="TwitterUsername"';
var replaceText = defaultText;
var defaultText2 = 'http://twitter.com/TwitterUsername';
var replaceText2 = defaultText2;

function ValidateCode()
{
	var theForm = document.forms[0];	
	for(i=0; i<theForm.elements.length; i++){
		if(theForm.elements[i].type=="textarea"){			
			if(theForm.elements[i].value.indexOf(defaultText) > -1)
			{
				alert('You need to enter your twitter id in order for this code to work properly.');
			}
			break;
		}
	}	
}

function inputBox() {
	var twitterID = document.getElementById('twitterID');
	if(twitterID.value=="Your Twitter ID"){ 
		twitterID.value = "";
	}
}

function updateTwitterCode(){
	var theForm = document.forms[0];
	var twitterID = 't="'+document.getElementById('twitterID').value+'"';
	var twitterID2 = 'http://twitter.com/'+document.getElementById('twitterID').value;	
	for(i=0; i<theForm.elements.length; i++){
		if(theForm.elements[i].type=="textarea"){
			theForm.elements[i].value = theForm.elements[i].value.replace(replaceText,twitterID);
			theForm.elements[i].value = theForm.elements[i].value.replace(replaceText2,twitterID2);
		}
	}
	replaceText = twitterID;
	replaceText2 = twitterID2;
}


function noenter() {
	if(window.event.keyCode==13){
		updateTwitterCode();
		window.event.keyCode =0;
	}
	return !(window.event && window.event.keyCode == 13); 
}

function copyText(theId) {
   var obj=document.getElementById(theId);
   obj.focus();
   obj.select();
   copyIntoClipboard(obj.value);
}

function copyIntoClipboard(text) {

        var flashId = 'flashId-HKxmj5';

        var clipboardSWF = 'clipboard.html';

        if(!document.getElementById(flashId)) {
            var div = document.createElement('div');
            div.id = flashId;
            document.body.appendChild(div);
        }
        document.getElementById(flashId).innerHTML = '';
        var content = '<embed src="' + 
            clipboardSWF +
            '" FlashVars="clipboard=' + encodeURIComponent(text) +
            '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        document.getElementById(flashId).innerHTML = content;
    }
