jQuery.noConflict();

jQuery(document).ready(function(){
	var productImagesList = jQuery(".product_images")

	//jQuery.each(productImagesList, function() {
		//addImagePager(this);
	//});
	
	//jQuery(".product_image").click(function(e) {
		//this.t = this.title;
		//this.title = "";
		//var c = (this.t != "") ? "<br/>" + this.t : "";

		//imageStringParts = this.src.split('&');
		//largeImageString = imageStringParts[0] + "&aid=" + jQuery(this).attr("value") + "&" + imageStringParts[2];
		
		//var largeImage = new Image();
		//largeImage.src = largeImageString;
		
		//jQuery('#product_preview_image img').hide()
		//.attr('src', '');
		
		//jQuery('#product_preview_image').append('<div id="preload" style="width: 200px; height: 100px; background: url(/images/loader.gif) no-repeat center center;"></div>')
		//.css('left', '50%')
		//.css('margin-left', '-100px')
		//.css('top', '200px')
		//.css('border', '2px solid red')
		//.show();
		
		
		//jQuery(largeImage)
			//.load(function() {
				////jQuery(this).hide();
				//jQuery("#product_preview_image").show();
			
				////alert("image loaded... " + this.width + "px breit");
				//jQuery("#product_preview_image img")[0].src = this.src;
				////largeImage = jQuery("#product_preview_image img")[0];
		
				//var width = 0;
				//if(navigator.appName.indexOf("Internet Explorer") != -1)
				//{
					//width = parseInt(document.body.clientWidth/2) - parseInt(this.width/2)
				//}
				//else
				//{
					//width = parseInt(window.innerWidth/2) - parseInt(this.width/2)
				//}
				
					
				//jQuery("#product_preview_image")
				//.css("top","50px")
				//.css("left", width.toString() + "px")
				//.css('margin-left', 'auto')
				//.css('border', 'none');
				
				//jQuery('#preload').remove();
				
				//jQuery("#product_preview_image img").fadeIn(1000)
				//.css("height", this.height);
				
				//jQuery('body').mousedown(function () {
					//jQuery("#product_preview_image").fadeOut("fast");
					//jQuery('body').unbind('click');
				//});
			//});
		
		//// src vom image nochmals zuweisen, wegen eines Bugs im IE (.load() event wird sonst nur das erste Mal aufgerufen)	
		//largeImage.src = largeImageString;
	//});
	
	// auf alle input felder hover hinzufügen für IE
	//if(navigator.appName.indexOf("Internet Explorer") != -1)
	//{
		//jQuery('form input.formValue, select.formValue, textarea.formValue').focus(function() {
			//jQuery(this).css('background-color', '#ffc4c4');
		//});
		
		//jQuery('form input.formValue, select.formValue, textarea.formValue').blur(function() {
			//jQuery(this).css('background-color', '');
		//});
	//}
})

var imagePageCounter = 0;
var className = "product_images_";
function addImagePager(productImages)
{
	//productImages.class = className + imagePageCounter;
	//jqProductImages = jQuery("." + productImages.class).before("<div class=\"" + productImages.class + "_nav\"/>")
	if(jQuery("#" + productImages.id + " img").size() > 1)
	{
		jqProductImages = jQuery("#" + productImages.id).before("<div id=\"" + productImages.id + "_nav\" class=\"product_images_nav\"><span>Fotos: </span></div>")
	}


	jqProductImages.cycle({
		fx: 'fade',
		timeout: 0,
		pager: "#" + productImages.id + '_nav',
		before: onAfter
	})
	
	// alle product_images durchgehen und höchstes bild suchen
	jQuery.each(jQuery('.product_images'), function() {
		var largestImage = 0;
		var productImagesChilds = jQuery(this).children();
		
		jQuery.each(productImagesChilds, function() {
			if(this.height > largestImage)
			{
				largestImage = this.height;
			}
		});
		
		this.height = largestImage;
	});
	
	imagePageCounter++;
}

function onAfter(curr, next, opts, fwd){
        //get the height of the current slide
        var jQueryht = jQuery(next).height();
        //set the container's height to that of the current slide
        jQuery(next).parent().css("height", jQueryht);
}

function popup(url, windowWidth, windowHeight) {
	if(windowWidth == undefined) {
		windowWidth = 700;
	}

	if(windowHeight == undefined) {
		windowHeight = 600;
	}

	var newWindow = window.open(url, 'popup', 'scrollbars=yes,height=' + windowHeight + ',width=' + windowWidth);
	
	if (window.focus) {
		newWindow.focus()
	}
	
	return false;
}
