//var images = ['image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg'];
//$('#prog_os').css({'background-image': 'url(images/' + images[Math.floor(Math.random() * images.length)] + ')'});



function tabletTime()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM" 
if (hours>12)
{
dn="PM"
hours=hours-12
//this is so the hours written out is 
//in 12-hour format, instead of the default //24-hour format.
}
if (hours==0)
hours=12
//this is so the hours written out 
//when hours=0 (meaning 12a.m) is 12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
/*document.toolbar_mid.Clock.value=
hours+":"+minutes+":"+seconds+" "+dn*/

//var currentTimeString = hours+":"+minutes+":"+seconds+" "+dn;
var currentTimeString = hours+":"+minutes+" "+dn;
 document.getElementById("Clock").firstChild.nodeValue = currentTimeString;
setTimeout("tabletTime()",1000)
}


$(document).ready(function() {
	     //     counter going in uner here
					document.domain = "innerwolfdesigns.com" 
					
 if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version <9) { toOld = '2old'} else { toOld ='imYoung'}

if (toOld == '2old'){
	
	$('#ipad_wrapper').css({
    background: 'url(../images/ipad_base_land.png) no-repeat',
    height: '807px',
    width: '1030px'
})
	$('#statusbar').css({left: '152px'});
	$('#container2').css({left: '150px'});
	$('#power_button a').css({left: '939px', top: '339px'});
	
	}

var prg = ''

$(window).load(function () {
  pad_Boot();
});
// boot up section ************************************************************************************************************** boot up section
					
function pad_Boot()
{
		$("#container2").delay(500).css({backgroundColor: '#222222'})
		$("#bootup").delay(1000).fadeIn(1500, function (){
				$("#loadingZone").fadeIn("fast");
				$("#progressBar").animate({width: "45%"}, 2000, function (){
					$("#progressBar").delay(500).animate({width: "60%"}, 2000, function (){
						$("#progressBar").animate({width: "83%"}, 3000, function (){
							$("#progressBar").animate({width: "100%"}, 2000, function (){
							$("#progressBar").animate({width: "1%"}, 20)
								$("#loadingZone").fadeOut(1000,function (){
									$("#bootup").delay(1000).fadeOut("slow", function (){
									$("#prog_os").fadeTo("fast", 1, function (){statusbar_Show();
									if ($('#welcomescreen').length){welcomeAnim();}
									});
										
									});});});});});});});
									
		}
		
		
function statusbar_Show()
{	
$("#statusbar").fadeIn("slow", function (){$("#statusbar").css({opacity:'0.75'});tabletTime()});
}
function statusbar_Hide()
{	
$("#statusbar").fadeOut("slow");
}


function welcomeAnim(){
	
	if (toOld=='2old'){
	
		$('#welcomescreen').css('background', '#FFFFFF url(../images/welBackgraph.png) no-repeat -100px -70px;');
		$('#welcome2').css('font-size', '72px');
		$('#welcome2').css('height', '72px');
		$("#welcomescreen").delay(500).show('fast', function() {
		$('#welcome2').fadeIn(1500, function (){
		$('#welcome2').delay(1000).animate({fontSize: '24px', height: '30px'},1000, function(){
		$('#innerwolfred').show(1000, function() {
			$('#designgrey').slideDown(1000, function (){	
			
			
			$('#progHolderOuter').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
			//$('#progHolder').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
			$('#progGuide').delay(1000).slideDown(1000, function(){
				$('#progHolderOuter').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast');
				//$('#progHolder').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast');
				$('#progGuide').delay(5000).slideUp('fast', function(){
					$('#progHolder img').attr('src','images/email_app.png');
					$("#progGuide").html("Contact us with design enquiries. Report a problem with this site. Or simply read and leave feedback in our comments section.");
		
		emailGuide()
		 });});});});});});});}
		 
		 else {
			 
	$("#welcomescreen").delay(500).show('fast');
	$('#welcome2').css({width: '0px'});
		$('#welcome2').scale(3);
		$('#innerwolfred').scale(5);
		$('#innerwolfred').css({display: 'block', opacity: '0'});

	//$('#welcome2').animate({width: '150px'}, 1500);
	$('#welcome2').show()
	$('#welcome2').animate({width: '150px', scale: '-=2'}, 1500,  function (){
	//$('#welcome2').animate({zoom: '100%'}, 1500, function (){
		$('#innerwolfred').animate({scale: '-=4', rotate: '+=360', opacity: '1'}, 1000, function() {
			$('#designgrey').slideDown(1000, function (){
			$('#progHolderOuter').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
				//$('#progHolder').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
					$('#progGuide').delay(1000).slideDown(1000, function(){
						$('#progHolderOuter').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast')
						//$('#progHolder').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast')
						$('#progGuide').delay(5000).slideUp('fast', function(){
		$('#progHolder img').attr('src','images/email_app.png');
		$("#progGuide").html("Contact us with design enquiries. Report a problem with this site. Or simply read and leave feedback in our comments section.");
		
		emailGuide()
		 }); }); }); });}); 
			 
			 };
		 
		 
		 
		 } 
		 
		 
		
function emailGuide (){

				$('#progHolderOuter').animate({ opacity: '1', left: '130px'}, 1500)
				//$('#progHolder').animate({ opacity: '1', left: '130px'}, 1500)
					$('#progGuide').delay(500).slideDown(1000, function(){
						$('#progHolderOuter').delay(6000).animate({ opacity: '0', left: '-200px'}, 'fast')
						//$('#progHolder').delay(6000).animate({ opacity: '0', left: '-200px'}, 'fast')
							$('#progGuide').delay(6000).slideUp('fast', function(){
								$('#progHolder img').attr('src','images/rss_app.png');// change icon to rss
								$("#progGuide").html("Read some of the latest RSS feeds from a selection of out clients. Or search for Feeds on the web.");

								  rssGuide();});});}
								
								function rssGuide(){
									$('#progHolderOuter').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
									//$('#progHolder').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
										$('#progGuide').delay(1000).slideDown(1000, function(){
											$('#progHolderOuter').delay(6000).animate({ opacity: '0', left: '-200px'}, 'fast')
											//$('#progHolder').delay(6000).animate({ opacity: '0', left: '-200px'}, 'fast')
												$('#progGuide').delay(6000).slideUp('fast', function(){
														$('#progHolder img').attr('src','images/gallery.png'); // change icon to gallery
														$("#progGuide").html("View a slideshow of a selection of our photos.");

														  galleryGuide()});});}
														
														function galleryGuide(){
															$('#progHolderOuter').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
															//$('#progHolder').delay(500).animate({ opacity: '1', left: '130px'}, 1500)
																$('#progGuide').delay(1000).slideDown(1000, function(){
																	$('#progHolderOuter').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast')
																	//$('#progHolder').delay(5000).animate({ opacity: '0', left: '-200px'}, 'fast')
																		$('#progGuide').delay(5000).slideUp('fast', function(){ 
																		$('#welcomescreen').delay(1000).fadeOut('slow', function (){$('#welcomescreen').remove();
																		fly()})});});
														
}
$("#skip img").click(function(){
	$('#welcomescreen').delay(1000).fadeOut('slow', function (){$('#welcomescreen').remove(); fly()})})

function fly(){
	if (toOld =='imYoung') {
$('#fly').css({display: 'block'});		
$('#fly').rotate('-10deg');
$('#fly').css({top:'900px', left: '600px'});
$('#fly').delay(2000).animate({top: '560px', left: '500px'},400, function (){
	$('#fly').animate({rotate: '+=10deg'},200, function(){
		$('#fly').animate({top: '530px', left: '500px'},800, function (){
			$('#fly').delay(500).animate({rotate: '+=10deg'},500, function (){
				$('#fly').animate({top: '250px', left: '550px'},500, function (){
					 $('#fly').delay(500).animate({rotate: '+=2deg'},300, function (){
						 $('#fly').animate({rotate: '-=2deg'},200, function (){
							 $('#fly').animate({rotate: '+=10deg'},50, function (){
								 $('#fly').animate({rotate: '+=20deg'},30, function (){
									 $('#fly').delay(300).animate({top: '-50px', left: '1000px'},100   ) })})})})})})})})})
} else {return false; }}
// END boot up section ************************************************************************************************************** END boot up section
	
	
	
// power button section ************************************************************************************************************** powerbutton section
    $('#power_button').click(function() {
		var img = $(this).find('img');
    	var src = img.attr('src');
    //image is on, so change src to off and return
    if(src == 'images/OnNormal2.png') {
        img.attr('src','images/OffNormal2.png')
			
				if ($('#myIframe').is(':visible')){
					$('#myIframe').fadeTo("slow", 0.3, function (){
						$(".close_page").fadeTo("slow", 0.3);
						$("#alert_message").html("This tablet is shutting down");
						$("#alert_ok").hide();
						$("#alert_yesno").hide();
						$("#alert_shutdown").show();	
						$(".droidalert").delay(500).fadeIn("fast")
					});
				} else {
				
			 		$('.progs').fadeTo("slow", 0.3, function (){
						$("#alert_message").html("This tablet is shutting down");
						$("#alert_ok").hide();
						$("#alert_yesno").hide();
						$("#alert_shutdown").show();	
						$(".droidalert").delay(500).fadeIn("fast")
					});
				}
        return false;    
    }

    //image is off, so change src to x and return
    if(src == 'images/OffNormal2.png') {
        img.attr('src','images/OnNormal2.png');
		pad_Boot();
		
        return false;    
    }

  });	
  
  

// ************** shutdown section *********************


function power_standby()
{	
$('#power_button').fadeIn("fast").delay(500).fadeOut('fast').delay(500);
}

  $("#shutdown").click(function (){
	  	
		$(".droidalert").fadeOut("fast", function (){
			$("#statusbar").delay(500).fadeOut(500, function (){
				$(".close_page").fadeTo('fast',1);
				$(".close_page").hide();
				$(".progs").delay(500).fadeOut(500, function (){
				$('#myIframe').remove();
				$("#container2").css({backgroundColor: '#283739'})
			});
			});
		});
	});
	
	
	
	$("#cancel").click(function (){
		$(".droidalert").fadeOut("fast");
		
		if ($('#myIframe').is(':visible')){
					$('#myIframe').fadeTo("slow", 1);
					$(".close_page").fadeTo("slow", 1);
		} else
		$("#prog_os").fadeTo("slow", 1)
		$('#power_button').find('img').attr('src','images/OnNormal2.png')
	});
	
	
// ************** shutdown section *********************

// END power button section ************************************************************************************************************** END powerbutton section




// additional programs tab section ************************************************************************************************************** additional programs tab section


  $('#theTab').click(function() {
    $('#programmes').animate({width: 'toggle'});
var img = $(this).find('img');
    	var src = img.attr('src');
    //image is on, so change src to off and return
    if(src == 'images/tab_open.png') {
        img.attr('src','images/tab_close.png');
        return false;    
    }

    //image is off, so change src to x and return
    if(src == 'images/tab_close.png') {
        img.attr('src','images/tab_open.png');
        return false;    
    }

  });
  
// END additional programs tab section ************************************************************************************************************** END additional programs tac section

// programs  icons *********************************************************
$('.prog_icon').click(function () {
		prg =this.id
		var a ='url(images/splash_'
		var b = ".jpg)"
		var splashpic = a + prg + b	
		var frm  = prg +'.html'

		
		$('.splash').css('background-image', splashpic);
		$('#'+prg +'_Icon').show('slow');
		$('.splash').fadeIn('slow', function() {  
			$('#prog_os').fadeOut("slow")
			$('<iframe />', {
			id:   'myIframe',
			frameborder: '0',
			marginheight: '0',
			marginwidth: '0',
			scrolling: 'no',
			display:'block',
			src: frm
			}).appendTo('#container2');	
			$('#myIframe').addClass('progs');
			$('#myIframe').load(function (){
			$(".close_page").show('slow');
    		$('.splash').delay(500).fadeOut("slow")
     		});
	
		});
	
});
//******************************************************
	
       
		
	$('.close_page').click(function (){
		closepage();
	});
	
	$("#no").click(function (){
		$(".droidalert").fadeOut("fast");
	});

	$('#home').click(function (){
		if ($('#myIframe').is(':visible'))
		{closepage(); 
		return false;  }
		})
	
	function closepage() {
		var stuff2 = prg
			if (stuff2 == 'os'){
			return false;}
			else if (stuff2 == 'mail'){
				$("#alert_message").html("Are you sure you want to Close IWD Send-It?");
				}
			else if (stuff2 == 'rss'){
				$("#alert_message").html("Are you sure you want to Close IWD RSS News?");}
			else if (stuff2 == 'gallery'){
				$("#alert_message").html("Are you sure you want to Close IWD Darkroom?");}
			else if (stuff2 == 'browser'){
						$("#alert_message").html("Are you sure you want to Close IWD Quest?");}
						
			$("#alert_ok").hide();
			$("#alert_shutdown").hide();
			$("#alert_yesno").show();	
			$(".droidalert").fadeIn("fast");
			}

	$("#yes").click(function (){
		$(".droidalert").fadeOut("fast", function (){
							if ($('#myIframe').is(':visible')){
								
								$('#myIframe').delay(500).fadeOut("500", function(){
									$('#myIframe').remove();
									$("#prog_os").show()
									$(".browsertools").hide();
									$(".close_page").hide();
									})
									
							}
		});
	});
	







});
(function ($) {
    var rotateUnits = 'deg';
    
    $.fn.rotate = function (val)
    {
        var style = $(this).css('transform') || 'none';
        
        if (typeof val == 'undefined')
        {
            if (style)
            {
                var m = style.match(/rotate\(([^)]+)\)/);
                if (m && m[1])
                {
                    return m[1];
                }
            }
            
            return 0;
        }
        
        var m = val.toString().match(/^(-?\d+(\.\d+)?)(.+)?$/);
        if (m)
        {
            if (m[3])
            {
                rotateUnits = m[3];
            }
            
            $(this).css(
                'transform',
                style.replace(/none|rotate\([^)]*\)/, '') + 'rotate(' + m[1] + rotateUnits + ')'
            );
        }
        
        return this;
    }
    
    // Note that scale is unitless.
    $.fn.scale = function (val, duration, options)
    {
        var style = $(this).css('transform');
        
        if (typeof val == 'undefined')
        {
            if (style)
            {
                var m = style.match(/scale\(([^)]+)\)/);
                if (m && m[1])
                {
                    return m[1];
                }
            }
            
            return 1;
        }
        
        $(this).css(
            'transform',
            style.replace(/none|scale\([^)]*\)/, '') + 'scale(' + val + ')'
        );
        
        return this;
    }

    // fx.cur() must be monkey patched because otherwise it would always
    // return 0 for current rotate and scale values
    var curProxied = $.fx.prototype.cur;
    $.fx.prototype.cur = function ()
    {
        if (this.prop == 'rotate')
        {
            return parseFloat($(this.elem).rotate());
        }
        else if (this.prop == 'scale')
        {
            return parseFloat($(this.elem).scale());
        }
        
        return curProxied.apply(this, arguments);
    }
    
    $.fx.step.rotate = function (fx)
    {
        $(fx.elem).rotate(fx.now + rotateUnits);
    }
    
    $.fx.step.scale = function (fx)
    {
        $(fx.elem).scale(fx.now);
    }
    
    
    var animateProxied = $.fn.animate;
    $.fn.animate = function (prop)
    {
        if (typeof prop['rotate'] != 'undefined')
        {
            var m = prop['rotate'].toString().match(/^(([+-]=)?(-?\d+(\.\d+)?))(.+)?$/);
            if (m && m[5])
            {
                rotateUnits = m[5];
            }
            
            prop['rotate'] = m[1];
        }
        
        return animateProxied.apply(this, arguments);
    }
})(jQuery);

(function ($) {
    // Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform'
    // property uniformly across Safari/Chrome/Webkit, Firefox 3.5+, IE 9+, and Opera 11+.
    // 2009-2011 Zachary Johnson www.zachstronaut.com
    // Updated 2011.05.04 (May the fourth be with you!)
    function getTransformProperty(element)
    {
        // Try transform first for forward compatibility
        // In some versions of IE9, it is critical for msTransform to be in
        // this list before MozTranform.
        var properties = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform'];
        var p;
        while (p = properties.shift())
        {
            if (typeof element.style[p] != 'undefined')
            {
                return p;
            }
        }
        
        // Default to transform also
        return 'transform';
    }
    
    var _propsObj = null;
    
    var proxied = $.fn.css;
    $.fn.css = function (arg, val)
    {
        // Temporary solution for current 1.6.x incompatibility, while
        // preserving 1.3.x compatibility, until I can rewrite using CSS Hooks
        if (_propsObj === null)
        {
            if (typeof $.cssProps != 'undefined')
            {
                _propsObj = $.cssProps;
            }
            else if (typeof $.props != 'undefined')
            {
                _propsObj = $.props;
            }
            else
            {
                _propsObj = {}
            }
        }
        
        // Find the correct browser specific property and setup the mapping using
        // $.props which is used internally by jQuery.attr() when setting CSS
        // properties via either the css(name, value) or css(properties) method.
        // The problem with doing this once outside of css() method is that you
        // need a DOM node to find the right CSS property, and there is some risk
        // that somebody would call the css() method before body has loaded or any
        // DOM-is-ready events have fired.
        if
        (
            typeof _propsObj['transform'] == 'undefined'
            &&
            (
                arg == 'transform'
                ||
                (
                    typeof arg == 'object'
                    && typeof arg['transform'] != 'undefined'
                )
            )
        )
        {
            _propsObj['transform'] = getTransformProperty(this.get(0));
        }
        
        // We force the property mapping here because jQuery.attr() does
        // property mapping with jQuery.props when setting a CSS property,
        // but curCSS() does *not* do property mapping when *getting* a
        // CSS property.  (It probably should since it manually does it
        // for 'float' now anyway... but that'd require more testing.)
        //
        // But, only do the forced mapping if the correct CSS property
        // is not 'transform' and is something else.
        if (_propsObj['transform'] != 'transform')
        {
            // Call in form of css('transform' ...)
            if (arg == 'transform')
            {
                arg = _propsObj['transform'];
                
                // User wants to GET the transform CSS, and in jQuery 1.4.3
                // calls to css() for transforms return a matrix rather than
                // the actual string specified by the user... avoid that
                // behavior and return the string by calling jQuery.style()
                // directly
                if (typeof val == 'undefined' && jQuery.style)
                {
                    return jQuery.style(this.get(0), arg);
                }
            }

            // Call in form of css({'transform': ...})
            else if
            (
                typeof arg == 'object'
                && typeof arg['transform'] != 'undefined'
            )
            {
                arg[_propsObj['transform']] = arg['transform'];
                delete arg['transform'];
            }
        }
        
        return proxied.apply(this, arguments);
    };
})(jQuery);

function simple_tooltip(target_items, name){
 $(target_items).each(function(i){
		$("body").append('<div class="'+name+'wrapper" id="'+name+i+'"><div class="'+name+'body"><p>'+$(this).attr('title')+'</p></div><div class="'+name+'arrow"></div>');		

		var my_tooltip = $("#"+name+i);
		
		
		
		if($(this).attr("title") != "" && $(this).attr("title") != "undefined" ){
		
		$(this).removeAttr("title").mouseover(function(){
					my_tooltip.css({opacity:0.8, display:"none"}).fadeIn(400);
		}).mousemove(function(kmouse){
				var border_top = $(window).scrollTop(); 
				var border_right = $(window).width();
				var left_pos;
				var top_pos;
				var offset = 20;
				if(border_right - (offset *2) >= my_tooltip.width() + kmouse.pageX){
					left_pos = kmouse.pageX+offset;
					} else{
					left_pos = border_right-my_tooltip.width()-offset;
					}
					
				if(border_top + (offset *2)>= kmouse.pageY - my_tooltip.height()){
					top_pos = border_top +offset;
					} else{
					top_pos = kmouse.pageY-my_tooltip.height()-offset;
					}	
				
				
				my_tooltip.css({left:left_pos, top:top_pos});
		}).mouseout(function(){
				my_tooltip.css({left:"-9999px"});				  
		});
		
		}
		
	});
}

	
	
$(document).ready(function(){
	 simple_tooltip(".prog_icon","tt");
});



// JavaScript Document

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



