function changeClass(obj,className)
{		
	obj.className = className;
}

function changeSubject(obj,text)
{
	var x = document.getElementById("subjectline");							  
	var y = obj;
	if(obj.value==undefined)
		x.firstChild.nodeValue="Editing: ";
	else
		x.firstChild.nodeValue="Editing: " + y.value;
}

function clearText(obj,text)
{
	if(obj.value==text)
		obj.value='';
	else
	  if(obj.value=='')
		  obj.value=text;
}

function openWin(url,name,features)
{
	window.open(url,name,features);
}

function openWin2(url,name,w,h,features)
{	
	var scrW = screen.width;
	var scrH = screen.height;	
	
	var top  = ((scrH - h)/2);
	var left = ((scrW - w)/2);

	features2 = "width=" + w + ",";
	features2+= "height=" + h + ",";
	features2+= "top=" + top + ",";
	features2+= "left=" + left + ",";
	features2+= features;
		
	try {
		handle = window.open(url,name,features2);
		handle.focus();		
	}
	catch(e) {
		alert("It seems that you have a pop-up blocker enabled\n" + 
			  "Please make sure you allow pop-ups from this site.\n" + 
			  "Otherwise you won't be able to view this page!");
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validate(obj,type,elID){
	var x = document.getElementById(elID);							  
	
	switch(type){
		case "text":
			if(obj.value==""){
				x.firstChild.nodeValue = "! This cannot be blank";								
			}else{
				x.firstChild.nodeValue = "*";				
			}			
		break;
		case "email":
			var goodEmail = obj.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
			
			if(goodEmail){
				x.firstChild.nodeValue = "*";							
			}else{
				x.firstChild.nodeValue = "! Invalid E-Mail Address";				
			}
		break;
		case "form":
			var error=true;
			
			if(x.form.value=="feedback"){
				if(x.fname.value==""){
					y = document.getElementById('feedbackFName');							  
					y.firstChild.nodeValue = "! This cannot be blank";
					error=true;
				}else{error=false;}
				
				
				if(x.lname.value==""){
					y = document.getElementById('feedbackLName');							  
					y.firstChild.nodeValue = "! This cannot be blank";
					error=true;
				}else{error=false;}
				
				var goodEmail = x.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);							
				if(!goodEmail){
					y = document.getElementById('feedbackEMail');							  
					y.firstChild.nodeValue = "! Invalid E-Mail Address";					
					error=true;
				}else{error=false;}
			}			
			
			
			else if(x.form.value=="evine"){
				if(x.fname.value==""){
					y = document.getElementById('evineFName');							  
					y.firstChild.nodeValue = "! This cannot be blank";
					error=true;
				}else{error=false;}
				
				if(x.lname.value==""){
					y = document.getElementById('evineLName');							  
					y.firstChild.nodeValue = "! This cannot be blank";
					error=true;
				}else{error=false;}
				
				var goodEmail = x.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);							
				if(!goodEmail){
					y = document.getElementById('evineEMail');							  
					y.firstChild.nodeValue = "! Invalid E-Mail Address";					
					error=true;
				}else{error=false;}
			}

			if(error==true)
			{			
				alert("There is an error with your form entry!\nPlease check that all required fields are properly completed.");
				return false;
			}						
			else				
				return true;
		break;
	}
}

function confirmAction(question){
	var agree=confirm(question);
	
	if (agree)
		return true;
	else
		return false;	
}

function openPreview(id){
	openWin2("preview.php?id=" + id,"win",650, screen.height-250, "resizable=yes,scrollbars=yes");
}

function hideUpload(){
	var x = document.getElementById("formbody");
	var y = document.getElementById("fileinput");
	var z = document.getElementById("submitbtn");			
	x.innerHTML="<p>Uploading Image</p><br><p>Please Be Patient!!</p>";
	x.style.fontWeight = "bold";
	x.style.fontSize = "12px"
	y.style.display = "none";
	z.style.display = "none";
}