// JScript File
function openAddProperyWindow(url, height, width) {
	window.open(url, 'productAttributeValue', 'height=' + height + ',width=' + width + ',statusbar=0,resizable=no,toolbar=no,menubar=no,scrollbars=yes');
	alert(2)
	return false;
}

function jumpToURL(ddlURL) {
	window.location.href = ddlURL.options[ddlURL.selectedIndex].value;
}

function setStatusBarText(txtStatus) {
	window.status = txtStatus; return true
}

function checkEnterForFormSubmit(e, o) { //e is event object passed from function invocation
	var characterCode                       //literal character code will be stored in this variable

	if (e && e.which) { //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else {
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
		o.form.submit() //submit the form
		return false
	}
	else {
		return true
	}
}

function handleEnterForSearch(button, event, buttonID) {
	var keyCode = event.keyCode
	if (keyCode == 13) {
		var button = document.getElementById(buttonID);
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = false;
		button.click();
	}
}

function clearMe(defaultVal, txtBox) {
	if (txtBox.value == defaultVal) {
		txtBox.value = '';
	}
}

/* OPEN IMAGES IN NEW WINDOW (auto size) */
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.
PositionX = 100;
PositionY = 100;

defaultWidth = 900;
defaultHeight = 700;

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
	var isNN = (navigator.appName == "Netscape") ? 1 : 0;
	var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
var optNN = 'scrollbars=no,width=' + defaultWidth + ',height=' + defaultHeight + ',left=' + PositionX + ',top=' + PositionY;
var optIE = 'scrollbars=no,width=150,height=100,left=' + PositionX + ',top=' + PositionY;
function popImage(imageURL, imageTitle) {
	if (isNN) { imgWin = window.open('about:blank', '', optNN); }
	if (isIE) { imgWin = window.open('about:blank', '', optIE); }
	with (imgWin.document) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>'); writeln('<sc' + 'ript>');
		writeln('var isNN,isIE;'); writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;'); writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){'); writeln('if (isIE){'); writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}'); writeln('if (isNN){');
		writeln('window.innerWidth=document.images["Slika"].width;'); writeln('window.innerHeight=document.images["Slika"].height;}}');
		writeln('function doTitle(){document.title="' + imageTitle + '";}'); writeln('</sc' + 'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()" onclick="self.close()" style="cursor: hand;">');
		writeln('<img name="Slika" src=' + imageURL + ' style="display:block"></body></html>');
		close();
	}
}

function SetStyle(sHref, sStyle) {
	_sHref = document.getElementById(sHref);
	if (_sHref) {
		if (_sHref.className == 'mm_last_hover') {
			_sHref.className = 'mm_last_hover';
		}
		else {
			_sHref.className = sStyle;
		}
	}
}
var menuTimeout = null;

function clearMenuTimeout() {
	if (menuTimeout != null) {
		clearTimeout(menuTimeout);
	}
}

function HideMenuDivWithTimeout(IDdiv, ShowMainMenuWrap, counter) {
	clearMenuTimeout();
	menuTimeout = setTimeout('HideMenuDiv("' + IDdiv + '","' + ShowMainMenuWrap + '","' + counter + '")', 250);
}

function ShowMenuDiv(IDdiv, top_position, IDsHref, isInsideLink, isDefaultPage, counter) {

	clearMenuTimeout();

	//first we set default styles to lnkMenuItem, because mm_item has changed it
	for (i = 0; i < 30; i++) {
		_index = i;
		if (i < 10) { _index = '0' + i; }
		if (isDefaultPage == 'True') {
			_sHref = document.getElementById('ctl00_ctl00_MainContentPlaceholder_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem');
		}
		else {
			_sHref = document.getElementById('ctl00_ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem');
		}
		if (!_sHref) {
			_sHref = document.getElementById('ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem');
		}
		if (_sHref) {
			if (_sHref.className == 'mm' || _sHref.className == 'mm_hover') {
				_sHref.className = 'mm';
			}
			else {
				_sHref.className = 'mm_last';
			}
		}
	}

	for (j = 0; j < 30; j++) {
		_index2 = j;
		if (j < 10) { _index2 = '0' + j; }
		if (isDefaultPage == 'True') {
			_sHref = document.getElementById('ctl00_ctl00_MainContentPlaceholder_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2);
		}
		else {
			_sHref = document.getElementById('ctl00_ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2);
		}
		if (!_sHref) {
			_sHref = document.getElementById('ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2);
		}
		if (_sHref) {
			_sHref.className = 'mm_opened';
		}
	}

	if (IDsHref != '') {
		_sHref = document.getElementById(IDsHref);
		if (_sHref) {
			if (_sHref.className == 'mm' || _sHref.className == 'mm_hover') {
				_sHref.className = 'mm_hover';
			}
			else {
				_sHref.className = 'mm_last_hover';
			}
		}
	}

	//first we hide all divs
	for (i = 0; i < 50; i++) {
		if (IDdiv != 'mm_item_' + i) {
			_div = document.getElementById('mm_item_' + i);
			if (_div) {
				_div.style.display = 'none';
			}
		}
	}

	_div = document.getElementById(IDdiv);
	if (_div) {
		_div.style.display = 'none';
	}

	if (!isInsideLink) { //we show submenu if link is not insidelink

		_div = document.getElementById(IDdiv);
		if (_div) {
			if (top_position != -1) {
				if (isDefaultPage == 'True') {
					if ($.browser.msie && $.browser.version <= 7) {			
						if ($.browser.version == 6) {
							_div.style.top = top_position - 118 + 'px';
						} 				
						if ($.browser.version == 7) {
							_div.style.top = top_position - 113 + 'px';
						} 
					}
					else {
						_div.style.top = top_position + 'px';
					}
				}
				else {
					if ($.browser.msie) {
						if ($.browser.version <= 7) {
							_div.style.top = top_position - 10 + 'px';
						}
						else {
							_div.style.top = top_position - 8 + 'px';
						}	
					}
					else {
						_div.style.top = top_position - 10 + 'px';
					}
				}
			}
			_div.style.display = 'block';
		}
	}
}

function HideMenuDiv(IDdiv, ShowMainMenuWrap, counter) {

	for (i = 0; i < 30; i++) {
		_index = i;
		if (i < 10) { _index = '0' + i; }
		var tmp = 'ctl00_ctl00_MainContentPlaceholder_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem';
		_sHref = document.getElementById(tmp);
		if (!_sHref) {
			_sHref = document.getElementById('ctl00_ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem');
		}
		if (!_sHref) {
			_sHref = document.getElementById('ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl' + _index + '_lnkMenuItem');
		}
		if (_sHref) {
			if (_sHref.className == 'mm' || _sHref.className == 'mm_hover') {
				_sHref.className = 'mm';
			}
			else {
				_sHref.className = 'mm_last';
			}
		}
	}

	for (j = 0; j < 30; j++) {
		_index2 = j;
		if (j < 10) { _index2 = '0' + j; }
		var tmp = 'ctl00_ctl00_MainContentPlaceholder_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2;
		_sHref = document.getElementById(tmp);
		if (!_sHref) tmp = 'ctl00_ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2;
		if (!_sHref) tmp = 'ctl00_PageHeader1_HeaderSub1_SiteMenuSpecial1_rptMenuSpecial_ctl0' + counter + '_ctl' + _index2;
		_sHref = document.getElementById(tmp);
		if (_sHref) {
			_sHref.className = 'mm_opened';
		}
	}

	if ((IDdiv == 'main_menu_wrap') || (IDdiv == 'main_menu_home')) {
		if (ShowMainMenuWrap == 'False') {
			if (IDdiv == 'main_menu_wrap') {
				document.getElementById('main_menu_wrap').style.display = 'none';
			}
			else {
				document.getElementById('main_menu_home').style.display = 'none';
			}
		}
	}
	else {
		if (ShowMainMenuWrap == 'False') { //not default page
			if (document.getElementById('main_menu_wrap')) {
				document.getElementById('main_menu_wrap').style.display = 'none';
			}
			else {
				document.getElementById('main_menu_home').style.display = 'none';
			}
		}
		_div = document.getElementById(IDdiv);
		if (_div) {
			_div.style.display = 'none';
		}
	}
}

function findPosY(obj) {
	eleOffset = $(obj).offset();
	return eleOffset.top;
}

var TopMenuTimeout = null;

function clearTopMenuTimeout() {
	if (TopMenuTimeout != null) {
		clearTimeout(TopMenuTimeout);
	}
}

function ShowTopmenuDivWithTimeout(IDdiv, ParentID) {
	clearTopMenuTimeout();
	TopMenuTimeout = setTimeout('ShowTopMenuDiv("' + IDdiv + '","' + ParentID + '")', 250);
}

function ShowTopMenuDiv(IDdiv, ParentID) {
	clearTopMenuTimeout();

	//first we hide all divs
	for (i = 0; i < 50; i++) {
		if (IDdiv != 'hn_popup_' + i) {
			HideTopMenuDiv('hn_popup_' + i);
		}
	}

	_div = document.getElementById(IDdiv);
	if (_div) {
		_div.style.display = 'block';
	}

	_ParentID = document.getElementById(ParentID);
	if (_ParentID) {
		_ParentID.className = 'hnlw_link_hover';
	}

}



function HideTopMenuDivWithTimeout(IDdiv, ParentID) {
	clearTopMenuTimeout();
	TopMenuTimeout = setTimeout('HideTopMenuDiv("' + IDdiv + '","' + ParentID + '")', 250);
}


function HideTopMenuDiv(IDdiv, ParentID) {
	//first we hide all divs
	for (i = 0; i < 50; i++) {
		_div = document.getElementById('hn_popup_' + i);
		if (_div) {
			_div.style.display = 'none';
		}
	}

	for (i = 0; i < 50; i++) {
		_href = document.getElementById('hnlw_link_' + i);
		if (_href) {
			_href.className = 'hnlw_link';
		}
	}
}

function ShowSearchDiv(val) {
	document.getElementById('where_popup').style.display = 'block';
}

function HideSearchDiv() {
	document.getElementById('where_popup').style.display = 'none';
}

function ShowProdColourListDiv() {
	document.getElementById('choose_color').style.display = 'block';
}

function HideProdColourListDiv() {
	document.getElementById('choose_color').style.display = 'none';
}

function ShowSelProdColourDiv() {
	document.getElementById('sel_opt').style.display = 'block';
}
function SHProdColourListDiv() {
	var tip = document.getElementById('selected_option').style.display;

	if (tip == 'block') {
		document.getElementById('choose_color').style.display = 'block';
	} else {
		document.getElementById('choose_color').style.display = 'none';
	}
}

var showedDIV;

function SHProdCompleteByProdID(divname) {

	obj = document.getElementById('divAttributes_' + showedDIV);
	obj.style.display = 'none';

	var obj = document.getElementById('divAttributes_' + divname);
	obj.style.display = 'block';

	showedDIV = divname;

}

function SHOceniIzdelekDiv(divname) {

	var obj = document.getElementById(divname);

	if (obj.style.display == 'none') {
		obj.style.display = 'block';
	}
	else {
		obj.style.display = 'none';
	}
}


function ToggleMenu(val) {
	if (val == 1) {
		document.getElementById('Menu1Top').className = 'lam_option_on';
		document.getElementById('Menu2Top').className = 'lam_option_off';
		document.getElementById('ctl00_ctl00_MainContentPlaceholder_MainContentPlaceholder_Menu1').style.display = 'block';
		document.getElementById('ctl00_ctl00_MainContentPlaceholder_MainContentPlaceholder_Menu2').style.display = 'none';
	}
	else {
		document.getElementById('Menu1Top').className = 'lam_option_off';
		document.getElementById('Menu2Top').className = 'lam_option_on';
		document.getElementById('ctl00_ctl00_MainContentPlaceholder_MainContentPlaceholder_Menu1').style.display = 'none';
		document.getElementById('ctl00_ctl00_MainContentPlaceholder_MainContentPlaceholder_Menu2').style.display = 'block';
	}
}

//custom options
function OpenPopupOptions(url, options) {
	//MyWindow=window.open('popups/popup_template.shtml','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300'); return false;
	var _win = null
	_win = window.open(url, 'bigbangPopup', options);
	if (window.focus) { _win.focus() }
	return _win == null;
}

//custom dimensions
function OpenPopup(url, width, height) {
	var options = 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ' ,height=' + height;
	return OpenPopupOptions(url, options);
}

function load() {
	Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

function EndRequestHandler() {
	obj = document.getElementById('offline_stock')
	if (obj && obj.nodeName != "DIV") {
		alert('nodeValue: ' + obj.nodeValue);
		alert('nodeName: ' + obj.nodeName);
		if (document.getElementById('ctl00_ctl00_MainContentPlaceholder_MainContentPlaceholder_ProductDetailStoresStock2_hfHelper').value == '1') {
			document.getElementById('offline_stock').style.display = 'block';
		}
	}
}
