///////////////////////////////////////////////////////////////////////////////////////////////////

/*IE 6 hover plagin by R.Kesheshyan r_kesha@mail.ru*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 u=k(){9 g=/^([^#.>`]*)(#|\\.|\\>|\\`)(.+)$/;k u(a,b){9 c=a.J(/\\s*\\,\\s*/);9 d=[];n(9 i=0;i<c.l;i++){d=d.v(o(c[i],b))};6 d};k o(a,b,c){a=a.z(" ","`");9 d=a.r(g);9 e,5,m,7,i,h;9 f=[];4(d==8){d=[a,a]};4(d[1]==""){d[1]="*"};4(c==8){c="`"};4(b==8){b=E};K(d[2]){w"#":7=d[3].r(g);4(7==8){7=[8,d[3]]};e=E.L(7[1]);4(e==8||(d[1]!="*"&&!x(e,d[1]))){6 f};4(7.l==2){f.A(e);6 f};6 o(7[3],e,7[2]);w".":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};7=d[3].r(g);4(7!=8){4(e.j==8||e.j.r("(\\\\s|^)"+7[1]+"(\\\\s|$)")==8){q};m=o(7[3],e,7[2]);f=f.v(m)}y 4(e.j!=8&&e.j.r("(\\\\s|^)"+d[3]+"(\\\\s|$)")!=8){f.A(e)}};6 f;w">":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};m=o(d[3],e,">");f=f.v(m)};6 f;w"`":5=p(b,d[1]);n(i=0,h=5.l;i<h;i++){e=5[i];m=o(d[3],e,"`");f=f.v(m)};6 f;M:4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};f.A(e)};6 f}};k p(a,b){4(b=="*"&&a.F!=8){6 a.F};6 a.p(b)};k x(a,b){4(b=="*"){6 N};6 a.O.G().z("P:","")==b.G()};6 u}();k Q(a,b){9 c=u(a);n(9 i=0;i<c.l;i++){c[i].R=k(){4(t.j.H(b)==-1){t.j+=" "+b}};c[i].S=k(){4(t.j.H(b)!=-1){t.j=t.j.z(b,"")}}}}4(D.I&&!D.T){D.I("U",V)}',58,58,'||||if|listNodes|return|subselector|null|var||||||||limit||className|function|length|listSubNodes|for|doParse|getElementsByTagName|continue|match||this|parseSelector|concat|case|matchNodeNames|else|replace|push|childNodes|nodeType|window|document|all|toLowerCase|indexOf|attachEvent|split|switch|getElementById|default|true|nodeName|html|hoverForIE6|onmouseover|onmouseout|opera|onload|ieHover'.split('|'),0,{}))
/*parametrs [selector, hover_class]*/
function ieHover() {
	hoverForIE6(".nav li", "hover");
}

///////////////////////////////////////////////////////////////////////////////////////////////////

//clears the default text from input fields
function clearInputs(){
	$('#header input:text, #header input:password, #header textarea').each(function(){
		if(!this.val) this.val = this.value;
		this.onfocus = function(){
			if(this.value == this.val) this.value = '';
		}
		this.onblur = function(){
			if(this.value == '') this.value = this.val;
		}
	});
}
if (window.addEventListener)
	window.addEventListener("load", clearInputs, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", clearInputs);

///////////////////////////////////////////////////////////////////////////////////////////////////

//Google Analytics tracking
function trackPage() {
	try {
		//add the account number
		var pageTracker = _gat._getTracker("UA-3483523-3");
		pageTracker._trackPageview();
	} catch(err) {}
}

///////////////////////////////////////////////////////////////////////////////////////////////////

//File Uplaod
function upload() {
	$("#uploadify").uploadify({
		'uploader'       : '/template_files/uploadify/uploadify.swf',
		'script'         : '/template_files/uploadify/uploadify.php',
		'cancelImg'      : '/template_files/uploadify/cancel.png',
		'buttonImg'      : '/template_files/images/btn_browse_files.jpg',
		'width'   		 : '149',
		'height'		 : '42',
		'folder'         : '/uploads',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'multi'          : false,
		'onComplete': function(e, q, f, r, d) {
			$("#freeform").submit();
        }
	});	
}

///////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function() {
	//track the page with Google Analytics
	trackPage();
		
	$("a.zoom").fancybox({
			'zoomOpacity': true,
			'overlayShow': false,
			'zoomSpeedIn': 300,
			'zoomSpeedOut': 300,
			'frameWidth': 300,
			'frameHeight': 250
		});
		
	$("a.newsletter-btn").fancybox({
			'hideOnContentClick': false,
			'zoomOpacity': true,
			'overlayShow': false,
			'zoomSpeedIn': 150,
			'zoomSpeedOut': 150,
			'frameWidth': 508,
			'frameHeight': 434
		});
		
	$("a.comparison-zoom").fancybox({
			'hideOnContentClick': false,
			'zoomOpacity': true,
			'overlayShow': false,
			'zoomSpeedIn': 150,
			'zoomSpeedOut': 150,
			'frameWidth': 660,
			'frameHeight': 510
		});
		
	//quick-quote tabs	
	if ( $("#design-tabs").length > 0 ) {
		$("#design-tabs").tabs({ selected: 0});
	}
	
	//quick-quote tabs	
	if ( $("#quick-quote").length > 0 ) {
		$("#quick-quote").tabs({ selected: 0});
	}
	//quote form tabs
	if ( $("#quote-forms").length > 0 ) {
		$("#quote-forms").tabs({ selected: 0});
	}
	//template tabs
	if ( $("#template-tabs").length > 0 ) {
		//$("#template-tabs").tabs({ selected: 0});
		$tplTabs = $("#template-tabs").tabs({ 
		    // set url hash on tab click 
		    select: function(event, ui){ 
			   document.location.hash = $(ui.panel).attr("id"); 
		    } 
	    });
		// set the selected tab based on the current hash
		$tplTabs.tabs('select', document.location.hash);
	}
	
	//replications tabs
	if ( $("#products").length > 0 ) {
		$tabs = $("#products").tabs({ 
		    // set url hash on tab click 
		    select: function(event, ui){ 
			   document.location.hash = $(ui.panel).attr("id"); 
		    } 
	    });
		// set the selected tab based on the current hash
		$tabs.tabs('select', document.location.hash); 
	}
	
	//home page slideshow
	if ( $("#home-images").length > 0 ) {
		if($.browser.msie == false) {
			$('#home-images').cycle({ 
			    fx:    'fade', 
			    speed:  1000,
				timeout: 5000, 
				pause: 0,
				random: 1
			 });
		}else{
			$('#home-images').cycle({ 
			    fx:    'fade', 
			    speed:  0,
				timeout: 5000, 
				pause: 0,
				random: 1
			 });	
		}
	}
	
	//file upload
	if ( $("#upload-art").length > 0 ) {
		upload();
	}
	
	
	//home page client raves
	if ( $("#rave-ticker").length > 0 ) {
		$('#rave-ticker').cycle({ 
		    speed:  0,
			timeout: 10000, 
			pause: 0,
			random: 1
		 });
	}
	
	//sidebar send to a friend
	if ( $(".send-to-friend-start a").length > 0 ) {
		$(".send-to-friend-start a").click(function() {
			$(".send-to-friend-start").hide();
			$("div.send-to-friend").show();
			return false;
		});
	}
	
	
		
});

///////////////////////////////////////////////////////////////////////////////////////////////////