/*function addLoadEvent(func) {

    var oldonload = window.onload;

    if (typeof window.onload != 'function') {

        window.onload = func;

    } else {

        window.onload = function() {

            oldonload();

            func();

        }

    }

}*/



function checkEmail(email)

{	

	var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	var emailVal = $("#" + email).val();

	return pattern.test(emailVal);

}



$(document).ready(function() {



	$("#subForm input:submit").click(function() {	

		

		// First, disable the form from submitting

		$('form#subForm').submit(function() { return false; });

		

		// Grab form action

		formAction = $("form#subForm").attr("action");

		

		// Hacking together id for email field

		// Replace the xxxxx below:

		// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below

		id = "dykjky";

		emailId = id + "-" + id;

		

		// Validate email address with regex

		if (!checkEmail(emailId)) 

		{

			alert("Please enter a valid email address");

			return;

		}

		

		// Serialize form values to be submitted with POST

		var str = $("form#subForm").serialize();

		

		// Add form action to end of serialized data

		final = str + "&action=" + formAction;

		

		// Submit the form via ajax

		$.ajax({

			url: "/js/proxy.php",

			type: "POST",

			data: final,

			success: function(data){

				//Check to make sure that the email was accepted

				if (data.search(/invalid/i) != -1) {

					alert('The email address you supplied is invalid and needs to be fixed before you can subscribe to this list.');

				}

				else

				{

					$("p#subscribe-fields").hide(); // If successfully submitted hides the form

					$("p#success-message").fadeIn("fast");  // Shows "Thanks for subscribing" div

				}

			}

		});

	});

	

	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme:'light_square',
		slideshow:5000,
		allowresize: true
	});

	

	$('span#petroleum').qtip({

		content: '<b>Petrolatum:</b> An irritant that coats the skin and is void of any healing properties often causing the very symptoms its intended to remedy',

		style: {

	        border: {

	           width: 0,

	           radius: 0

	        },

			padding: 10,

			paddingTop: 5,

			color: '#ffffff',

			background: 'url(/images/backgrounds/bg-tooltip-medium.png) no-repeat',

			width: 200,

			height: 100

		},

		position: {

			corner: {

				target: 'bottomRight',

				tooltip: 'bottomLeft'

			}

		}

	});

	

	$('span#paraben').qtip({

		content: '<b>Paraben:</b> Used in cosmetics as a synthetic preservative and in high doses can be carcinogenic',

		style: {

	        border: {

	           width: 0,

	           radius: 0

	        },

			padding: 10,

			paddingTop: 5,

			color: '#ffffff',

			background: 'url(/images/backgrounds/bg-tooltip-small.png) no-repeat',

			width: 200,

			height: 100

		},

		position: {

			corner: {

				target: 'bottomRight',

				tooltip: 'bottomLeft'

			}

		}

	});

	

	$('span#beeswax').qtip({

		content: '<b>Beeswax:</b> A natural wax that conditions lips while acting as a barrier, preventing moisture loss',

		style: {

	        border: {

	           width: 0,

	           radius: 0

	        },

			padding: 10,

			paddingTop: 5,

			color: '#ffffff',

			background: 'url(/images/backgrounds/bg-tooltip-small.png) no-repeat',

			width: 200,

			height: 100

		},

		position: {

			corner: {

				target: 'bottomRight',

				tooltip: 'bottomLeft'

			}

		}

	});

	

	$('span#vitamin').qtip({

		content: '<b>Vitamin E:</b> Known for its restorative powers, Vitamin E works as an natural antioxidant, slowing down the oxidation processes and inhibiting premature aging',

		style: {

	        border: {

	           width: 0,

	           radius: 0

	        },

			padding: 10,

			paddingTop: 5,

			color: '#ffffff',

			background: 'url(/images/backgrounds/bg-tooltip-large.png) no-repeat',

			width: 200,

			height: 100

		},

		position: {

			corner: {

				target: 'bottomRight',

				tooltip: 'bottomLeft'

			}

		}

	});

	

	$('span#zinc').qtip({

		content: '<b>Zinc Oxide:</b> An organic compound that works as a natural sunscreen agent by reflecting UV radiation, preventing sunburn and premature aging of the skin',

		style: {

	        border: {

	           width: 0,

	           radius: 0

	        },

			padding: 10,

			paddingTop: 5,

			color: '#ffffff',

			background: 'url(/images/backgrounds/bg-tooltip-large.png) no-repeat',

			width: 200,

			height: 100

		},

		position: {

			corner: {

				target: 'bottomRight',

				tooltip: 'bottomLeft'

			}

		}

	});

	

});
