var feedbackValueInJs = "";
function initInputs () {
	var inputs = document.getElementsByTagName("input");
	for (var i = 0; i < inputs.length; i++ ){
		if(inputs[i].type == "text" ) {
			inputs[i].valueHtml = inputs[i].value;
			inputs[i].onfocus = function (){
				if (this.name == 'url') {
					this.focus();
					var _this = this;
					setTimeout(function(){_this.select()}, 100);
					this.onkeydown = function(e){
						//Added by sayantani to allow Cntl+C return true
						
						var evt=window.event || e ;
						 var pressedKey = String.fromCharCode(evt.keyCode).toLowerCase(); 
						 if (evt.ctrlKey && (pressedKey == "c" || pressedKey == "v")) {   
							 // disable key press porcessing
							return true; 
						}else{
							return false; 
						}
						//End addition
					}
				} else {
					//Commented By Sumana on 23/08/09 for bug Fix
					/*if (this.value == this.valueHtml)
						this.value = "";*/
					if (this.className.indexOf('type') == -1)
						this.className += ' type';
				}
			}
			inputs[i].onblur = function (){
				if (this.value == "") {
					this.className = this.className.replace('type','');					
				}
				//Commented By Sumana on 26/08/09 for bug Fix
				//Commented line is removed and if is added By Sumana on 31/08/09 for bug Fix
				//Comment on 14/09/09 --> this if block has been removed from the if block By Sayantani
				if(this.name == 'url'){
					this.value = this.valueHtml;
				}
			}
		}
	}
	var textarea = document.getElementsByTagName("textarea");
	for (var i = 0; i < textarea.length; i++ ){
		
		textarea[i].valueHtml = textarea[i].value;
		textarea[i].onfocus = function (){
			if(this != null){
			
				if(this.id == "feedbackArea" && (this.value == "Leave feedback for this file."
				|| (document.getElementById("ratingFeedbackMessageHidden") != null && 
						document.getElementById("ratingFeedbackMessageHidden").value == this.value)	
				)){
					this.value = "";
					this.className += ' type';
				}
			}
		}
		textarea[i].onblur = function (){
			
			if(this != null){
				if(this.id == "feedbackArea"){
					//Changed By Sumana on 22/09/09 for bug Fix
					if(feedbackValueInJs == ""){
						this.value != ""? this.value = this.value: this.value = this.valueHtml;
					}else{
						this.value != ""? this.value = this.value: this.value = feedbackValueInJs;
					}
				}
				if(this.id == "feedbackArea" && (this.value == "Leave feedback for this file."
					|| (document.getElementById("ratingFeedbackMessageHidden") != null && 
							document.getElementById("ratingFeedbackMessageHidden").value == this.value)	
					)){
					this.className = this.className.replace('type','');
				}
			}
			
		}
	}
}


if (window.addEventListener){
	window.addEventListener("load", initInputs, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", initInputs);
}