$(document).ready(function() {

// get the URL being called, place in variable 'url'
var url = document.URL;

// set the referer identifier for each possible referer
// this is the string that gets looked for to check who the referer is
var rGoogle = /utm_src=google/;
var rYahoo = /utm_src=yahoo/;
var rBing = /utm_src=bing/;

// check each referrer string to see if it is in the URL.
// this should only happen on the landing page
// if it is, set a cooke named "Refer" with the value as noted below
if (rGoogle.test(url))
	{
		$.cookies.set('Refer', 'googlerefer')
	}
if (rYahoo.test(url))
	{
		$.cookies.set('Refer', 'yahoorefer')
	}
if (rBing.test(url))
	{
		$.cookies.set('Refer', 'bingrefer')
	} 

// get the value of the cookie with the name of 'Refer'
// there will be a cookie if the visitor is on the landing page
// OR if they WERE on the landing page earlier and the cookie was set
var cookie = $.cookies.get('Refer');

// check the value of the variable 'cookie'

// if it is set with a referer, then set the value of variables 'phone' and 'headerimg'
// appropriate for the particular referer
if (cookie == 'googlerefer')
{
	phone = '314-997-2196';
	headerimg = '<img src="images/header-gawno.jpg" alt="St. Louis Pediatric Ophthalmology" width="732" height="215">';
	//voip =  '<a href="tel:13149972196"> Call 314-997-2196</a>';
}
else if (cookie == 'yahoorefer')
{
	phone = '314-997-3937';
	headerimg = '<img src="images/header.jpg" alt="St. Louis Pediatric Ophthalmology" width="732" height="215">';
    //voip = '<a href="tel:13149973937"> Call 314-997-3937</a>';
}
else if (cookie == 'bingrefer')
{
	phone = '314-997-3937';
	headerimg = '<img src="images/header.jpg" alt="St. Louis Pediatric Ophthalmology" width="732" height="215">';
	//voip = '<a href="tel:13149973937"> Call 314-997-3937</a>';
}

// check if the variable of 'cookie' has a value
// if it DOES, then:
if (cookie)
{
    // replace the contents of any tag with the class "phoneno" with the variable 'phone' (as set above)
    $('.phoneno').html(phone);
    // replace the contents of any tag with the id "phoneimg" with the variable 'headerimg' (as set above)
    $('#phoneimg').html(headerimg);
    //$('.inlineVOIP').html(voip);
}
// if the variable of 'cookie' is does NOT have a value, then the content that is on the page in the 'phoneno'
// and 'phoneimg' tags remains as stated in the page content

}); // end ready()

