   function getCookie(name) {  
     var arg = name + "=";  
     var argLen = arg.length;  
     var cookieLen = document.cookie.length;  
     var i = 0;  
     while (i < cookieLen) {
       var j = i + argLen;    
       if (document.cookie.substring(i, j) == arg)      
         return getCookieVal(j);
       i = document.cookie.indexOf(" ", i) + 1;    
       if (i == 0) break;   
     }  
     return null;
   }

   function getCookieVal(offset) {
     var endstr = document.cookie.indexOf(";", offset);
     if (endstr == -1)
       endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
   }

   function setCookie(name, value) {  
     var argv = setCookie.arguments;  
     var argc = setCookie.arguments.length;  
     var expires = (argc > 2) ? argv[2] : null;  
     var path = (argc > 3) ? argv[3] : null;  
     var domain = (argc > 4) ? argv[4] : null;  
     var secure = (argc > 5) ? argv[5] : false;  
     document.cookie = name + "=" + escape(value) + 
                       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
                       ((path == null) ? "" : ("; path=" + path)) +  
                       ((domain == null) ? "" : ("; domain=" + domain)) +    
                       ((secure == true) ? "; secure" : "");
   }

   function deleteCookie(name) {  
     var exp = new Date();  
     exp.setTime (exp.getTime() - 1);   
     var cval = getCookie(name);  
     document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
   }

   var expDays = 30;
   var exp = new Date(); 
   exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));

   function getVisitCount() {
     var count = getCookie('count')
     if (count == null) {
       setCookie('count', '1');
       return 1;
     } else {
       var newcount = parseInt(count) + 1;
       deleteCookie('count');
       setCookie('count', newcount, exp);
       return count;
     }
   }

   function yesFlash() {
     var movieArray = new Array("image1.swf", "image2.swf", "image3.swf", "image4.swf", "image5.swf", "image6.swf", "image7.swf");
     var curMovieIdx = getVisitCount();

     document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"782\" height=\"280\">\n");
     document.write("<param name=\"movie\" value=\"http://bss.on.ca/wp-content/themes/default/media/" + movieArray[(curMovieIdx % movieArray.length)] + "\">\n");
     document.write("<param name=\"quality\" value=\"high\">\n");
     document.write("<param name=\"wmode\" value=\"transparent\">\n");
     document.write("<embed src=\"http://bss.on.ca/wp-content/themes/default/media/" + movieArray[(curMovieIdx % movieArray.length)] + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"782\" height=\"280\"></embed>\n");
     document.write("</object>\n");
   }
