
function show(x)
{	
	xmlhttp=GetXmlHttpObject();
	document.getElementById("w_content").innerHTML = "<img src=\"http://jerrymannel.com/blog/wp-content/themes/punchcut/wimages/ajax-loader.gif\">";
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="http://jerrymannel.com/blog/wp-content/themes/punchcut/weddingGetData.php";
	url=url+"?data="+x;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("w_content").innerHTML = xmlhttp.responseText;
	}
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest){return new XMLHttpRequest();}
	if (window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}
	return null;
}

function showInvite(x)
{
	url_root="http://jerrymannel.com/blog/wp-content/themes/punchcut/wimages";
	invite = new Array("g-front.png", "g-1.png", "g-2.png", "g-back.png");
	switch(x)
	{
		case 1: document.getElementById('wc_time-c').innerHTML="<img src=\""+url_root+"/"+invite[0]+"\" />"; break;
		case 2: document.getElementById('wc_time-c').innerHTML="<img src=\""+url_root+"/"+invite[1]+"\" />"; break;
		case 3: document.getElementById('wc_time-c').innerHTML="<img src=\""+url_root+"/"+invite[2]+"\" />"; break;
		case 4: document.getElementById('wc_time-c').innerHTML="<img src=\""+url_root+"/"+invite[3]+"\" />"; break;
	}
}

function showTimer()
{
	document.getElementById('w_content').innerHTML = " \
		<div id=\"w_timer\">\
			<div id=\"w_timer-normal\" style=\"text-align:center; padding: 10px;\" class=\"timer_box\">\
				<p class=\"w_timer_title\"> For \"Normal\" People </p>\
				<p>Years Passed</p>\
					<p id=\"t_day_n\" class=\"w_timer_time\"></p>\
				<p>Months Over </p> \
					<p id=\"t_hour_n\" class=\"w_timer_time\"></p>\
				<p>Days i survived</p> \
					<p id=\"t_min_n\" class=\"w_timer_time\"></p>\
				<p>Hours i escaped</p> \
					<p id=\"t_sec_n\" class=\"w_timer_time\"></p>\
			</div> \
			<div id=\"w_timer-normal\" style=\"text-align:center; padding: 10px; background-color: #000000;\" class=\"timer_box\">\
				<p class=\"w_timer_title\"> For \"Geeks\" </p>\
				<p>Years Passed</p>\
					<p id=\"t_day_g\" class=\"w_timer_time\"></p>\
				<p>Months Over </p> \
					<p id=\"t_hour_g\" class=\"w_timer_time\"></p>\
				<p>Days i survived</p> \
					<p id=\"t_min_g\" class=\"w_timer_time\"></p>\
				<p>Hours i escaped</p> \
					<p id=\"t_sec_g\" class=\"w_timer_time\"></p>\
			</div> \
		</div> \
	";
	t=setTimeout("timer()",1000);
}

String.prototype.toBinaryString = function() {
   var returnBinary = "";
   for (var i=0; i<this.length; i++) {
      returnBinary = returnBinary+" "+(this.charCodeAt(i)).toString(2);
   }
   return returnBinary;
}

function timer()
{
	today = new Date("February 11, 2010 12:45:00");
	w_day = new Date();
	//w_day = new Date("January 11, 2010 2:00:00");
	
	year=1000*60*60*24*365;
	month=1000*60*60*24*30;
	day=1000*60*60*24;
	hour=1000*60*60;
	min=1000*60;
	
	remainder_years = Math.floor((w_day.getTime()-today.getTime())/year);
	remainder_months = Math.floor((w_day.getTime()-today.getTime())/month);
	remainder_days = Math.floor((w_day.getTime()-today.getTime())/day);
	remainder_hours = Math.floor((w_day.getTime()-today.getTime())/hour);
	remainder_mins = Math.floor((w_day.getTime()-today.getTime())/min);
	remainder_secs = Math.floor((w_day.getTime()-today.getTime())/1000);
	
	// NORMAL
	document.getElementById('t_day_n').innerHTML=remainder_years;
	document.getElementById('t_hour_n').innerHTML=remainder_months;
	document.getElementById('t_min_n').innerHTML=remainder_days;
	document.getElementById('t_sec_n').innerHTML=remainder_hours;
	
	// GEEK
	document.getElementById('t_day_g').innerHTML=remainder_years.toString(2);
	document.getElementById('t_hour_g').innerHTML=remainder_months.toString(2);
	document.getElementById('t_min_g').innerHTML=remainder_days.toString(2);
	document.getElementById('t_sec_g').innerHTML=remainder_hours.toString(2);
	
	t=setTimeout("timer()",1000);
}

// THE PHOTO ALBUM
function showPhoto()
{
	url_root="http://jerrymannel.com/blog/wp-content/themes/punchcut/wimages";
	document.getElementById('w_content').innerHTML = " \
		<div id=\"w_photo\"> \
			<div id=\"slideshow\"> \
				<img src=\""+url_root+"/i-01.jpg\" alt=\"Slideshow Image 1\" class=\"active\" /> \
				<img src=\""+url_root+"/i-02.jpg\" alt=\"Slideshow Image 2\" /> \
				<img src=\""+url_root+"/i-03.jpg\" alt=\"Slideshow Image 3\" /> \
				<img src=\""+url_root+"/i-04.jpg\" alt=\"Slideshow Image 4\" /> \
				<img src=\""+url_root+"/i-05.jpg\" alt=\"Slideshow Image 4\" /> \
			</div> \
		</div> \
	";
	$(function() {
		setInterval( "slideSwitch()", 3000 );
	});
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
