$(function () {
	
	if($('#customform-contact #submit').length) {
		$('#customform-contact #submit').val('SEND');
	}
	if($('#customform-subscribe #submit').length) {
		$('#customform-subscribe #submit').val('JOIN');
	}
	
	if($('#customform-subscribe #Field1').length) {
		$('#customform-subscribe #Field1').val('E-MAIL ADDRESS');
	}
	if($('#customform-subscribe #Field1').length) {
		$('#customform-subscribe #Field1').focus(function() {
			if($('#customform-subscribe #Field1').val()=='E-MAIL ADDRESS'){
				$('#customform-subscribe #Field1').val('');
			};
		});
	}
	if($('#customform-subscribe #Field1').length) {
		$('#customform-subscribe #Field1').blur(function() {
			if($('#customform-subscribe #Field1').val()== ''){
				$('#customform-subscribe #Field1').val('E-MAIL ADDRESS');
			};
		});
	}
	
	$('.column.first .pagecontent img').each(function(index){
		var caption = $(this).attr('alt');
		var detail = $(this).attr('title');
		var side = $(this).attr('class');
		var width = $(this).attr('width') + 2;
		$(this).wrap('<div class="image-wrap ' + side + '" style="width:' + width + 'px" />');
		if($(this).attr('title') != ""){
			$(this).after('<span class="detail">' + detail + '</span>');
		}
		$(this).after('<span class="caption">' + caption + '</span>');
		$(this).removeClass();
	});
	
	/*
	$('.wwd').masonry({
		singleMode: true,
		itemSelector: '.wwd-item'
	});
	*/
	$( "#home-tabs" ).tabs();

});
    
Cufon.replace('h1, #section-index h2, #maincontent h2, #maincontent h3, .module h3, a.mainlink, h3.blue-heading');
/*Cufon.replace('h1, #section-index h2, .module h3, a.mainlink');*/

function popUp2(message) {

var x = 20;
var y = 20;

	var windowparam = "width=" + 650 + ",height=" + 700 + ",scrollbars=yes,menubar=no,left="+x+",top="+y+",screenX="+x+",screenY="+y;
	popwin = window.open(message, "popwin", windowparam)
	popwin.opener = self;
	popwin.focus()
}
		
function validate_email(field,alerttxt) {
	with (field) { 
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			alert(alerttxt);
			return false;
		}
		else { return true; }
	}
}
function validate_form(thisform,fieldtovalidate)
{
	with (thisform)
	{
	if (validate_email(fieldtovalidate,"Not a valid e-mail address!")==false)
	  { return false;}
	}
}


function getPassword(thisTable,thisId){ 
	  var retVal = "" 
	  retVal = prompt("A password is required to view this video.", ""); 
	  thisURL="/video.cfm";
	  $.post(thisURL, { variable: thisTable, variable2: thisId, variable3: retVal }, function(data){
	    newAnswer=data.replace(/^\s*/, "").replace(/\s*$/, "");
		if (newAnswer == "No") {
	 	 	alert("Incorrect Password!");
		  	window.location.reload();
		  	return false;
		  }
		  else {
		  	return true;
		  } 
	  });
}

function popUp1(message) {



var x = 20;

var y = 20;



	var windowparam = "width=" + 500 + ",height=" + 700 + ",scrollbars=yes,menubar=no,left="+x+",top="+y+",screenX="+x+",screenY="+y;

	popwin = window.open(message, "popwin", windowparam)

	popwin.opener = self;

	popwin.focus()

}

