function checkStep1(){
	if(document.frm.fSubject.value.length>=5 && document.frm.fSubject.value.length<=100){
		return true;
	}else{
		window.alert("Please enter a subject for your issue.\n\nThe subject entered must be more than 5 characters long and less than 100.");
		return false;
	}
}

function checkStep3(){
	var s="";
	if(document.frm.fName.value.length<3 || document.frm.fName.value.length>50){
		s+="Please enter your full name.\nThe name entered must be less than 50 characters.\n\n";
		document.frm.fName.style.backgroundColor="#ffff99";
	}else{
		document.frm.fName.style.backgroundColor="#ffffff";
	}
	if(document.frm.fEmail.value.length<5 || document.frm.fEmail.value.length>50 || !checkMail(document.frm.fEmail.value)){
		s+="Please enter your valid email address.\nThe email address entered must be less than 50 characters.\n\n";
		document.frm.fEmail.style.backgroundColor="#ffff99";
	}else{
		document.frm.fEmail.style.backgroundColor="#ffffff";
	}
	if(document.frm.fSubject.value.length<5 || document.frm.fSubject.value.length>100){
		s+="Please enter a subject for your issue.\nThe subject entered must be more than 5 characters long and less than 100.\n\n";
		document.frm.fSubject.style.backgroundColor="#ffff99";
	}else{
		document.frm.fSubject.style.backgroundColor="#ffffff";
	}
	if(document.frm.fCategory.value.length<1){
		s+="Please select a category for your issue.\n\n";
		document.frm.fCategory.style.backgroundColor="#ffff99";
	}else{
		document.frm.fCategory.style.backgroundColor="#ffffff";
	}
	if(document.frm.fOS.value.length<1){
		s+="Please select your operating system.\n\n";
		document.frm.fOS.style.backgroundColor="#ffff99";
	}else{
		document.frm.fOS.style.backgroundColor="#ffffff";
	}
	if(document.frm.fText.value.length<10){
		s+="Please enter a detailed description of your issue.\n\n";
		document.frm.fText.style.backgroundColor="#ffff99";
	}else{
		if(document.frm.fText.value.length>2000){
			s+="Please limit your issue description to 2000 characters or less. You currently have entered " + document.frm.fText.value.length + ".\n\n";
			document.frm.fText.style.backgroundColor="#ffff99";
		}else{
			document.frm.fText.style.backgroundColor="#ffffff";
		}
	}
	if(s.length > 0){
		window.alert(s);
		return false;
	}else{
		return true;
	}
}

function checkUpdate(){
	var s="";
	if(document.frm.fText.value.length<10){
		s+="Please enter a detailed description of your issue.\n\n";
		document.frm.fText.style.backgroundColor="#ffff99";
	}else{
		if(document.frm.fText.value.length>2000){
			s+="Please limit your issue description to 2000 characters or less. You currently have entered " + document.frm.fText.value.length + ".\n\n";
			document.frm.fText.style.backgroundColor="#ffff99";
		}else{
			document.frm.fText.style.backgroundColor="#ffffff";
		}
	}
	if(s.length > 0){
		window.alert(s);
		return false;
	}else{
		return true;
	}
}

function checkMail(s){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (filter.test(s));
}

var subRating=false;
function ratingFunc(divID,eType,def){
	if(!subRating){
		switch(eType){
			case 0: //over
			case 2: //down
				for(var i=0;i<5;i++){
					var o=document.getElementById("ct_rating"+i);
					o.style.backgroundImage="url(/support/images/star_green.gif)";
					if(divID>=i){
						o.style.width="30px";
					}else{
						o.style.width="0px";
					}
				}
			break;
			case 1: //out
				for(var i=0;i<5;i++){
					var o=document.getElementById("ct_rating"+i);
					o.style.backgroundImage="url(/support/images/star.gif)";
					if(def>i){
						if(def-i>1){
							o.style.width="30px";
						}else{
							o.style.width=Math.floor((def-i)*30)+"px";
						}
					}else{
						o.style.width="0px";
					}
				}
			break;
		}
		if(eType==2){
			subRating=true;
			var http_request;
			if (window.XMLHttpRequest) { // Mozilla, Safari,...
				http_request = new XMLHttpRequest();
			}else if(window.ActiveXObject){ // IE
				try {
					http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try {
						http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
			}
			http_request.onreadystatechange=function(){return true;};
			http_request.open("GET","/support/knowledgebase/issue/rating.asp?id="+def+"&r="+(divID+1),true);
			http_request.send(null);
		}
	}
}

function ct_startUpload(){
	if(document.frmUpload.fFile.value.length > 5){
		document.getElementById("ct_attach").style.display="none";
		document.getElementById("ct_attachMon").style.display="";
		return true;
	}else{
		window.alert("Please select a file from your local computer which you wish to upload.");
		return false;
	}
}

function ct_fileUploaded(t){
		if(ct_upload.document.body){
			
		var b=ct_upload.document.body.innerHTML.toLowerCase().replace(/^\s+|\s+$/g,"");
		
		if(b.length>8&&b.substr(0,8)=="complete"){
			ct_upload.src="/support/blank/";
			document.getElementById("ct_attachMon").innerHTML="Your file has been attached to this issue.";
		}else if(ct_upload.document.body.innerHTML.length>5){
			if(ct_upload.document.body.innerHTML.length<300){
				window.alert("There was an error uploading the file\n"+ct_upload.document.body.innerHTML);
			}else{
				window.alert("There was an error uploading the file");
			}
			window.location.href="/support/history/";
		}
	}
}
