// JavaScript Document
var timerId;
var showingOnce = true;

// ************************************************************

    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
	
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
    var is_ie7    = (is_ie && (is_major == 4) && (agt.indexOf("msie 7.")!=-1) );
    var is_ie7up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5 && !is_ie6);

// ************************************************************

function showPopup( url ) 
{
       	if ( is_ie3 || is_ie4 || is_ie5 || is_ie5_5 || is_ie6 ) return false;
		
		clearTimeout(timerId);
		
		if (showingOnce) 
		 {
			 showingOnce = false;
		     //else return false;
		
		if (document.getElementById("divPopupContainer").innerHTML != "") 
		 {
		 document.getElementById("transparentDiv1").style.display = "block";
         document.getElementById("PopupBackground").style.display = "block";
         document.getElementById("Popup").style.display = "block";
         //alert("got it");
		 //return false;
		 }
		else { // Begin 2nd Else Cond
		var httpRequest;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml');        
            } 
        else if (window.ActiveXObject) 
		    { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
            }

        if (!httpRequest) { alert("Your browser does not support AJAX! Please update browser or use another one!"); return false; }

        httpRequest.onreadystatechange = function() {
                                                    try {
                                                        if (httpRequest.readyState == 4) 
		                                                 {
                                                         if (httpRequest.status == 200) 
		                                                  {
			                                               // Process request
			                                              //alert(httpRequest.responseText);
		                                                 														 														 
														  document.getElementById("divPopupContainer").innerHTML = httpRequest.responseText;
														  
														  }
                                                         else alert('There was a problem with the request: URL not found; Error ' + httpRequest.status);
                                                         }
                                                        }
                                                    catch (e) { alert('Caught Exception: ' + e.description); }
                                                    }
			
        httpRequest.open("GET", location.protocol + "//" + location.host + "/popups/" + url, true);
		httpRequest.send(null);
		} // End 2nd Else Cond
		}
}

/*
function MM_preloadImages() { //v3.0
  var d = document; 
  if (d.images) 
   { 
   if (!d.MM_p) d.MM_p = new Array();
    var i, j = d.MM_p.length, a = MM_preloadImages.arguments; 
	for ( i = 0; i < a.length; i++ )
    if ( a[i].indexOf("#") != 0 ) 
	 { 
	 d.MM_p[j] = new Image(); 
	 d.MM_p[j++].src = a[i];
	 }
   }
}
*/
var fullPath = location.protocol + "//" + location.host + "/";
MM_preloadImages( fullPath + 'images/squeezeback3.png', fullPath + 'images/innershadow.gif', fullPath + 'images/starbullet.png', fullPath + 'images/loading.gif');

function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expiredays = (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;
    
	
	var ExpDate = new Date();
        ExpDate.setDate(ExpDate.getDate() + expiredays);
	
    document.cookie =
        name + "=" + escape (value) +
        ((expiredays == null) ? "" : ("; expires=" + ExpDate.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function isValidEmail(str) 
{
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function Optin_Process(form1)
{
//val name
  if (form1.name.value == "" || form1.name.value == "Please Cap the first letter")
  {
   alert("Please don't forget to put Your name!");
   form1.name.focus();
  return false;
  }

//val email
  if (form1.from.value == "")
  {
   alert("Please enter a value for the \"Email\" field.");
   form1.from.focus();
   return false;
  }
// test if valid email address, must have @ and .

   if (!isValidEmail(form1.from.value))
   {
  alert("Please enter your valid email address!");
  form1.from.focus();
  return false;
    }

SetCookie("LifeCellCustName", document.forms['form1'].elements["name"].value, 30, "/", "www.lifecellskin.com");
opacity('submitDiv', 100, 0, 1000);
setTimeout("changeSubmitDiv()",1000);
setTimeout("opacity('submitDiv', 0, 100, 1500)",1000);
//return false;
}

function changeSubmitDiv()
{
document.getElementById("submitDiv").innerHTML = '<br /><img src="loading.gif" border="0" alt="*" /> <span class="pTextJustify" style=" color:white;"><b>Loading...</b></span>';	
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}

}

function ClosePopup()
{
document.getElementById("transparentDiv1").style.display = "none";
document.getElementById("PopupBackground").style.display = "none";
document.getElementById("Popup").style.display = "none";
}

var capitalizeMe = function( obj, cap ) {
       val = obj.value;
       newVal = '';
       val = val.split(' ');
       for ( var c = 0; c < val.length; c++ )
	     {
	     newVal += val[c].substring( 0, 1 ).toUpperCase();  
		 switch( cap )
		       {
			   case 'UC':
			      newVal += val[c].substring( 1, val[c].length ).toUpperCase();
			   break;
			   case 'LC':
			      newVal += val[c].substring( 1, val[c].length ).toLowerCase();
			   break;
			   default:
			      newVal += val[c].substring( 1, val[c].length );
			   }
		 newVal += ( c == val.length-1 ? '' : ' ' );
		 }
       
	   obj.value = newVal;
       }

var setPopupTimer = function( timer, url ) {
	if ( GetCookie('LifeCellCustName') == null ) timerId = setTimeout("showPopup('" + url + "')", timer * 1000 );
	}
	
var execPopup = function( url ) {
	if ( GetCookie('LifeCellCustName') == null ) showPopup( url );
	}
	
