/* 
##########################################################################
############# 1. Check if coockie exists
############# 2. If coockie does not exist check if need to create one
############# 3. Create coockie if needed
########################################################################## 
*/
var vars = [], hash, phonenumber;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
var cookie_exists = 0;

// 1. Check if coockie exists
var name;
name = "cpctrk=";
var returnvalue = "";
if (document.cookie.length > 0) 
   {
      offset = document.cookie.indexOf(name)
      // if cookie exists
      if (offset != -1) 
         {
            offset += name.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset);
            // set index of end of cookie value
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
         }
   }
   
// 2. If coockie does not exist check if need to create one
if(returnvalue == "")
   {
		// get all get variables from the url
		for(var i = 0; i < hashes.length; i++)
		   {
			  hash = hashes[i].split('=');
			  vars.push(hash[0]);
			  vars[hash[0]] = hash[1];
		   }

		// 3. Create coockie if needed
		   if (vars["_vsrefdom"]=="paidsearch")
			  {
				 ////////////////////////////////////////////////////////////////////////////////////////////////
				 // prepare for setting a cookie \/
				 var expires,name,expires_date;
				 var today = new Date();
				 today.setTime( today.getTime() );
				 expires = 365 * 1000 * 60 * 60 * 24;
				 expires_date  = new Date( today.getTime() + (expires) );
					
				 // set cookie
				 document.cookie = "cpctrk=yes; expires=" + expires_date.toGMTString() + "; path=/";
				 cookie_exists = 1;
				 // prepare for setting a cookie & set cookie /\
				 ////////////////////////////////////////////////////////////////////////////////////////////////
			  }
   }
else // if there is a cookie
   {
	   cookie_exists = 1;
   }

/* ################################################################################################################################################################## */
/* ###################################################################>>>>> Functions <<<<<########################################################################## */
/* ################################################################################################################################################################## */



function getPhoneNumber(defaultphone)
   {
      // if cookie exists display the voice star phone number, otherwise display the regular:
	  phonenumber = (cookie_exists) ? '480-630-2578' : defaultphone;
	  document.write (phonenumber);
   }
   
function getPhoneImg()
   {


var filename,buttonnumber;
   if (window.location.href)
   {
      var m = window.location.href.toString().match(/.*\/(.+?)\./);
      if (m && m.length > 1)
      {
         filename= m[1];
      }
   }

switch(filename)
{
case 'index':
	buttonnumber=1;
 	 break;
case 'about_us':
	buttonnumber=2;
 	 break;
case 'useful_info':
	buttonnumber=3;
 	 break;
case 'sponsored_events':
	buttonnumber=4;
 	 break;
case 'referrals':
	buttonnumber=5;
 	 break;
case 'contact_us':
	buttonnumber=6;
 	 break;
default:
	button=0;
}

 
	  var cpcflash="";
cpcflash += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
cpcflash += "    codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,24\"";
cpcflash += "     width=\"952\" height=\"459\">";
cpcflash += "										<param name=\"movie\" value=\"fshi_header_cpc.swf?button="+buttonnumber+"\" \/>";
cpcflash += "										<param name=\"quality\" value=\"high\" \/>";
cpcflash += "										<param name=\"menu\" value=\"false\" \/>";
cpcflash += "										<param name=\"wmode\" value=\"transparent\" \/>";
cpcflash += "										<!--[if !IE]> <-->";
cpcflash += "										<object data=\"fshi_header_cpc.swf?button="+buttonnumber+"\"";
cpcflash += "        width=\"952\" height=\"459\" type=\"application\/x-shockwave-flash\">";
cpcflash += "														<param name=\"quality\" value=\"high\" \/>";
cpcflash += "														<param name=\"menu\" value=\"false\" \/>";
cpcflash += "														<param name=\"pluginurl\" value=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" \/>";
cpcflash += "														<param name=\"wmode\" value=\"transparent\" \/>";
cpcflash += "														FAIL (the browser should render some flash content, not this).";
cpcflash += "										<\/object>";
cpcflash += "										<!--> <![endif]-->";
cpcflash += "						<\/object>";

var noncpcflash="";
noncpcflash += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
noncpcflash += "    codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,24\"";
noncpcflash += "     width=\"952\" height=\"459\">";
noncpcflash += "										<param name=\"movie\" value=\"fshi_header.swf?button="+buttonnumber+"\" \/>";
noncpcflash += "										<param name=\"quality\" value=\"high\" \/>";
noncpcflash += "										<param name=\"menu\" value=\"false\" \/>";
noncpcflash += "										<param name=\"wmode\" value=\"transparent\" \/>";
noncpcflash += "										<!--[if !IE]> <-->";
noncpcflash += "										<object data=\"fshi_header.swf?button="+buttonnumber+"\"";
noncpcflash += "        width=\"952\" height=\"459\" type=\"application\/x-shockwave-flash\">";
noncpcflash += "														<param name=\"quality\" value=\"high\" \/>";
noncpcflash += "														<param name=\"menu\" value=\"false\" \/>";
noncpcflash += "														<param name=\"pluginurl\" value=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" \/>";
noncpcflash += "														<param name=\"wmode\" value=\"transparent\" \/>";
noncpcflash += "														FAIL (the browser should render some flash content, not this).";
noncpcflash += "										<\/object>";
noncpcflash += "										<!--> <![endif]-->";
noncpcflash += "						<\/object>";

	  
	  
	  
	  
	  phoneimg = (cookie_exists) ? cpcflash : noncpcflash;
	  document.write (phoneimg);
   } 

