﻿// BG
var nr=-1;
var lastnr=-1;
function bg() { 
	do { 
	nr = Math.round(Math.random()*3+1); 
	document.getElementById('body').style.backgroundImage = 'url(img/tapete'+nr+'.gif)'; 
	} while(nr==lastnr); lastnr=nr; 
}

// paragraph bgnr maker
var pnr=-1;
var plastnr=-1;
function pbg() { 
	do { 
		pnr = Math.round(Math.random()*20+1); 
	} while(pnr==plastnr); 
	plastnr=pnr;
	return pnr>9 ? pnr : ('0'+pnr);
}

// SWFobject
if(window.location.href.indexOf('fullflash') > -1 && swfobject.hasFlashPlayerVersion("9.0.0"))
{
	var vars = {};
	var params = { scale:'noScale', salign:'lt', menu:'false' };
	var attributes = { id:'testObject', name:'testObject' }; // give an id to the flash object
	swfobject.embedSWF("load23.swf", "site", "100%", "100%", "9.0.0", "js/expressInstall.swf", vars, params, attributes );
	if(swfmacmousewheel)
	{
	swfmacmousewheel.activate();
	swfmacmousewheel.registerObject(attributes.id);
	}
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("#site", "height:100%;");
	swfobject.createCSS("#flashversion", "display:none;");
	swfobject.createCSS("body", "margin:0; padding:0; overflow:hidden; height:100%;");
}
else
{
	
}


function fullflash()
{
	if( ! swfobject.hasFlashPlayerVersion("9.0.0") )
	{
		if(	confirm("Flashplayer 9 is required, would you like to download it?") )
		{
			window.open("http://www.adobe.com/go/getflashplayer", "getflash");
		}
	}
	else
	{
		window.open("/?fullflash", "_self");
	}
}


function previewHandler()
{
	$('.handle').hoverIntent(showPreview, hidePreview);
	
	$('body').mousemove(function(e){
		$('#preview').css('top', (e.clientY-100) +'px');
    });


	/*
	$(".carousel").each(function() {
    	$(this).simplecarousel({
			slidespeed: 700,auto: 5000,width: 400,height: 260
    	});
	});
	*/
}

var skipHide = false;

function showPreview()
{  
	if (Modernizr.touch){
		$(this).parent().find('.preview').slideDown("slow");
		$(this).parent().find('.carousel').simplecarousel({
			slidespeed: 400,auto: 3000,width: 430,height: 260
    	});
	}
	else
	{
		skipHide = true;
		var x = 520;
		$('#preview').css('display','block');
		$('#preview').animate( {'right': x}, 400);
		$('#preview').empty();
		$('#preview').append( $(this).parent().find('.preview').clone() );
		$('#preview .preview').show();
		$('#preview .preview ul').simplecarousel({
			slidespeed: 400,auto: 3000,width: 400,height: 290, vertical: true
	    });
	
		if( $(this).find(':first-child').is('form')==false )
		{
			$(this).parent().find('.between').animate( {'width':496}, 200);
			$(this).parent().find('p').animate( {'paddingRight':108}, 200);
			$(this).parent().find('p').css({backgroundImage:'url(./img/signs/sign_'+pbg()+'.gif)'});
		}
	}
}
function hidePreview()
{ 
	if (Modernizr.touch){
		$(this).parent().find('.preview').slideUp("fast");
	}
	else
	{	
		skipHide = false;
		var x = $(window).width();
		$('#preview').animate( {'right':x}, 400, noPreview );
		
		$(this).parent().find('.between').animate( {'width':396}, 200);
		$(this).parent().find('p').animate( {'paddingRight':8}, 200);
	}
}

function noPreview()
{ 
	if(!skipHide)
		$('#preview').css('display','none'); 
}


$(document).ready(previewHandler);


/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Contains: touch | teststyles | prefixes
 */
;window.Modernizr=function(a,b,c){function y(a,b){return!!~(""+a).indexOf(b)}function x(a,b){return typeof a===b}function w(a,b){return v(m.join(a+";")+(b||""))}function v(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k,l=Object.prototype.toString,m=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),n={},o={},p={},q=[],r=function(a,c,d,e){var g,i,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);g=["&shy;","<style>",a,"</style>"].join(""),k.id=h,k.innerHTML+=g,f.appendChild(k),i=c(k,a),k.parentNode.removeChild(k);return!!i},s,t={}.hasOwnProperty,u;!x(t,c)&&!x(t.call,c)?u=function(a,b){return t.call(a,b)}:u=function(a,b){return b in a&&x(a.constructor.prototype[b],c)};var z=function(c,d){var f=c.join(""),g=d.length;r(f,function(c,d){var f=b.styleSheets[b.styleSheets.length-1],h=f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"",i=c.childNodes,j={};while(g--)j[i[g].id]=i[g];e.touch="ontouchstart"in a||j.touch.offsetTop===9},g,d)}([,["@media (",m.join("touch-enabled),("),h,")","{#touch{top:9px;position:absolute}}"].join("")],[,"touch"]);n.touch=function(){return e.touch};for(var A in n)u(n,A)&&(s=A.toLowerCase(),e[s]=n[A](),q.push((e[s]?"":"no-")+s));v(""),i=k=null,e._version=d,e._prefixes=m,e.testStyles=r;return e}(this,this.document);


