if(filename!="index.html" && filename!="")
{
var c_splash="splashpagecookie_s";
var splash_value = getCookie(c_splash);
if(splash_value==null || splash_value=="")
	{
	location.href="index.html";	
	}
}

function cookies_enabled()
{
document.cookie="testcookie"
	cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
if (!cookieEnabled) //if cookies are not enabled on client's browser
{
  //    var cookie_disable=1;
     document.write("<p class='red'>WARNING: Your browser does not have cookies enabled, the functionality of this site requires the use of cookies, please enable your cookies to ensure you are able to view the site properly.</p>");
}	 
}

var keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";
  function encode64(input) {
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;

      do {
         chr1 = input.charCodeAt(i++);
         chr2 = input.charCodeAt(i++);
         chr3 = input.charCodeAt(i++);

         enc1 = chr1 >> 2;
         enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
         enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
         enc4 = chr3 & 63;

         if (isNaN(chr2)) {
            enc3 = enc4 = 64;
         } else if (isNaN(chr3)) {
            enc4 = 64;
         }

         output = output + 
            keyStr.charAt(enc1) + 
            keyStr.charAt(enc2) + 
            keyStr.charAt(enc3) + 
            keyStr.charAt(enc4);
         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return output;
   }

function decode64(input) {
     var output = "";
				var chr1, chr2, chr3;
				var enc1, enc2, enc3, enc4;
				var i = 0;
				input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
				while (i < input.length) {
					enc1 = keyStr.indexOf(input.charAt(i++));
					enc2 = keyStr.indexOf(input.charAt(i++));
					enc3 = keyStr.indexOf(input.charAt(i++));
					enc4 = keyStr.indexOf(input.charAt(i++));
					chr1 = (enc1 << 2) | (enc2 >> 4);
					chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
					chr3 = ((enc3 & 3) << 6) | enc4;
					output = output + String.fromCharCode(chr1);
					if (enc3 != 64) {
						output = output + String.fromCharCode(chr2);
					}
					if (enc4 != 64) {
						output = output + String.fromCharCode(chr3);
					}
				}
				output = uTF8Decode(output);
				return output;
   }

function uTF8Decode(input)
{
	var string = "";
			var i = 0;
			var c = c1 = c2 = 0;
			while ( i < input.length ) {
				c = input.charCodeAt(i);
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				} else if ((c > 191) && (c < 224)) {
					c2 = input.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				} else {
					c2 = input.charCodeAt(i+1);
					c3 = input.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
			}
			return string;
}

function getCookie(c_name)
{

if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
   if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	}
  }
return "";
}


function get_ED()
{
	var cookie_name = "EDClassification";
	number=getCookie(cookie_name);
	var ed;
	if(number>=26 && number<=30)
		ed = "edMarker-Normal";
	else if(number>=17 && number<=25)
		ed = "edMarker-Mild";
	else if(number>=11 && number<=16)
		ed = "edMarker-High";
	else if(number>=6 && number<=10)
		ed = "edMarker-Severe";

	return ed;
}

function hidediv1(div) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.display = 'none'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.div.display = 'none'; 
} 
else { // IE 4 
document.all.div.style.display = 'none'; 
} 
} 
} 

function showdiv1(div) { 

if (document.getElementById) { // DOM3 = IE5, NS6 

document.getElementById(div).style.display = 'block'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.div.display = 'block'; 
} 
else { // IE 4 
document.all.div.style.display = 'block'; 
} 
} 

} 

function count_visitor()
{
	var url;
	var cookie_value = getCookie("visitor_count");
	if(cookie_value!=1) //cookie is not set yet
	{
	 url = "<script type=\"text/javascript\" src=\"http://scripts.nitro-dev.com/40over40/counter_new.php?counter=1\"></script>"; //increment & get the count
	  
	 //set cookie
	 document.cookie = "visitor_count=1";
	 //delete article cookie
	  var d = new Date();
	document.cookie = "article=1;expires=" + d.toGMTString() + ";" + ";";
	}
	else
	{
	 url ="<script src=\"http://scripts.nitro-dev.com/40over40/counter_visit_new.php\"></script>"; //simply get the visitor count	
	
	}
	return url;
}
function testcookie()
{
	  var cookie_arr = new Array('erections_hard','intercourse_penetrate','maintain_erections','difficulty_maintain','confidence');
		 for (var j = 0; j < cookie_arr.length; j++)
		{
	        var cookie_decode = cookie_arr[j].replace(/^\s*|\s*$/,"");
			var cookie_name =  encode64(cookie_decode);
			var cookie_value = getCookie(cookie_name);
			
			cookie_value =  decode64(cookie_value);
//			if(cookie_value==0 || isNaN(cookie_value[0])) 
			
			
				if(cookie_value==0 || cookie_value==null)
				 hidediv1("expand_"+cookie_decode);
				else
				$('#'+cookie_decode).sSelect();
			
		}
}

function article_cookie()
{
 var article_name = encode64("article");
 var article_val = encode64("1");
document.cookie=article_name+"=" +article_val;
//alert("This article is added to your 4t action plan");
hidediv1("add_img2");
showdiv1("add_img1");
}


function check_ie()
{
	
	var c_name="cookieie6";
	 var cookie_decode = c_name.replace(/^\s*|\s*$/,"");
	  var cookie_name =  encode64(cookie_decode);
	  var cookie_value = getCookie(cookie_name);
	  cookie_value =  decode64(cookie_value);
		if(cookie_value!=1)
	{
		 var ie6_name = encode64("cookieie6");
		 var ie6_val = encode64("1");
		document.cookie=ie6_name+"=" +ie6_val;
		location.href="isplash.html";
	}
	
}
function check_cookie(c_name)
{
	  var cookie_decode = c_name.replace(/^\s*|\s*$/,"");
	  var cookie_name =  encode64(cookie_decode);
	  var cookie_value = getCookie(cookie_name);
	  cookie_value =  decode64(cookie_value);
		if(c_name=="article")
	{
			//diabetes page
			if(cookie_value==1)
			{
				hidediv1("add_img2");
				showdiv1("add_img1");
			}	
	}
	
	else
	{
		//on test page
		if(cookie_value==0 || cookie_value==null)
				 hidediv1("expand_"+cookie_decode);
				else
				$('#'+cookie_decode).sSelect();
	}
}


function detect_flash()
{
	
if(!FlashDetect.installed)
	{
	//flash not installed 
	showdiv1("saveButton2");
	hidediv1("saveButton");
	  
	}
	else
	{
		if(FlashDetect.versionAtLeast(10)==false)
		{
	   	  //flash version less than 10
			hidediv1("saveButton");
			showdiv1("saveButton2");
			
	    }   
		else
		{
			if(document.getElementById('flv1')==null) //flash disabled
			{
				hidediv1("saveButton");
				showdiv1("saveButton2");
			}
			else
			{
			showdiv1("saveButton");
			hidediv1("saveButton2");
			}
			
		}
	}
}

