// JavaScript Document

function open_return_window() 
{
return_window = open("","hoverwindow","width=600,height=380,left=10,top=10");

// open new document 
return_window.document.open();

// Text of the new document
return_window.document.write('<html><title>Return/Shipping and Handling</title>');
return_window.document.write('<body bgcolor=\"FFFFFF\">');
return_window.document.write('<h3 style="color:#935c9a;">Returns</h3>');
return_window.document.write('<p style="text-align:justify;">At Ostomy secrets we want you to enjoy your shopping experience with us and are excited you have come to our site!  However, given the nature of undergarments and sanitary issues, we are unable to accept returns.  We highly advise following the sizing charts and measuring before placing your order.   We want you to make sure you order the correct size and therefore can enjoy your Ostomy Secrets as soon as they arrive!  If you need assistance or have questions about sizing, call us at 1-800-518-8515.</p>');
return_window.document.write('<h3 style="color:#935c9a;">Shipping and Handling</h3>');
return_window.document.write('<h4>For US Orders</h4><p style="text-align:justify;">Ostomy Secrets uses the United States postal service (USPS) for all of its shipping needs.   The flat rate of $6.00 enables Ostomy Secrets to keep your shipping costs as low as possible, regardless of the quantity of your order.  Overnight shipping available on orders received by 2pm EST.  Flat fee of $25 will be charged.<br/>International Shipping is available for $20. </p>');
return_window.document.write('</body></html>');

// close the document
return_window.document.close(); 
}

function open_new_window() 
{
new_window = open("","hoverwindow","width=600,height=150,left=10,top=10");

// open new document 
new_window.document.open();

// Text of the new document
new_window.document.write('<html><title>ostomysecrets sizing information</title>');
new_window.document.write('<body bgcolor=\"FFFFFF\">');
new_window.document.write('<center><img src="\_images/chart.png\"></center>');
new_window.document.write('</body></html>');

// close the document
new_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window() 
{
new_window.close();
}





function open_contact_window() 
{
contact_window = open("","hoverwindow","width=300,height=350,left=380,top=200");

// open new document 
contact_window.document.open();

// Text of the new document
contact_window.document.write('<html><title>Contact ostomysecrets</title>');
contact_window.document.write('<body bgcolor=\"FFFFFF\">');
contact_window.document.write('<h3 style="color:#935c9a;">Contact Us</h3>');
contact_window.document.write('<h4>Address:</h4> 3225 South Macdill Avenue<br/>Suite 129-239<br/>Tampa, Florida 33629' );
contact_window.document.write('<h4>Phone:</h4> 1-800-518-8515' );
contact_window.document.write('<h4>Email:</h4> <a href="mailto:lisa@ostomysecrets.com" target="_self" >lisa@ostomysecrets.com</a>');
contact_window.document.write('</body></html>');

// close the document
contact_window.document.close(); 
}

function open_privacy_window() 
{
privacy_window = open("","hoverwindow","width=650,height=150,left=380,top=200");

// open new document 
privacy_window.document.open();

// Text of the new document
privacy_window.document.write('<html><title>ostomysecrets Privacy Statement</title>');
privacy_window.document.write('<body bgcolor=\"FFFFFF\">');
privacy_window.document.write("We value your privacy. When you visit");
privacy_window.document.write(" &nbsp; &nbsp;<a href='http://www.ostomysecrets.com' target='_blank'>www.ostomysecrets.com</a> &nbsp; ");
privacy_window.document.write("you may be asked to provide personal information.  Your name, mailing address and payment information is collected only to process payment. We may use your e-mail address to send you periodic Ostomy Secrets announcements including sales and our newsletter.  If you do not wish to receive such notices, please contact us. Your e-mail address will not be shared with any other party without your consent.");
privacy_window.document.write('</body></html>');

// close the document
privacy_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window() 
{
privacy_window.close();
}


function Validate(form) {

var err = document.getElementById("error");
var error;
var errorMsg = "";



if(form.name.value.length < 2) {
	 error = true;
	 errorMsg += "<li>Please Enter a Valid Name</li>";
}


if(form.address.value.length < 2) {
	 error = true;
	 errorMsg += "<li>Please Enter a Valid Address</li>";
}

reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	
	if (!reZip.test(form.zip.value)) {
	 error = true;
	 errorMsg += "<li>Please Enter a Valid Zip Code</li>";

}


var emailChk = checkEmail(form.email.value);
if(!emailChk) {
	error=true;
	errorMsg += "<li>Please enter a valid Email Address</li>";
}

if(error) {
		err.innerHTML = "<h5>Please correct the following errors before submitting your form.</h5>" +
		                "<ul>" + errorMsg +
						"</ul>";
		return false;
}
else 
	return true;

}


function checkEmail(str) {

var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		 
		    return false
		 }

 		 return true;					
	}
	
	function confirmContact(f)
	{
		$("#mainContactForm .required").css({"background-color" : "#fff" });
		var error = false;
		var out = "<td colspan='2'>";
		out += "<div class='error'><p>In order to submit this form, you must fill in all required fields.  Please see the highlighted areas below</p></div></td>"
		
		$("#mainContactForm .required").each(function(){
			if($(this).val() == "")
			{
				$(this).css({"background-color" : "#c57e7e" });
				error = true;
			}
		});
		
		if(error)
		{
		$("#contactErr").html(out);
		return false;
		} 
		return true;
	}