mod_options_zoom = {zoomType:'standard',zoomWidth: 310,zoomHeight: 398,xOffset: 10,yOffset: -1,position: "right",title:false};


function show_flash(widht,height,src,cyt,trans,color)
{
if (window.ActiveXObject)
{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+widht+'" height="'+height+'" id="'+src+'">');
document.write('<param name="allowScriptAccess" value="always" />');
document.write('<param name="movie" value="'+src+'" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="wmode" value="'+trans+'">');
document.write('<param name="bgcolor" value="'+color+'" />');
document.write('<PARAM NAME=FlashVars VALUE="'+cyt+'">');
document.write('<embed src="'+src+'" quality="high" FlashVars="'+cyt+'" bgcolor="'+color+'" width="'+widht+'" height="'+height+'" name="'+src+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" wmode="'+trans+'" />');
document.write('</object>');
}
else
{
document.write('<object id="'+src+'" data="'+src+'" type="application/x-shockwave-flash" width="'+widht+'" height="'+height+'">');
document.write('<param name="allowScriptAccess" value="always" />');
document.write('<param name="movie" value="'+src+'" />');
document.write('<param name="quality" value="high" />');
// document.write('<param name="wmode" value="'+trans+'">');
document.write('<param name="bgcolor" value="'+color+'" />');
document.write('<PARAM NAME=FlashVars VALUE="'+cyt+'">');
document.write('<embed src="'+src+'" quality="high" FlashVars="'+cyt+'" bgcolor="'+color+'" width="'+widht+'" height="'+height+'" name="'+src+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}
}

 function CreateBookmarkLink() {
  title = "Skapetze Licht Design"; 
  url = "http://www.skapetze.com"; 
  if (window.sidebar) { // Mozilla Firefox Bookmark	
  window.sidebar.addPanel(title, url,"");
  } else if( window.external ) { // IE Favorite
  window.external.AddFavorite( url, title);
  }	else { 
      alert("Diese Funktion wird leider von ihrem Browser nicht unterstützt");}
  }
  
function showthumb(i){   
	document.getElementById("pic"+i).style.display = "block";
}
		
var bildArray=new Array(1,2,3,4,5,6,7,8,9,10,11,12);
function bild(nummer){
	if(document.getElementById)
	for (a=0;a<bildArray.length;a++){
		if(bildArray[a]!=nummer){
			document.getElementById("bild"+bildArray[a]).style.display = "none";
		}else{
			document.getElementById("bild"+nummer).style.display = "block";
		}
	}
}

var picArray=new Array("first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh")
function showPic(which){
	if(document.getElementById)
	for (a=0;a<picArray.length;a++){
		if(picArray[a]!=which){
			document.getElementById(picArray[a]).style.display = "none";
		}else{
			document.getElementById(which).style.display = "block";
		}
	}
}
var submitter = null;
function submitFunction() {
   submitter = 1;
   }
jQuery(document).ready(function() {
								do_ship_link();
								do_buy_now_init();
								do_cart_quanty_init();
								do_check_highlight();
								setup_bild('true');
	//destroy the countdown befor ajax load jk
jQuery(".subnav_ajax,.tagcloud_ajax").each(function(){
			jQuery(this).click(function(){
										if(document.getElementById("countdown_product_1")){
	jQuery('#countdown_product_1').countdown('destroy');
										};
									  });									 
									 });


jQuery(".subnav_ajax").ajaxContent({target:'#putin',loaderType:'img',loadingMsg:'images/indicator.gif',returning:'true'});
jQuery('#cycle_video').cycle({  fx:     'fade' ,pause:1,speed:1000,timeout:7000,delay:-1000,cleartype:1});
jQuery('#cycle_video_2').cycle({  fx:     'fade' ,pause:1,speed:1000,timeout:7000,delay:-1000,cleartype:1});
jQuery('#cycle_video_3').cycle({  fx:     'fade' ,pause:1,speed:1000,timeout:7000,delay:-2000,cleartype:1});
jQuery('#cycle_video_4').cycle({  fx:     'fade' ,pause:1,random:1,speed:1000,timeout:2000,delay:-1000,cleartype:1});
jQuery('#cycle_video_5').after('<div id="nav">').cycle({  fx:     'scrollHorz' ,pause:1,random:0,next:'.cycle_video_next',prev:'.cycle_video_prev',speed:1000,timeout:7000,delay:-1000,cleartype:1,pager:  '#nav',
		pagerAnchorBuilder: function(idx, slide) { 
        return '<a href="#"></a>';}});
$('#start_cycle').bind('mouseenter',
        function() { $('#cycle_video_controls').show(); }
    );
	$('#start_cycle').bind('mouseleave',
        function() { $('#cycle_video_controls').hide(); }
    );

jQuery('#categories_container').accordion({
  header: '.title',
  selectedClass:'title_active',
  event: 'click',
  autoheight: false,
  active: false,
  animated:'firstclose',
  alwaysOpen:false});


});

 
   function do_ship_link(){
	 var i=0;
	 $(".question_link").live('click',function(){
	i++;
	// do it iframe because of ssl
	show_loader('show');
	var checked_basename = check_ssl($(this).attr('href'));
	var data = '<iframe id="questionIframe'+i+'" name="questionIframe'+i+'" src="'+checked_basename+'" style="width:100%;height:100%;background-color:#ffffff;" frameborder="0" hspace="0" allowtransparency="false"></iframe>';
	//pull it into modal and set the title
	do_question(data,$(this).attr('title'),i);
	return false;
	});

	 
	$(".ship_link").live('click',function(){
	// get the data for the html;
	var checked_basename = check_ssl($(this).attr('href'));
	$.ajax({url:checked_basename,data:{ajax:'ajax_calls',what:'content'},type:'POST',dataType:'json',success:function(data){put_it_in(data)},beforeSend:function(){show_loader('show');}});										   
// window.open($(this).attr('href'),'popup','toolbar=0, scrollbars=yes, resizable=yes, height=720, width=750');
return false;});
		$(".mod_popup_link").live('click',function(){								   
window.open($(this).attr('href'),'popup','toolbar=0, scrollbars=yes, resizable=yes, height=720, width=750');
return false;});
	$(".ui-widget-overlay").live('click',function(){$('#question,#dialog').dialog('destroy');$('object,embed').show();});
 }
 
 function check_ssl(cyt_url){
 					// SSL cyt
					if(typeof cyt_url != 'undefined'){
					var cyt_href = '';
						if(typeof cyt_ajax_request != 'undefined'){
						var cyt_href = cyt_url.replace(cyt_ajax_normal_server,cyt_ajax_ssl_server);
						}else{
							if(cyt_url.search('https:') != -1){
							var cyt_href = cyt_url.replace('https:','http:')
							}else{
							var cyt_href = cyt_url;
							}						
						}
					return cyt_href;
					}
 }
 
  function show_loader(what){
 if(what == 'show'){
	/* $.blockUI({message:'<img src="images/indicator.gif" />',css:{width:'',margin:'0 0 0 -64px',left:'50%',border:'1px solid #CC0000',background:'#000000',padding:'10px'},showOverlay:false,overlayCSS:{opacity:0}});*/
        $.blockUI({
            message: '<img src="images/indicator.gif" />',
            css: {
                width: '',
				height: '',
                margin: '0 0 0 -64px',
                left: '50%',
				top: '40%',
                border: '1px solid #CC0000',
				padding:	'10px',
				backgroundColor:'#000000',
				cursor:		'wait'
            },
            showOverlay: false,
            overlayCSS: {
                opacity: 0
            }
        });
    
	 
 }else{
  $.unblockUI();
 }
 
 }
 
  //for handle the putin
function put_it_in(data,mod_objekt) {
show_loader('hide');
if(typeof(data.error)!='undefined'){
 //alert(data.error);
 	mod_url_to_go = check_ssl(data.error);
	setTimeout(function(){window.location.href = mod_url_to_go},100);
}else{
if(typeof(data.message_to_show)!='undefined'){
$.each(data.message_to_show, function(json_message_to_show_id,json_message_to_show_data){
$.growlUI(json_message_to_show_data.title, json_message_to_show_data.text,5000);
});
}
if(typeof(data.dialog_to_show)!='undefined'){
$.each(data.dialog_to_show, function(json_dialog_to_show_id,json_dialog_to_show_data){
$(json_dialog_to_show_id).dialog({width:600,autoOpen:false,modal:true,bgiframe:true,title:json_dialog_to_show_data.title,close:function(){$('#dialog').dialog('destroy');$('object,embed').show();},open:function(){$('object,embed').hide();}});
$(json_dialog_to_show_id).html(json_dialog_to_show_data.text);
$(json_dialog_to_show_id).dialog('open');
	if($(json_dialog_to_show_id).height() >= 294){
	$(json_dialog_to_show_id).dialog('option','height',350);
	$(json_dialog_to_show_id).dialog('option','position','center');	
	$(json_dialog_to_show_id).css('height','294px');
	}
});
}
// get the right main _content
if(typeof(data.url_to_get)!='undefined'){
$.ajax({url:check_ssl(data.url_to_get),data:{ajax:1},success:function(html_of_data){$('#putin').html(html_of_data);do_cart_quanty_init();show_loader('hide');},beforeSend:function(){show_loader('show');}});
}
if(typeof(data.items)!='undefined'){
// now give the boxes the new data
$.each(data.items, function(json_id,json_data){
if(typeof(mod_objekt)!='undefined'){
mod_objekt.effect("transfer", { to: json_data.update_select }, 1000,function(){$(json_data.update_select).effect('highlight', {color:'#cc0000'}, 750);});
}else{
$(json_data.update_select).effect('highlight', {color:'#cc0000'}, 750);
}
$(json_data.update_select).html(json_data.update_text);
});
}

}

}

  function do_question(quest_data,headline,quant){
	$('#question').dialog({height:350,width:600,autoOpen:false,modal:true,bgiframe:true,close: function(ev, ui) {$('#question').dialog('destroy');$('#questionIframe'+quant).remove();$('object,embed').show();},open:function(){$('object,embed').hide();}});
	$('#question').html(quest_data);
	$('#questionIframe'+quant).load(function(){show_loader('hide');
				$('#question').dialog('option', 'title', headline);
				$('#question').dialog('open'); 
				});

	 }
 
 function do_buy_now_init(){
$("a[href*='action=buy_now&BUYproducts_id']").live('click',function(){									
var mod_objekt = $(this);
var checked_basename = check_ssl($(this).attr('href'));
$.ajax({url:checked_basename,data:{ajax:'ajax_calls',what:'cart'},dataType:'json',success:function(data){put_it_in(data,mod_objekt);},beforeSend:function(){show_loader('show');}});
return false;
});	
}
 
 function do_cart_quanty_init(){
	if($('#cart_quantity').length){
	var checked_basename = check_ssl($('#cart_quantity').attr('action'));
    var options = { 
		url:checked_basename,
		dataType:'json',
		data:{ajax:'ajax_calls',what:'cart'},
        beforeSubmit:  function(){show_loader('show')},  // pre-submit callback 
        success:       function(data){put_it_in(data);do_cart_quanty_init();$('#cart_pos_rel').height($('#putin_cart').height());}   // post-submit callback 
    }; 	
	 $('#cart_quantity').ajaxForm(options);
$('select[name=attributes]').bind('change',function(){ $('#cart_quantity').ajaxSubmit(options);});	 
	 // bind the keypress
var search_timeout = undefined;
$('input[name^=cart_quantity]').bind('keyup', function() {
        if(search_timeout != undefined) {
                clearTimeout(search_timeout);
        }
        var $this = this; // save reference to 'this' so we can use it in timeout function
        search_timeout = setTimeout(function() {
                search_timeout = undefined;
                $('#cart_quantity').ajaxSubmit(options);
        }, 750);
});
	 
$('#cart_quantity').submit(function(){
return false;
});
	}
}
 
 	 function do_check_highlight(){
//var checked_basename = check_ssl(window.location.href);
//$.ajax({url:checked_basename,data:{ajax:'ajax_calls',what:'highlight'},type:'POST',dataType:'json',success:function(data){highlight_it(data)},beforeSend:function(){}});	
highlight_it();
 }
 
 function highlight_it(data){
	 var config = {    
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
     interval: 300, // number = milliseconds for onmouseover polling interval    
     over: function(){JT_show($(this));}, // function = onmouseover callback (REQUIRED)    
     timeout: 500, // number = milliseconds delay before onmouseout    
     out: function(){} // function = onmouseout callback (REQUIRED)    
	};
	$(".highlight").hoverIntent(config);
	  $(".highlight").live('click',function(){
												JT_show($(this));
												return false;
												});
	  /*if(typeof(data.highlight)!='undefined'){
	 $.each(data.highlight, function(json_id,json_data){
  $('body').highlight(json_data.title,json_data.mod_id);
									 });
	  }*/
 }
 
  function mysqlTimeStampToDate(timestamp) {
    //function parses mysql datetime string and returns javascript Date object
    //input has to be in this format: 2007-06-05 15:26:02
    var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
    var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
    return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
  }
  
   function setup_bild(zoom){
	 if(zoom=='true'){
	 	if($.browser.safari){
			 //pause for the safari nasty but nice
	 	setTimeout(function(){$('#zoom_it_1').jqzoom(mod_options_zoom);},1000);
	 	}else{
	 	$('#zoom_it_1').jqzoom(mod_options_zoom);
	 	}
	 }
		$('.prodinfo_smallimage > a').click(function(){
							var nummer = $(this).parents('div').attr('id').replace('small','');
							$("div[id^='bild']").hide();
							$('.prodinfo_smallimage > a').removeClass('pic_aktive');
							//$("a[id^='zoom_it_']").unbind();
							$('img.loaded_not_fired').remove();
							$("#bild"+nummer).show();
							$(this).addClass('pic_aktive');
							$('#zoom_it_'+nummer).jqzoom(mod_options_zoom);
					   return false;
					   });
				
	}
