var kkMenu=Array();
var kkMenuToLoad=0;
var kkMenuReady=0;
function canManipulateImages() {if (document.images) {return true;}else{return false;}}
function preLoadImage(menuname) {
	kkMenu[menuname]=Array();
	kkMenu[menuname][0]=new Image();
	kkMenuToLoad++;
	kkMenu[menuname][0].onload=function(){
//		if ($(menuname).src.indexOf('main')>0) {
//			$(menuname).src==kkMenu[menuname][0].src;
//		}
		kkMenuReady++;
		if (kkMenuReady==kkMenuToLoad) {
			showMenu();
		}
	}
	main_suffix='main';
	over_suffix='over';
	if ($(menuname)) {
		varDesign=$(menuname).getAttribute('varDesign');
	}
	
	if (varDesign=='reverse' && menuname.indexOf('shape')!=0) {
		main_suffix='over';
		over_suffix='black.over';
	}
	if (varDesign=='wedding' && menuname.indexOf('shape')!=0) {
		main_suffix='wedding.main';
		over_suffix='black.over';
	}
	if (varDesign=='wedding' && menuname.indexOf('shape')==0) {
		main_suffix='over';
		over_suffix='over';
	}
	if (varDesign=='wedding_home' && menuname.indexOf('shape')!=0) {
		main_suffix='over';
		over_suffix='black.over';
	}
	if (varDesign=='main_white' && menuname.indexOf('shape')!=0) {
		main_suffix='white.main';
		over_suffix='black.over';
	}

	kkMenu[menuname][0].src=path_images+'Menu/'+menuname+'.'+main_suffix+'.png';
	
	kkMenu[menuname][1]=new Image();
	kkMenu[menuname][1].src=path_images+'Menu/'+menuname+'.'+over_suffix+'.png';
}
function chImage(menuname,menustate) {
	$(menuname).src=kkMenu[menuname][menustate].src;
}
function startPreload() {
	thisURL=document.location+'';
	thisURL=thisURL.toLowerCase();
	preLoadImage('story');
		if (thisURL.indexOf('story')>0) {
			preLoadImage('story_store');
			preLoadImage('story_biography');
			preLoadImage('story_philosophy');
			preLoadImage('story_style');
		}
	preLoadImage('collections');
		if (thisURL.indexOf('collections')>0) {
			if (thisURL.indexOf('by')<1 && thisURL.indexOf('category')<1) {
				preLoadImage('collections_18kwhitegold');
//					if (thisURL.indexOf('18k')>0 && thisURL.indexOf('white')>0 && thisURL.indexOf('gold')>0) {
					if (thisURL.indexOf('18k-white-gold')>0) {
						preLoadImage('collections_18kwhitegold_cognac');
						preLoadImage('collections_18kyellowgold_tigereye');
						preLoadImage('collections_18kwhitegold_beigecoral');
						preLoadImage('collections_18kwhitegold_cremecoral');
					}
				preLoadImage('collections_18krosegold');
//					if (thisURL.indexOf('18k')>0 && thisURL.indexOf('rose')>0 && thisURL.indexOf('gold')>0) {
					if (thisURL.indexOf('18k-rose-gold')>0) {
						preLoadImage('collections_18krosegold_pinkcoral');
						preLoadImage('collections_18krosegold_blackdiamond');
						preLoadImage('collections_18krosegold_jade');
					}
				preLoadImage('collections_18kyellowgold');
//					if (thisURL.indexOf('18k')>0 && thisURL.indexOf('yellow')>0 && thisURL.indexOf('gold')>0) {
					if (thisURL.indexOf('18k-yellow-gold')>0) {
						preLoadImage('collections_18kyellowgold_lapizlazuli');
						preLoadImage('collections_18kyellowgold_turquoise');
						preLoadImage('collections_18kyellowgold_turquoiseandruby');
						preLoadImage('collections_18kyellowgold_whitecoral');
						preLoadImage('collections_18kyellowgold_redcoral');
					}
				preLoadImage('collections_mensjewelry');
				preLoadImage('collections_silver');
				preLoadImage('collections_silver18kgold');
				preLoadImage('collections_platinum_caps');
					if (thisURL.indexOf('platinum-jewelry')>0) {
						preLoadImage('collections_platinum_colorlessdiamond');
						preLoadImage('collections_platinum_bluesapphire');
					}
			}
			preLoadImage('collections_bycategory');
				if (thisURL.indexOf('by')>0 && thisURL.indexOf('category')>0) {
					preLoadImage('collections_bycategory_bracelets');
					preLoadImage('collections_bycategory_cufflinks');
					preLoadImage('collections_bycategory_earrings');
					preLoadImage('collections_bycategory_necklace');
					preLoadImage('collections_bycategory_rings');
				}
		}
	preLoadImage('weddingsuite');
		if (((thisURL.indexOf('wedding')>0 && thisURL.indexOf('suite')>0) || (thisURL.indexOf('wedding')>0 && thisURL.indexOf('questionnaire')>0)) && thisURL.indexOf('collection')<1 && thisURL.indexOf('shop')<1) {
			preLoadImage('weddingsuite_engagement_rings');
			preLoadImage('weddingsuite_womens_wedding_rings');
			preLoadImage('weddingsuite_mens_wedding_rings');
			preLoadImage('weddingsuite_bridal_jewelry');
//			preLoadImage('weddingsuite_wedding_questionaire');
		}
	preLoadImage('wordofmouth');
		if (thisURL.indexOf('word')>0 && thisURL.indexOf('of')>0 && thisURL.indexOf('mouth')>0) {
			preLoadImage('wordofmouth_asseenin');
			preLoadImage('wordofmouth_news');
			preLoadImage('wordofmouth_clientsspeak');
			preLoadImage('wordofmouth_presscenter');
		}
	preLoadImage('shop');
	preLoadImage('service');
	preLoadImage('limited_editions');
	preLoadImage('shapes_mtb');
	preLoadImage('shapes_news');
	preLoadImage('shapes_new_collection');
	preLoadImage('shapes_new_pieces');
	preLoadImage('shapes_press');
	preLoadImage('shapes_register');
}
function showMenu() {
	if (IE) {
			$('kkMenu').style.visibility='visible';
			$('kkLogo').style.visibility='visible';
			if ($('kkMenu_Shapes_Rotator')) {
				$('kkMenu_Shapes_Rotator').style.visibility='visible';
			}
		} else {
			$('kkMenu').style.visibility='visible';		
			$('kkLogo').style.visibility='visible';
			if ($('kkMenu_Shapes_Rotator')) {
				$('kkMenu_Shapes_Rotator').style.visibility='visible';
			}
	}
	position_kkBottom();
//	setHints('kkContent','img');
}
function onLoadOperations() {
	showMenu();
//	startPreload();
	if (IE) {
//			window.onscroll=scroll_kkBottom;
//			window.onresize=scroll_kkBottom;
//			scroll_kkBottom();
//			position_kkBottom();
		} else {
//			scroll_kkBottom();
//			position_kkBottom();
//			alert(document.documentElement.scrollHeight);
//			window.onscroll=scroll_kkBottom;
//			setInterval('scroll_kkBottom()',10);
	}
}

function position_kkBottom() {
	kkBottom_top=518;
	delta=0;

	if (IE) {
		kkBottom_top=kkBottom_top-20;
		delta=20;
	}

	if ($('divSClink').style.display=='block') {
		kkBottom_top=kkBottom_top-$('divSClink').clientHeight;
	}
	if ($('divWLlink').style.display=='block') {
		kkBottom_top=kkBottom_top-$('divWLlink').clientHeight;
	}
	
	if (kkBottom_top < ($('kkLeftSide').clientHeight+90) && IE) {
		kkBottom_top=$('kkLeftSide').clientHeight+68+delta;
	}

	if (kkBottom_top < ($('kkLeftSide').clientHeight+20) && !IE) {
		kkBottom_top=$('kkLeftSide').clientHeight+10+delta;
	}
	if (!IE) {
			kkBottom_top=kkBottom_top-8;
		} else {
			kkBottom_top=kkBottom_top+8;
	}
	$('kkBottom').style.top=kkBottom_top+'px';
	$('kkBottom').style.paddingBottom='20px';
}

function showPurchaseInfo(id_product, e) {
	ev=(isIE)?window.event:e;
	hintObj=$('divPurchaseInfo');
	if (!hintObj) {return;}
	xpos=ev.clientX;
	hintObj.style.display='none';
	hintObj.style.left=(xpos-200)+'px';
	hintObj.style.top=(ev.clientY)+7+'px';
	xajax_opAjax_showPurchaseInfo(id_product);
	return false;
}

function addBookmark(url, title) { 
	if (!url) url=location.href;
	if (!title) title=document.title;

	if ((typeof window.sidebar=='object') && (typeof window.sidebar.addPanel=='function')) {
			//Gecko
			window.sidebar.addPanel(title, url, '');
		} else if (typeof window.external=='object') {
			//IE4+
			window.external.AddFavorite(url, title);
		} else if (window.opera && document.createElement) {
			//Opera7+
			var a=document.createElement('A');
			if (!a) return false; 
			//IF Opera 6
			a.setAttribute('rel','sidebar');
			a.setAttribute('href',url);
			a.setAttribute('title',title);
			a.click();
		} else {
			return false;
	}
	return true;
} 

