function viewImage(src, title){
	if (!document.getElementById('jscontainer')) document.body.innerHTML += '<div id="jscontainer"></div>';
	document.getElementById('jscontainer').innerHTML = '<div onclick="closeImage()" id="overlay"></div><div id="lightbox"><div id="outerImageContainer"><div id="imageContainer"><img src="/images/px.gif" id="lightboxImage"><div id="loading"><a href="#" id="loadingLink"><img src="/images/loading.gif"></a></div></div></div><div id="imageDataContainer"><div id="imageData"><div id="imageDetails"><span id="caption">' +title + '</span></div><div id="bottomNav"><a onclick="closeImage()" id="bottomNavClose"><img src="/images/closelabel.gif"></a></div></div></div>';
	overlay();
	if (document.images)
	{
		preload_image_object = new Image();
	   	preload_image_object.src = src;
		if (preload_image_object.width){
			ts();
		}else{
			preload_image_object.onload = ts;
		}
	}
}
function closeImage(){
	if (document.getElementById('jscontainer')){
		document.getElementById('jscontainer').innerHTML = '';
	}
}
function ts(){
	document.getElementById('loading').style.display = 'none';
	document.getElementById('outerImageContainer').style.width = (preload_image_object.width + 20) + 'px';
	document.getElementById('outerImageContainer').style.height = (preload_image_object.height + 20) + 'px';
	document.getElementById('imageDataContainer').style.width = (preload_image_object.width + 20) + 'px';
	document.getElementById('lightboxImage').src = preload_image_object.src;
	document.getElementById('lightbox').style.top = (document.getElementById('htmli').scrollTop+100) + 'px';
	overlay();
}
function overlay(){
	if (window.innerWidth){
		document.getElementById('overlay').style.width=(window.innerWidth)+'px';
		document.getElementById('overlay').style.height=document.getElementById('htmli').scrollHeight+'px';
	}else{
		document.getElementById('overlay').style.width=(document.body.clientWidth)+'px';
		document.getElementById('overlay').style.height=document.getElementById('htmli').scrollHeight+'px';
	}
}
function ModalWin(text){
	if (!document.getElementById('jscontainer')) document.body.innerHTML += '<div id="jscontainer"></div>';
	document.getElementById('jscontainer').innerHTML = '<div onclick="closeImage()" id="overlay"></div><div id="lightbox2"><div id="outerImageContainer"><div id="imageContainer">'+text+'</div></div><div id="imageDataContainer"><div id="imageData"><div id="bottomNav"><a onclick="closeImage()" id="bottomNavClose"><img src="/images/closelabel.gif"></a></div></div></div>';
	document.getElementById('outerImageContainer').style.width = '500px';
	document.getElementById('outerImageContainer').style.height = (document.getElementById('imageContainer').offsetHeight + 20) + 'px';
	document.getElementById('imageDataContainer').style.width = '500px';
	overlay();
}

function ModalWin2(text){
	if (!document.getElementById('jscontainer')) document.body.innerHTML += '<div id="jscontainer"></div>';
	document.getElementById('jscontainer').innerHTML = '<div onclick="closeImage()" id="overlay"></div><div id="lightbox2"><div id="imageDataContainer"><div style="position: absolute; margin-top: 30px; margin-left: 30px; font-size: 18px; font-weight: bold; font-family: Tahoma, Sans-Serif;">Товар</div><div id="imageData"><div id="bottomNav"><a onclick="closeImage()" id="bottomNavClose"><div style="background: url(/images/closelabel.gif) top right no-repeat; width: 20px; height: 22px; margin-top: 30px; margin-left: 30px;">&nbsp;</div></a></div></div></div><div id="outerImageContainer"><div id="imageContainer" style="padding: 10px 30px; text-align: left;">'+text+'<a href="/cart.jsp"><img src="/images/cartbtn_go.jpg" height="50"></a> <img src="/images/cartbtn_close.jpg" height="50" onclick="closeImage()" style="cursor: pointer;"></div></div></div>';
	document.getElementById('lightbox2').style.top = ($(window).scrollTop()+100) + 'px';
	document.getElementById('outerImageContainer').style.width = '370px';
//	document.getElementById('outerImageContainer').style.height = (document.getElementById('imageContainer').offsetHeight + 20) + 'px';
	document.getElementById('imageDataContainer').style.width = '370px';
	overlay();
}


$(document).ready(function() {
	$('.tx').focus(function() {
		if (this.value == this.defaultValue) this.value = '';
		if(this.value != this.defaultValue) this.select();
	});
	$('.tx').blur(function() {
  		if ($.trim(this.value) == '') this.value = (this.defaultValue ? this.defaultValue : '');
	});
	$('#pass').focus(function() {
		if (this.value == this.defaultValue){
			this.value = '';
			this.type = 'password';
		}
		if(this.value != this.defaultValue) this.select();
	});
	$('#pass').blur(function() {
  		if ($.trim(this.value) == ''){
			this.type = 'text';
  			this.value = (this.defaultValue ? this.defaultValue : '');
  		}
	});
});

