/**
 * RokVM - VirtueMart Class for handling RocketTheme templates
 * Djamil Legato - (c) RocketTheme, LLC
 * 
 */

var RokVM = {};
RokVM.autoHide = 3; // seconds before auto closing the Panel


eval(function(p,a,c,k,e,d){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--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[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}('2.z={1w:8.1B,1i:6(){2.z.1q();2.3.1h()},1d:6(F){F=$(F);4(!F){v 2.z}7 Y=F.1O(".13-R-1H");7 C=0;Y.U(6(I){C=1R.C(I.1N().1M.y,C)});Y.1e("1K",C)},1q:6(){7 10=$$(".l-1y-B, .13-R-1D");4(10.p){10.U(6(B){7 L=B.f(".1J");7 M=B.f(".1C");7 b=B.f(".1S");4(!L||!M||!b){v}7 1Q=b.g().d();b.i("1I",6(e){e=(c u(e)).x();7 5=9.5;4(5<0){5=0}4(1o(5)){9.5=1;5=1}4(e.1r=="L"){4($o(9.g().d())=="w"){9.5=++5}}4(e.1r=="M"){4(5>0&&$o(9.g().d())=="w"){9.5=--5}}});b.i("1L",6(e){e=(c u(e)).x();7 5=9.5;4(5<0){5=0}4(1o(5)){9.5=1;5=1}4(e.1j==1){4($o(9.g().d())=="w"){9.5=++5}}4(e.1j==-1){4(5>0&&$o(9.g().d())=="w"){9.5=--5}}});L.i("Q",6(e){(c u(e)).x();4($o(b.g().d())=="w"){b.5=++b.5}});M.i("Q",6(e){(c u(e)).x();4(b.g().d()>0&&$o(b.g().d())=="w"){b.5=--b.5}})})}}};2.3={1h:6(){2.3.j=$("l-D");2.3.k=$("l-K");2.3.P=$("l-D-1P");4(!2.3.j||!2.3.k||!2.3.P){v 2.3}4(!2.3.h){2.3.h=(c(h.1z)(2.3.j,{1A:1G,1E:h.1F.1x.2c})).Z()}2.3.P.1e("2j","2k");2.3.k.X("a").i("Q",6(e){(c u(e)).x();4(!2.3.j.O().p){v}7 m=2.3.k.f("18");4(!m||!m.O().d()&&!2.3.j.O().p){v}2.3.A=H;4(8.s&&8.s.N){8.s.E()}4(8.q&&8.q.N){8.q.E()}2.3.h.E()});2.15=c(h.2i)(8);2.3.S();2.3.1g()},1g:6(){7 V=$$(".2h");4(!V.p){v 2.3}V.U(6(T){T.i("2e",2.3.1c.2f(T,H))})},1c:6(e,A){(c u(e)).x();(c 1v(9.2g("2m"),{1k:$(9),16:H,1b:6(r){7 J=c 1n(\'I\').W(r);7 1a=J.f(\'.1p\');2.3.S((r.p&&1a)?r:14);2.3.A=A||14}})).1s()},S:6(t){7 1m={1b:6(n){2.3.1u(n,t)},16:H,1k:{2o:1,2r:"2n.2p",1T:"2q"}};(c 1v(2.z.1w+"2l.2d",1m)).1s()},19:6(n){7 D=2.3.j;7 J=c 1n(\'I\').W(n);7 G=D.f(\'.11-l-K\');7 1Z=J.f(\'.1p\').20((G)?G:D,(G)?\'21\':\'1Y\')},1u:6(n,t){2.3.j.W(n);7 12=2.3.j.f(".1X"),m=0;4(12){m=12.1U.1V(" ")[0].d()}4(!m){2.3.k.X().1l("1t","l-K-17")}1W{2.3.k.X().1l("1t","l-K-17-22")}2.3.k.f("18").23(m);4(t)2.3.19(t);4(2.3.A&&n.p||t){4(8.s&&8.s.N){8.s.E()}4(8.q&&8.q.N){8.q.E()}2.15.29();2.3.11();2.3.Z.2a(2.2b*28)}2.3.A=14},11:6(){2.3.h.27()},Z:6(){2.3.h.24()}};8.i("1f",2.z.1i);8.i(8.25?"26":"1f",6(){2.z.1d("13-R")});',62,152,'||RokVM|Cart|if|value|function|var|window|this||input|new|toInt||getElement|getValue|Fx|addEvent|cartPanel|cartButton|cart|total|response|type|length|loginFx||fontFx|error|Event|return|number|stop||Base|clicked|box|max|panel|toggle|id|panelPos|true|div|trash|button|up|down|open|getText|cartSurround|click|featured|getShortList|form|each|forms|setHTML|getFirst|divs|hide|boxes|show|products|home|false|scrollWindow|evalScripts|desc|strong|handleError|tip|onComplete|add|featuredHeight|setStyle|domready|XHRify|init|start|wheel|data|setProperty|options|Element|isNaN|shop_tip|quantityBox|key|request|class|update|Ajax|uri|Expo|quantity|Slide|duration|templatePath|quantity_box_button_down|cartblock|transition|Transitions|400|inner|keyup|quantity_box_button_up|height|mousewheel|size|getSize|getElements|surround|val|Math|inputboxquantity|option|innerHTML|split|else|total_products|inside|info|inject|before|full|setText|slideOut|webkit|load|slideIn|1000|toTop|delay|autoHide|easeOut|php|submit|bindWithEvent|getProperty|addtocart_form|Scroll|visibility|visible|index2|action|shop|only_page|basket_short|com_virtuemart|page'.split('|'),0,{}))




var live_site = RokVM.Base.uri;


/// Following is VM stuff, kept for compatibility


/**
 * This file holds javscript functions that are used by the templates in the Theme
 * 
 */
 
 // AJAX FUNCTIONS 
function loadNewPage( el, url ) {
	
	var theEl = $(el);
	var callback = {
		success : function(responseText) {
			theEl.innerHTML = responseText;
			if( Lightbox ) Lightbox.init();
		}
	}
	var opt = {
	    // Use POST
	    method: 'get',
	    // Handle successful response
	    onComplete: callback.success
    }
	new Ajax( url + '&only_page=1', opt ).request();
}

function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value ; }

function handleAddToCart( formId, parameters ) {
	formCartAdd = document.getElementById( formId );
	
	var callback = function(responseText) {
		updateMiniCarts();
		// close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!)
		/*if (document.boxB) {
			document.boxB.close();
			clearTimeout(timeoutID);
		}

		document.boxB = new MooPrompt(notice_lbl, responseText, {
				buttons: 2,
				width:400,
				height:150,
				overlay: false,
				button1: ok_lbl,
				button2: cart_title,
				onButton2: 	handleGoToCart
			});
			
		setTimeout( 'document.boxB.close()', 3000 );*/
	}
	
	var opt = {
	    // Use POST
	    method: 'post',
	    // Send this lovely data
	    data: $(formId),
	    // Handle successful response
	    onComplete: callback,
	    
	    evalScripts: true
	}

	new Ajax(formCartAdd.action, opt).request();
}
/**
* This function searches for all elements with the class name "vmCartModule" and
* updates them with the contents of the page "shop.basket_short" after a cart modification event
*/
function updateMiniCarts() {
	var callbackCart = function(responseText) {
		carts = $$( '.vmCartModule' );
		if( carts ) {
			try { 
				for (var i=0; i<carts.length; i++){
					carts[i].innerHTML = responseText;
		
					try {
					color = carts[i].getStyle( 'color' );
					bgcolor = carts[i].getStyle( 'background-color' );
					if( bgcolor == 'transparent' ) {
						// If the current element has no background color, it is transparent.
						// We can't make a highlight without knowing about the real background color,
						// so let's loop up to the next parent that has a BG Color
						parent = carts[i].getParent();
						while( parent && bgcolor == 'transparent' ) {
							bgcolor = parent.getStyle( 'background-color' );
							parent = parent.getParent();
						}
					}
					var fxc = new Fx.Style(carts[i], 'color', {duration: 1000});
					var fxbgc = new Fx.Style(carts[i], 'background-color', {duration: 1000});

					fxc.start( '#222', color );							
					fxbgc.start( '#fff68f', bgcolor );
					
					
					
					if( parent ) {
						setTimeout( "carts[" + i + "].setStyle( 'background-color', 'transparent' )", 1000 );
					}
					} catch(e) {}
				}
			} catch(e) {}
		}
	}
	var option = { method: 'post', onComplete: callbackCart, data: { only_page:1,page: "shop.basket_short", option: "com_virtuemart" } }
	new Ajax( live_site + '/index2.php', option).request();
}
/**
* This function allows you to present contents of a URL in a really nice stylish dhtml Window
* It uses the WindowJS, so make sure you have called
* vmCommonHTML::loadWindowsJS();
* before
*/
function fancyPop( url, parameters ) {
	
	parameters = parameters || {};
	popTitle = parameters.title || '';
	popWidth = parameters.width || 700;
	popHeight = parameters.height || 600;
	popModal = parameters.modal || false;
	
	window_id = new Window('window_id', {className: "mac_os_x", 
										title: popTitle,
										showEffect: Element.show,
										hideEffect: Element.hide,
										width: popWidth, height: popHeight}); 
	window_id.setAjaxContent( url, {evalScripts:true}, true, popModal );
	window_id.setCookie('window_size');
	window_id.setDestroyOnClose();
}