// Copyright 2000-2011, DataCom/OTA, Inc.
	
// Setup
// Google
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27423865-1']);
  _gaq.push(['_setDomainName', 'winterfun101.com']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

// BigFun Submenu
var bfscItems = new Array();
var currentLeft = 0;

// init site
function initWF(adGroup, firstAd) {
	ads(adGroup, firstAd);
	startSnow();
}

// Text popups
var iPics = new Array();
iPics[0]="/happenings/story.html";
//iPics[1]="/happenings/story2.html";

iPic=0;

//SlideShow
function iImages() {
	if (iPic < iPics.length) {
		getFile(iPics[iPic], "iStory");
		//document.getElementById('iPic').innerHTML = iPics[iPic];
		//document.getElementById('iPic').src = iPics[iPic];
	iPic++;
	} else {
	iPic = 0;
		getFile(iPics[iPic], "iStory");
		//document.getElementById('iPic').innerHTML = iPics[iPic];
		//document.getElementById('iPic').src = iPics[iPic];
	iPic++;
	}
	setTimeout ("iImages()", 10000);
}


// Set cookies
function setCookie(theName, theValue) {
	var expDate = new Date;
	expDate.setMonth(expDate.getMonth()+6);
	document.cookie = theName + "=" + theValue +";path=/;expires=" + expDate.toGMTString() +";"
}

// Read cookies
function getCookie(cookieName) {
  var cookieData = document.cookie;
  var i = 0;
  var cEnd;
  while (i < cookieData.length) {
    var j = i + cookieName.length;
    if (cookieData.substring(i, j) == cookieName) {
      cEnd = cookieData.indexOf(";", j);
      if (cEnd == -1)
        cEnd = cookieData.length;
      return decodeURIComponent(cookieData.substring(j + 1, cEnd));
    }
    i++;
  }
  return "";
}

// Delete Cookie
function deleteCookie (name, path, domain) {
	if (getCookie(name))
    	document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

// Open Files
function openFile(theFile) {
    window.open (theFile);
}

function openFileA(theFile, theWindow, theBar, theSize, theWidth, theHeight) {
    window.open (theFile, theWindow,"status=no,location=no,toolbars="+theBar+",menubar="+theBar+",directories=no,scrollbars=yes,resizable="+theSize+",width="+theWidth+",height="+theHeight);
}

// bfsc sub menu
function bfSubmenu() {
	var divID = document.getElementById("scroller").getElementsByTagName("div");
	var menuList = new Array();
    var i = 0;
    for(i=0;i<divID.length;i++) {
		var menuItem = divID[i].id.replace(/-/gi, "&nbsp;");
		var x = (i == divID.length-1) ? i-1 : i ;
		var menuLink = '<a href="javascript:moveDiv(\'' + 300*x + '\', \'' + divID[i].id + '-mi\');" id="' + divID[i].id + '-mi">' + menuItem + '</a>';
		bfscItems.push(divID[i].id + "-mi");
		menuList.push(menuLink);
	}
	var menuString = "<p>";
	menuString = menuString + menuList.join(" &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; ");
	menuString = menuString + "</p>";
	  document.getElementById("cgiMenu").innerHTML = (menuString);
}

function moveDiv(theEnd, theItem) {
	var newLeft = currentLeft - theEnd;
	currentLeft = eval(theEnd);
	var i = 0;
    for(i=0;i<bfscItems.length;i++) {
		document.getElementById(bfscItems[i]).style.removeProperty("color");
	}
	document.getElementById(theItem).style.color="#F60";
	if (newLeft<0) { start=eval(currentLeft+newLeft);finish=Math.abs(newLeft)+start;scrollDivLeft(start, finish); }
	if (newLeft>0) { start=eval(newLeft+currentLeft);finish=currentLeft;scrollDivRight(start, finish); }
}

function scrollDivLeft(start, finish){
	//window.alert(start);
	if (start != finish) {
		start+=15;
		document.getElementById('quicktips').scrollLeft=start;
		setTimeout(function(){scrollDivLeft(start, finish)},10)
	}
}

function scrollDivRight(start, finish){
	//window.alert(start);
	if (start != finish) {
		start-=15;
		document.getElementById('quicktips').scrollLeft=start;
		setTimeout(function(){scrollDivRight(start, finish)},10)
	}
}

// AJAX File Request
function getFile(theFile, theDiv) {
	var pageReq = false;
	
    if (window.XMLHttpRequest) {
        pageReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
		try {
			pageReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				pageReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				pageReq = false;
			}
		}
	}
	
    pageReq.open('GET', theFile, true);
    pageReq.onreadystatechange = function() {
        if (pageReq.readyState == 4) {
			document.getElementById(theDiv).innerHTML = pageReq.responseText;
		}
    }
    pageReq.send(null);
}

//Process Forms
function postFile(theCGI, theQuery, theDiv) {
	var pageReq = false;
	
    if (window.XMLHttpRequest) {
        pageReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
		try {
			pageReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				pageReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				pageReq = false;
			}
		}
	}
	
    pageReq.open('POST', theCGI, true);
    pageReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    pageReq.onreadystatechange = function() {
        if (pageReq.readyState == 4) {
			document.getElementById(theDiv).innerHTML = pageReq.responseText;
            //updatepage(pageReq.responseText);
        }
    }
    pageReq.send(eval(theQuery)());
	document.getElementById(theDiv).innerHTML = "<h1>Sending . . . </h1>";
}

// /contact.shtml (contact us) form
function cu() {
    var form = document.forms['contact'];
    var fn = form.Name.value;
	var ph = form.Phone.value;
    var em = form.Email.value;
    var cm = form.Comments.value;
    qstr = 'Name=' + escape(fn) + '&Phone=' + escape(ph) + '&Email=' + escape(em) + '&Comments=' + escape(cm);
    return qstr;
}

