function parse_json(json)
{
	if(json == undefined || !json || json == '') return;
	var json = eval( "(" + json + ")"); 
	if(json == undefined || !json || !json.length) return;
	
	for(var i in json)
	{
		if(json[i] == null) continue;
		
		if(json[i].type == 'html')
		{
			var obj = $('#'+json[i].name);
			if(!obj.length) continue;
			obj.html(json[i].value);
		}
		else
		if(json[i].type == 'alert')
			alert(json[i].value);
		else
		if(json[i].type == 'go')
			window.location.href = json[i].value;
		else
		if(json[i].type == 'form')
			$('#'+json[i].name+' form').ajaxForm({ success: function(result) { parse_json(result); }});
	}
}

function f1()
{
	$('#eventt').fadeOut(1000, f2);	
}

function f2()
{
	$('#eventt').fadeIn(1000, f1);	
}

function sethintfocus()
{
	var name = $(this).attr('name');
	$('label.fieldHint[for="'+name+'"]').fadeIn('slow');	
}

function sethintbluer()
{
	var name = $(this).attr('name');
	$('label.fieldHint[for="'+name+'"]').fadeOut('slow');	
}

function init_feedback()
{
	$('#sendform input').focus(sethintfocus).blur(sethintbluer);
	$('#sendform textarea').focus(sethintfocus).blur(sethintbluer);
	
	var options = { 
	    target:        '#send_result'
	    /*beforeSubmit:  showRequest,*/ 
	    /*success:       showResponse*/ 
	
	    // other available options: 
	    //url:       url         // override for form's 'action' attribute 
	    //type:      type        // 'get' or 'post', override for form's 'method' attribute 
	    //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
	    //clearForm: true        // clear all form fields after successful submit 
	    //resetForm: true        // reset the form after successful submit 
	
	    // $.ajax options can be used here too, for example: 
	    //timeout:   3000 
	}; 
	
//	$('#sendform').ajaxForm(options);
}


$(function() 
{
	var sPath = document.location.href;
	if (sPath.indexOf('wwwcontent')!=-1 && $.browser.msie) {
	  var aPath = sPath.split('/');
	  var nCnt = 0;
	  for (var i=0;i <= aPath.length; i++) {
	    if (aPath[i] == 'wwwcontent') {
	      nCnt = aPath.length - i - 2;
	    }
	  }
	  var sAdd = '';
	  for (i=1; i <= nCnt; i++) {
	    sAdd = sAdd + '../';
	  }
	  
	  var csshref = sAdd+'css/ie.css';
  
	  var fileref=document.createElement("link");
	  fileref.setAttribute("rel", "stylesheet");
	  fileref.setAttribute("type", "text/css");
	  fileref.setAttribute("href", csshref);
	  document.getElementsByTagName("head")[0].appendChild(fileref);
	  
	  $(".catalog .title .cir, .sub1t, .sub2t, .sub1b, .sub2b, .sub1, .sub2, #fancy_close, #fancy_loading div, #fancy_bg div, #fancy_title_left, #fancy_title_right").css("behavior","url('"+sAdd+"pngbehavior.htc')");
	}
	
	$("a").not('.relref, .fotoimg, .active, .ajtip, a[@href=""]').hover(
		function(){ $(this).addClass('hover'); },
		function(){ $(this).removeClass('hover'); 
	});

    $('div.img').hover(function() { $(this).addClass('active');}, function() { $(this).removeClass('active'); });
	$("a.fotoimg, area.fotoimg").fancybox({ 'hideOnContentClick': true, 'overlayShow': false }); 

/*	$("a, img").
		tooltip({ 
			positionLeft: true,
			fade: 250,
			showURL: false 
		});
*/	
		
	$('a.ajtip').cluetip({
	      cluetipClass: 'jtip',
		  arrows: true, 
	      dropShadow: true, 
		  width:120,
	      height: 'auto',
	      sticky: true,
	      positionBy: 'bottomTop',
		  closeText: '',
		  local: true,
		  mouseOutClose: true,
		  delayedClose: 10000
    	});
    
    $('ul.gall_images').galleria({
		history   : false, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
			if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
				//image.css('display','none').fadeIn(1000);
				var _wrapper = $('.galleria_wrapper');
				_wrapper.css('display','none').fadeIn(1000);
			}
			caption.css('display','none').fadeIn(1000);
			var _li = thumb.parents('li');
			_li.siblings().children('img.selected').fadeTo(500,0.95);
			thumb.fadeTo('fast',1).addClass('selected');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			var _li = thumb.parents('li');
			var _fadeTo = _li.is('.active') ? '1' : '0.95';
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.95); } // don't fade out if the parent is active
			)
		}
	});
		
	f1();
	
	
	$('#mainrolll').cycle({ 
	    fx:     'fade', 
	    speed:   1000, 
	    timeout: 3000, 
	    next:   '#mainrolll', 
	    pause:   1,
	    random: 1,
	    delay: 2000
	});
	
	$('#mainrollr').cycle({ 
	    fx:     'fade', 
	    speed:   1000, 
	    timeout: 3000, 
	    next:   '#mainrollr', 
	    pause:   1,
	    random: 1,
	    delay: 3000
	});
	
});

