function swapImg(obj){
	var cSrc = obj.src;
	
	if (cSrc.indexOf("_off") > 0){cSrc = cSrc.replace("_off","_on");}
	else if (cSrc.indexOf("_on") > 0){cSrc = cSrc.replace("_on","_off");}
	obj.src = cSrc;
}

var markFields_color1 = "#CBE596";
var markFields_color2 = "#FFFFFF";

function markFields(fnames,state){
	var fnameArray = fnames.split("|");
	
	if(state) var color = markFields_color1;
	else var color = markFields_color2;
	
	for(var i = 0; i < fnameArray.length; i++){
		document.getElementById(fnameArray[i]).style.backgroundColor = color;
		if(state)document.getElementById(fnameArray[i]).focus();
	}
}

function validate(sect){
	var eMsg = "";
	
	switch(sect){
		case 'blog':
			//Clear Fields
			markFields("title",0);
					
			var title = document.getElementById('title').value;

			if(!title.length){
				var eMsg = "Please enter a title";
				markFields("title",1);
			}
		break;
		case '3gurus':
			//Clear Fields
			markFields("firstname|lastname|email|address|city|state|zipcode|country|cc_name|cc_number|cc_cvn",0);
					
			var firstname = document.getElementById('firstname').value;
			var lastname = document.getElementById('lastname').value;
			var email = document.getElementById('email').value;
			var address = document.getElementById('address').value;
			var city = document.getElementById('city').value;
			var state = document.getElementById('state').value;
			var zipcode = document.getElementById('zipcode').value;
			var country = document.getElementById('country').value;
			var cc_name = document.getElementById('cc_name').value;
			var cc_number = document.getElementById('cc_number').value;
			var cc_cvn = document.getElementById('cc_cvn').value;

			if(!firstname.length){
				var eMsg = "Please enter your first name";
				markFields("firstname",1);
			}else if(!lastname.length){
				var eMsg = "Please enter your last name";
				markFields("lastname",1);
			}else if(!email.length){
				var eMsg = "Please enter your email address";
				markFields("email",1);
			}else if(!address.length){
				var eMsg = "Please enter your street address";
				markFields("address",1);
			}else if(!city.length){
				var eMsg = "Please enter your city";
				markFields("city",1);
			}else if(!state.length){
				var eMsg = "Please enter your state";
				markFields("state",1);
			}else if(!zipcode.length){
				var eMsg = "Please enter your zipcode/postal code";
				markFields("zipcode",1);
			}else if(!country.length){
				var eMsg = "Please enter your country";
				markFields("country",1);
			}else if(!cc_name.length){
				var eMsg = "Please enter the name that appears on your credit card";
				markFields("cc_name",1);
			}else if(!cc_number.length){
				var eMsg = "Please enter your credit card number";
				markFields("cc_number",1);
			}else if(!cc_cvn.length){
				var eMsg = "Please enter your credit card's CVN\n(3-4 digit code, usually on the back of the card)";
				markFields("cc_cvn",1);
			}
		break;
	}
	
	if(eMsg.length){
		alert(eMsg);
		return false;
	}else{return true;}
}

function pollWindowSize(type){
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	
	switch(type){
		case 'w': return myWidth; break;
		case 'h': return myHeight; break;
	}
}

function showGreyIce(){
	var newdiv = document.createElement('div');
	//newdiv.setAttribute('id', id);
	newdiv.style.width = pollWindowSize('w');
	newdiv.style.height = 3000;
	newdiv.style.position = "absolute";
	newdiv.style.left = 0;
	newdiv.style.top = 0;
	newdiv.style.zIndex = 999;
	newdiv.style.opacity = ".70";
	newdiv.style.filter = "alpha(opacity=70)";
	newdiv.style.background = "#000000";
	newdiv.innerHTML = "<h1 style='padding-top:100px;color:white;'>Please Be Patiant While We Upload Your File...</h1>";
	document.body.appendChild(newdiv);
	return true;
} 
