
/* Opens popup window  */
function opener(page)
{
  window.open(page, "popup", "location=no,menubar=no,resizable=no,width=550,height=580,scrollbars=yes");
}

/* Opens popup window */
function NewWindow(mypage, myname, w, h, scroll) 
{
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* Even 'column' script
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com
Modified by Erica Melton to work in WST
How it works: just apply the CSS class of 'column' to your pages' main columns.
Add "matchColumns();" to body onload.
*/
function matchColumns()
{ 
  var divs,contDivs,maxHeight,divHeight,d; 
	
  // get all <div> elements in the document 
  divs=document.getElementsByTagName('div'); 
  contDivs=[]; 

  // initialize maximum height value 
  maxHeight=0; 

  // iterate over all <div> elements in the document 
  for(var i=0;i<divs.length;i++){ 
    // make collection with <div> elements with class attribute 'container' 
    if(/\bcolumn\b/.test(divs[i].className))
	  { 
      d=divs[i]; 
      contDivs[contDivs.length]=d; 
		
      // determine height for <div> element 
      if(d.offsetHeight)
	    { divHeight=d.offsetHeight;}
      else if(d.style.pixelHeight)
	    { divHeight=d.style.pixelHeight;} 

      // calculate maximum height 
      maxHeight=Math.max(maxHeight,divHeight); 
      } 
    } 

    // assign maximum height value to all of container <div> elements 

    for(var i=0;i<contDivs.length;i++)
	{ contDivs[i].style.height=maxHeight + "px"; } 	
} 

/* AJAX FUNCTION */
function ajaxFunction(url,divid)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById(divid).innerHTML = xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
  }
  
function getSIFR()
{
  //<[CDATA[
  var stempelgaramond = {src: 'images/StempelGaramond.swf'};

  //sIFR.debugMode = true;
  // sIFR.domains = ['novemberborn.net'] // Don't check for domains in this demo selector: '#qm0 a'
  sIFR.activate(stempelgaramond);

	//,'font-size':'20px','width':'334px'
  
	sIFR.replace(stempelgaramond, {selector: 'h1'
		,css: {
	  '.sIFR-root': { 'color': '#000000', 'letter-spacing': 1.5, 'background-color':'#e6a664','font-size':'20px'}
	}
	,wmode:'transparent'
	,offsetLeft:-12
	,fixHover:true
	,selectable:false
	,forceWidth:true
	
	}
); //]]>
} //end sIFR function 



//Functions for pop up boxes 
function closepopup(boxname){
	box = document.getElementById(boxname);
	box.style.visibility = "hidden";
}

function openpopup(boxname){
	box = document.getElementById(boxname);
	box.style.visibility = "visible";
}


/***********************************************************************
PopLight functions for lightbox popups
***********************************************************************/
$(document).ready(function() {

//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="/images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});
});

/***********************************************************************
NIVO slider for home page image slider
***********************************************************************/
$(window).load(function() {

    var total = $('#slider img').length;
    var rand = Math.floor(Math.random()*total);


	$('#slider').nivoSlider({
		effect:'fade',
		//slices:15,
		//animSpeed:500,
		//pauseTime:3000,
		//startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		//directionNavHide:true, //Only show on hover
		//controlNav:true//, //1,2,3...
		//controlNavThumbs:false, //Use thumbnails for Control Nav
		//controlNavThumbsSearch: '.jpg', //Replace this with...
		//controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		//keyboardNav:true, //Use left & right arrows
		//pauseOnHover:true, //Stop animation while hovering
		//manualAdvance:false, //Force manual transitions
		//captionOpacity:0.8, //Universal caption opacity
		//beforeChange: function(){},
		//afterChange: function(){},
		//slideshowEnd: function(){} //Triggers after all slides have been shown
		startSlide:rand //choose a random starting slide
	});

});

/***********************************************************************
Counter countdown to show
***********************************************************************/
<!--
var year = 2010;			// in what year will your target be reached?
var month = 8;				// value between 0 and 11 (0=january,1=february,...,11=december)
var day = 23;				// between 1 and 31
var hour = 18;				// between 0 and 24
var minute = 0;			// between 0 and 60
var second = 0;			// between 0 and 60
var eventtext = "greenville, sc <img src='/images/wine-glass-icon.png' width='8px' height='27px' style='vertical-align:middle'/> september 23-26, 2010 <img src='/images/fork-icon.png' width='8px' height='27px' style='vertical-align:middle'/> "; // text that appears next to the time left
var endtext = "Euphoria is now!"; // text that appears when the target has been reached
var end = new Date(year,month,day,hour,minute,second);
function timeleft(){
	var now = new Date();
	if(now.getYear() < 1900)
		yr = now.getYear() + 1900;
	var sec = second - now.getSeconds();
	var min = minute - now.getMinutes();
	var hr = hour - now.getHours();
	var dy = day - now.getDate();
	var mnth = month - now.getMonth();
	var yr = year - yr;
	var daysinmnth = 32 - new Date(now.getYear(),now.getMonth(), 32).getDate();
	if(sec < 0){
		sec = (sec+60)%60;
		min--;
	}
	if(min < 0){
		min = (min+60)%60;
		hr--;	
	}
	if(hr < 0){
		hr = (hr+24)%24;
		dy--;	
	}
	if(dy < 0){
		dy = (dy+daysinmnth)%daysinmnth;
		mnth--;	
	}
	if(mnth < 0){
		mnth = (mnth+12)%12;
		yr--;
	}	
	var sectext = " seconds ";
	var mintext = " minutes : ";
	var hrtext = " hours ";
	var dytext = " days : ";
	var mnthtext = " months : ";
	var yrtext = " years : ";
	if (yr == 1)
		yrtext = " year : ";
	if (mnth == 1)
		mnthtext = " month : ";
	if (dy == 1)
		dytext = " day : ";
	if (hr == 1)
		hrtext = " hour : ";
	if (min == 1)
		mintext = " minute : ";
	if (sec == 1)
		sectext = " second ";
	if(now >= end){
		document.getElementById("timeleft").innerHTML = endtext;
		clearTimeout(timerID);
	}
	else{
	//document.getElementById("timeleft").innerHTML = yr + yrtext + mnth + mnthtext + dy + dytext + hr + hrtext + min + mintext + sec + sectext + eventtext;
    //document.getElementById("timeleft").innerHTML = eventtext + "" + "<table><tr><td>"+mnth+": </td><td>"+dy+": </td><td>"+hr+": </td><td>"+min+": </td><td>"+sec+"</td></tr>"+"<tr><td>mths</td><td>days</td><td>hrs</td><td>mins</td><td>secs</td></tr></table>"
    document.getElementById("timeleft").innerHTML = "<h3 class='fontface'>" + eventtext + "" + ""+mnth+" months. "+dy+" days.</h3>"
	}
	timerID = setTimeout("timeleft()", 1000); 
}
window.onload = timeleft;
//-->

/***********************************************************************
Zoomer for Image Gallery
***********************************************************************/
$(document).ready(function(){
 	$('ul.thumb li').Zoomer({speedView:200,speedRemove:400,altAnim:true,speedTitle:400,debug:false});
});

