
function showExtWindow(myURL, myTitle){
    win = new Window({
        className: "magento",
        title: myTitle,
        width: 700,
        height: 450,
        destroyOnClose: true,
        recenterAuto: true,
        showEffect: Effect.BlindDown,
        hideEffect: Effect.BlindUp
    });
    win.setURL(myURL);
    win.setZIndex(5200);
    win.showCenter();
}

function showExtWindowSize(myURL, myTitle, myWidth, myHeight){
    win = new Window({
        className: "magento",
        title: myTitle,
        width: myWidth,
        height: myHeight,
        destroyOnClose: true,
        recenterAuto: true,
        showEffect: Effect.BlindDown,
        hideEffect: Effect.BlindUp
    });
    win.setURL(myURL);
    win.setZIndex(5200);
    win.showCenter();
}

function setZoomPic(myPic,myZoomPic){
	jQuery("#d1").attr("href",myZoomPic);	
	myImTag = document.getElementById("image");
	myImTag.src = myPic;
	jQuery("#pic").slideDown("slow");
	jQuery("#videoplayer").height(1);
}

function load_content(target, url, data, callback){
     target.load(url, data, function(){
		/*if (!jQuery('#testimonials a.more').lenght) {
			jQuery('#testimonials').prepend('<a class="more" href="/cms/inside-igigi/testimonials">View More ></a>');
		}*/

		jQuery('#testimonials').find('p').hide();
		jQuery('#testimonials').find('span.author').hide();
		jQuery('#testimonials p:first').fadeIn(1000).css('display','inline');
		jQuery('#testimonials span.author').fadeIn(1000).css('display','inline');

		var txt = jQuery('#testimonials p').text(),
		crop = '"' + txt.slice(0, 100) + '... "';

		jQuery('#testimonials p').text(crop);

	});
}

jQuery(document).ready(function(){
    jQuery("#d1").magnify({
        lensWidth: 160,
        lensHeight: 160,
        preload: false,
        showEvent: 'click',
        stageCss: {
            width: '340px',
            height: '459px'
        }
    });   
		 
    jQuery(".product-image").mouseover(function(){
        jQuery(this).children(".products-grid-image2").fadeIn("slow");
    });
    jQuery(".products-grid-image2").mouseout(function(){
        jQuery(this).fadeOut("slow");
    });
    
    load_content(jQuery('#testimonials'), '/cms/testimonials_generate');
	var timer = window.setInterval(function()
    {
    	load_content(jQuery('#testimonials'), '/cms/testimonials_generate');
    }, 10000);

	if (navigator.appName == "Microsoft Internet Explorer") {
		ieCSSactionFix();
		CSSHover();
	}
});


/*** email link crypt **/
function UnCryptMailto(s) {
	var n = 0;
	var r = "";
	for( var i = 0; i < s.length; i++){
		n = s.charCodeAt( i );
		if( n >= 8364 )
		{
			n = 128;
		}
		r += String.fromCharCode( n - 1 );
	}
	return r;
}

function linkTo_UnCryptMailto(s){
	location.href=UnCryptMailto(s);
}



/*==================================================================================================================*\
	IE6/7 :HOVER, :ACTIVE, :FOCUS SUPPORT
\*==================================================================================================================*/
function ieCSSactionFix() {
	window.CSSHover = (function () {
		var f				= /(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i,
			REG_AFFECTED	= /(.*?)\:(hover|active|focus)/i,
			REG_PSEUDO		= /[^:]+:([a-z-]+).*/i,
			REG_SELECT		= /(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi,
			REG_CLASS		= /\.([a-z0-9_-]*on(hover|active|focus))/i,
			REG_MSIE		= /msie (5|6|7)/i,
			REG_COMPAT		= /backcompat/i,
			g				= 'csh-',
			h				= {
				elements	: [],
				callbacks	: {},
				init		: function () {
					if (!REG_MSIE.test(navigator.userAgent) && !REG_COMPAT.test(window.document.compatMode)) {
						return;
					}
					var a = window.document.styleSheets,
						l = a.length;
					for (var i = 0; i < l; i++) {
						this.parseStylesheet(a[i]);
					}
			},
			parseStylesheet: function (a) {
				if (a.imports) {
					try{
						var b = a.imports,
							l = b.length;
						for (var i = 0; i < l; i++) {
							this.parseStylesheet(a.imports[i]);
						}
					}
					catch (securityException) {
					}
				}
				try{
					var c = a.rules,
						l = c.length;
					for (var j = 0; j < l; j++) {
						this.parseCSSRule(c[j], a);
					}
				}
				catch (securityException) {
				}
			},
			parseCSSRule: function (a, b) {
				var c = a.selectorText;
				if (f.test(c)) {
					var d			= a.style.cssText,
						affected	= REG_AFFECTED.exec(c)[1],
						pseudo		= c.replace(REG_PSEUDO, 'on$1'),
						newSelect	= c.replace(REG_SELECT, '.$2' + pseudo),
						className	= REG_CLASS.exec(newSelect)[1],
						e			= affected + className;
					if (!this.callbacks[e]) {
						b.addRule(affected, g + className + ':expression(CSSHover(this, "' + pseudo + '", "' + className + '"))');
						this.callbacks[e] = true;
					}
					b.addRule(newSelect, d);
				}
			},
			patch: function (a, b, c) {
				var d = g + c;
				if (a.style[d]) {
					a.style[d] = null;
				}
				if (!a.csshover) {
					a.csshover = [];
				}
				if (!a.csshover[c]) {
					a.csshover[c] = true;
					var e = new CSSHoverElement(a, b, c);
					this.elements.push(e);
				}
				return b;
			},
			unload: function () {
				try {
					var l = this.elements.length;
					for (var i = 0; i < l; i++) {
						this.elements[i].unload();
					}
					this.elements = [];
					this.callbacks = {};
				}
				catch (e) {
				}
			}
		};
		window.attachEvent('onbeforeunload', function () {
			h.unload();
		});
		var k = {
			onhover: {
				activator	: 'onmouseenter',
				deactivator	: 'onmouseleave'
			},
			onactive: {
				activator	: 'onmousedown',
				deactivator	: 'onmouseup'
			},
			onfocus: {
				activator	: 'onfocus',
				deactivator	: 'onblur'
			}
		};
		function CSSHoverElement(a, b, c) {
			this.node = a;
			this.type = b;
			var d = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g');
			this.activator = function () {
				a.className += ' ' + c;
			};
			this.deactivator = function () {
				a.className = a.className.replace(d, ' ');
			};
			a.attachEvent(k[b].activator, this.activator);
			a.attachEvent(k[b].deactivator, this.deactivator);
		}
		CSSHoverElement.prototype = {
			unload: function () {
				this.node.detachEvent(k[this.type].activator, this.activator);
				this.node.detachEvent(k[this.type].deactivator, this.deactivator);
				this.activator		= null;
				this.deactivator	= null;
				this.node			= null;
				this.type			= null;
			}
		};
		return function (a, b, c) {
			if (a) {
				return h.patch(a, b, c);
			}
			else {
				h.init();
			}
		}
	})();
}

function showvideo() {
	
	var video_mode = document.getElementById('video_mode').value;
	if (video_mode == 0) {
		document.getElementById('video_mode').value = '1';
		
		document.getElementById('product-video').style.display='';
	
		document.getElementById('product-shop').style.display='none';
		document.getElementById('productservice').style.display='none';			
	} else {
		document.getElementById('video_mode').value = '0';
		hidevideo();
	}
	
	
}

function hidevideo() {	
	document.getElementById('product-shop').style.display='';
	document.getElementById('productservice').style.display='';
	
	document.getElementById('product-video').style.display='none';		
}
