/*
		This Aplication Interface (A.P.I) was writen and modified by Chad Chamberlain on 7-6-2001.
*/

/* who wrote this code*/
var who = "Chad Chamberlain";
var modified = "Changes to the API made on 7-6-2001";
var author = who+" "+modified;

//ad code
function ad_random(sec,sz){var size = new Array ();size = sz.split("x");var now = new Date();randomnum = parseInt(now.getTime() + (Math.random()*100));var none=0;document.write('<a href="http://ad.doubleclick.net/jump/network.now.com/network;tile=5;sec='+sec+';sz='+sz+';ord='+randomnum+'?"><img src="http://ad.doubleclick.net/ad/network.now.com/network;tile=5;sec='+sec+';sz='+sz+';ord='+randomnum+'?" width='+size[0]+' height=' +size[1] + ' border=0 vspace=0 hspace=0></a>');}


//this function is used to launch interactives
function launch(pageTitle,w,h,address)
{
	newWin = window.open("",pageTitle,'width='+w+',height='+h+',status=no,toolbar=no,scrollbars=no')
	newWin.location = address
}


//this is used to launch a small window with the pop poll question in it
VoteWindow = false;
function popQuestion(VoteUrl, SectionForAdd) {
	var URL = "http://cbsnews.com/common/html/popvotequestion/popQVoteFrameset.html?qVote=" + VoteUrl + "&sec=" + SectionForAdd;
	var size = "width=250,height=430"

	if (!VoteWindow) {
		VoteWindow = window.open(URL, '', size);
	} else {
		if (VoteWindow.closed) {
			VoteWindow = window.open(URL, '', size);
		} else {
			VoteWindow.focus();
		}
	}
}



//this is for form drop down lists that have urls in them
function gothere(f_name, el_name){
                loc=document.forms[f_name].elements[el_name].options[document.forms[f_name].elements[el_name].selectedIndex].value;
 location=loc;
} 


/* This feature uses a cookie to count how many times a user visits the page to view the pop up... If that
	amount exceeds three times then the promo is not shown.
*/
//setting cookies for pop up
 function getCookieVal (offset) {  
        var endstr = document.cookie.indexOf (";",offset);  
        if (endstr == -1)    
                endstr = document.cookie.length;  
                return unescape(document.cookie.substring(offset, endstr));
	}
function GetCookie(name) {  
        var arg = name + "=";  
        var arg2 = arg.length;  
        var arg3 = document.cookie.length;  
        var i = 0;  
        while (i < arg3) {    
        var j = i + arg2;    
        if (document.cookie.substring(i, j) == arg)      
                return getCookieVal (j);    
                i = document.cookie.indexOf(" ", i) + 1;    
                if (i == 0) break;   
        }  
        return null;
}

function setCookie(name,value)
{
	var the_date = new Date("December 31, 2001");
	var the_cookie_date = the_date.toGMTString();
/* so now we will create the cookie and save it to the users machine*/
	document.cookie = name + "=" + escape (value) +";expires=" + the_cookie_date;
	//alert(document.cookie);
	}

function readCookie(count)
{
	var the_cookie = document.cookie;
	var broken_cookie = the_cookie.split("=");
	var name_cookie = broken_cookie[0];	
	var count = GetCookie('count')
    		if (count <= 3) 
				{
					count++;
					//alert(count);
					launch_promo();
					setCookie ('count', count);
                }
            else
				{  
					//alert("no more cookie for you");
                }
        
        return count;
}


//this function launches the promo for the earlyshow
function launch_promo()
{
	address="http://cbsnews.com/earlyshow/promo.html";
	newWin = window.open(address,"promo",'width=250,height=250,status=no,toolbar=no,scrollbars=no');
	newWin.location = address;
	newWin.focus();
	setTimeout('newWin.close()',10000);
}

//opens a window and then closes it after a certain amount of time

function openMe(url,width,height){
var dim = eval('"width=' + width + ',height=' + height + '"');
Npop = window.open(url,"Earlyshow",dim);
timer=setTimeout("Npop.close()", 30000);
Npop.focus();
}


function test(){
var browser = navigator.appName;
if(browser == "Netscape"){
self.location.href = "http://cbsnews.cbs.com/earlyshow/living/travel/09_25_entry_Netscape.html"
}
}
function PopUp(url,w,h) {
var dim = eval('"width=' + w + ',height=' + h + '"');
Npop = window.open(url,"pop",dim);
}

if (document.layers) {
  visible = 'show';
  hidden = 'hide';
} else if (document.all) {
  visible = 'visible';
  hidden = 'hidden';
}

function stepOne() {
 if (document.all) {
    entryform = document.all.entryForm.style;
  }
  if (entryform.visibility == visible) {
    entryform.visibility = hidden;
  } else {
    entryform.visibility = visible;
	checkform();
  }
}
function checkform(){
if (entryform.visibility == visible) {
	document.forms[0].ACCEPT.disabled = true;
	}

}


function stepOne(Fobj) {
var firstName = Fobj.fname.value;
var lastName = Fobj.lname.value
var address1 = Fobj.address1.value;
var address2 = Fobj.address2.value;
var city = Fobj.city.value;
var state = Fobj.state.value;
var zipcode = Fobj.zipcode.value;
var email = Fobj.email.value;
var email2 = Fobj.email2.value;
var email_option = Fobj.email_option.value;
var ph_area = Fobj.ph_area.value;
var ph_prefix = Fobj.ph_prefix.value;
var ph_suffix = Fobj.ph_suffix.value;
var bday_month = Fobj.bday_month.value;
var bday_day = Fobj.bday_day.value;
var bday_year = Fobj.bday_year.value;
// Values to validate for space

if(firstName.length < 1){
alert("Please enter your first name");
Fobj.fname.focus();
return;
}

if(lastName.length < 1){
alert("Please enter your last name");
Fobj.lname.focus();
return;
}

if(address1.length < 1){
alert("Please enter your address");
Fobj.address1.focus();
return;
}

if(address2.length < 1){
alert("Please enter your address");
Fobj.address2.focus();
return;
}


if(city.length < 1){
alert("Please enter your city");
Fobj.city.focus();
return;
}

if(state.length < 1){
alert("Please enter your state");
Fobj.state.focus();
return;
}

if(zipcode.length < 1){
alert("Please enter your zipcode");
Fobj.zipcode.focus();
return;
}

if(email.length < 1){
alert("Please enter a correct e-mail address");
Fobj.email.focus();
return;
}


}

function stepOne() {
  PopUp('form.html',400,400);
}
