jQuery = jQuery.noConflict();
var i;
var im = 0;
var imrc = 0;
var t = 0;

var url = "null";
jQuery(function() {
	//jQuery("html, body").scrollTop(250);
	//jQuery("#contentWrap").fadeIn();

	jQuery(".nBTN").hover(
		function(){
			jQuery(this).stop().animate({opacity:1});	
		},
		function(){
			jQuery(this).stop().animate({opacity:.7});	
		}
	);
	t = setTimeout('imageCycle()',3500);
	
	
	jQuery(".nBTN a").click(function(event) {
		//url = event.target.href;
		//transition();
		//return false;
	});
});

function transition() {
	//jQuery("#contentWrap").fadeOut();
	//jQuery("html, body").animate({scrollTop:426},1100);
			
}
jQuery(window).scroll(function(e){
	
	if(jQuery(this).scrollTop() > 400){
		
		if(url == "null"){
			
		}
		else {
			window.location = url;
			
		}
	}
});
function randomFromTo(from, to){
       return Math.floor(Math.random() * (to - from + 1) + from);
    }
function imageCycle() {
	im = randomFromTo(0,3);
	if(im == i){
		imageCycle();
	}
	else {
		var ran = randomFromTo(3700,7700);
		t = setTimeout('change(im)',ran);
	}
}
function change(img) {
	var imr = randomFromTo(4,23);
	
	if(imr == imrc){
		imageCycle();
	}
	else {
		
	jQuery(".CIM:eq("+img+")").animate({opacity:0},function(){
				jQuery(this).html("<img src='http://www.clpjewelry.com/images/UI/img"+imr+".jpg' />");
				jQuery(this).animate({opacity:1},'slow');	
		});	
		t = 0;
		clearTimeout(t);
		i = im;
		imrc = imr;
		imageCycle();
	}
	
}
