﻿<!--
	JSFX.Rollover("home", "/images/default6_r4_c2_f2.gif");
	JSFX.Rollover("meetdanesh", "/images/default5_r6_c2_f2.gif");
	JSFX.Rollover("procedures", "/images/default5_r10_c2_f2.gif");
	JSFX.Rollover("photogallery", "/images/default7_r12_c2_f2.gif");
	JSFX.Rollover("finance", "/images/default7_r14_c2_f2.gif");
	JSFX.Rollover("testimonials", "/images/default7_r17_c2_f2.gif");
	JSFX.Rollover("skincare", "/images/default7_r16_c2_f2.gif");
	JSFX.Rollover("request", "/images/default7_r19_c2_f2.gif");
	JSFX.Rollover("overseas", "/images/overseas_button_over.gif");
	JSFX.Rollover("surgerycenter", "/images/surgery_center_menu_f2.gif");
	JSFX.Rollover("Blog", "/images/Blogbutton_over.gif");
//-->

function openWindow(url,name, width, height) {
var popupWin;
	// if a window already exists, destroy it.
	if (popupWin && !popupWin.closed) {
               popupWin.close();
	}
	var attr = 'scrollbars=no,status=yes,width=' + width + ',height= ' + height  +',left=1,top=1,resizable=1';
   	popupWin = window.open(url, name, attr);
	popupWin.focus();
}

function OpenCoupon()
{
	var cgi = new Object();
      cgi.http_host = location.host;
      cgi.http_user_agent = navigator.userAgent;
      cgi.http_cookie = document.cookie;
      cgi.https = (location.protocol == 'https:\/\/') ? 'on' : 'off';
      cgi.path_info = (location.pathname.indexOf('?') != -1) ?
location.pathname.substring(0, location.pathname.indexOf('?')) :
location.pathname;
      cgi.query_string = (location.search) ?
((location.search.indexOf('#') != -1) ? location.search.substring(1,
location.search.indexOf('#')) : location.search.substring(1)) : '';
      cgi.script_name = cgi.path_info;
      cgi.http_referer = document.referrer;
	var LinkLocation =
"http://www.ocplasticsurgeons.com/coupon.html";
//alert("link=" + LinkLocation);
	openWindow(LinkLocation, 'Coupon', '360', '475');
}

// -------------------------------------------------------------------------- //
// referrerCookie.js
//
// Sets a cookie on the client recording the referrer
//
// -------------------------------------------------------------------------- //


/////////////////////////////////////////////////////////////
//
// setCookie()
//
// DESC:	Creates/overwrites a cookie
//
// USAGE:	setCookie(name, value, expires, path, domain, secure);
//
// INPUT:	name		- Name of the cookie
//			value		- Value of the cookie
//			[expires]	- Expiration date of the cookie (defaults to end of the current session)
//			[path]		- Path to which the cookie applies (defaults to entire domain)
//			[domain]	- Domain to which the cookies applies (defaults to current domain)
//			[secure]	- Boolean specifying if a secure connection is required (defaults to false)
//
// OUTPUT:	None
//
// CHANGED:	document.cookie
//
/////////////////////////////////////////////////////////////

function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}


/////////////////////////////////////////////////////////////
//
// getCookie()
//
// DESC:	Returns the value of the specified cookie or NULL
//			if the specified cookie is undefined.
//
// USAGE:	value = getCookie(name);
//
// INPUT:	name		- Name of the cookie to be retrieved
//
// OUTPUT:	Value of the specified cookie or NULL
//
// CHANGED:	None
//
/////////////////////////////////////////////////////////////

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}


/////////////////////////////////////////////////////////////
//
// deleteCookie()
//
// DESC:	Deletes the specified cookie
//
// USAGE:	deleteCookie(name, path, domain);
//
// INPUT:	name		- Name of the cookie to be deleted
//			[path]		- Path of the cookie to be deleted
//			[domain]	- Domain of the cookie to be deleted
//
// OUTPUT:	None
//
// CHANGED:	document.cookie
//
/////////////////////////////////////////////////////////////

function deleteCookie(name, path, domain)
{
	if ( getCookie(name) )
	{
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


//
// Set referrer cookie if it doesn't already exist
//
if ( ! getCookie("jsRef") )
{
	// Set expiration date of 3 days
	var currDate = new Date();
	currDate.setTime(currDate.getTime() + 3 * 24 * 60 * 60 * 1000);

	// Set cookie
	setCookie("jsRef", document.referrer, currDate);
}

function checkMe(obj) {
	// declare errorstring
	var errorString ="";
	// email must have  and '@' and a '.' and cannot have any spaces
	if ((obj.Email.value.indexOf("@")==-1) || (obj.Email.value.indexOf(".")==-1) || (obj.Email.value.indexOf(" ")!=-1)) {
		errorString = errorString + "'" + obj.Email.value + "' is not a valid email address.\nPlease re-enter your email address.\n\n";
		}
	// if we've set the errorstring, lets yell at them and return false
	if (errorString != "") {
		alert(errorString);
		return false;
	}
	
	return true;
}

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function validFirstName(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "First Name" || formField.value == "")
	{
		alert('Please enter your First Name.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function validLastName(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "Last Name" || formField.value == "")
	{
		alert('Please enter your Last Name.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a valid email address, for example: yourname@domain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value,10);
 		if (isNaN(num))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validDate(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var elems = formField.value.split("/");
 		
 		result = (elems.length == 3); // should be three components
 		
 		if (result)
 		{
 			var month = parseInt(elems[0],10);
  			var day = parseInt(elems[1],10);
 			var year = parseInt(elems[2],10);
			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&
					 allDigits(elems[1]) && (day > 0) && (day < 32) &&
					 allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.');
			formField.focus();		
		}
	} 
	
	return result;
}