/**	
*	@ author		Kheygetyan Ivan
*	@ date		04-02-2007 1:11 AM
*	@ version	1.0.0
**/
var count;
var timer;
var nn4 = (document.layers)? true : false;
var dom = (document.getElementById)? true : false;
var ie4 = (document.all && !dom)? true : false;

createFade = function(uid, tO) {
	if (!tO) {var tO = 0;}
	
	var boxParent = getObj('smallBasket');
	var lb = getObj('msg');
	if (lb != null) {
		boxParent.removeChild(lb);
		bild(boxParent, uid, tO);
	}
	else {
		bild(boxParent, uid, tO);
	}
}

bild = function(boxParent, uid, tO) {
	if(boxParent.style.display='none') {boxParent.style.display='block'}
	var msg = document.createElement("div");
	msg.setAttribute('id', 'msg');
	boxParent.appendChild(msg);
	var box = getObj('msg');
	box.style.display = 'none';
	box.style.position = 'absolute';
	box.style.top = '0px';
	box.style.left = '0px';
	box.style.width = '180px';
	box.style.height = '10px';
	box.innerHTML = '<table width="199" cellpadding="0" cellspacing="0" style="background:url(/imgs/smallBasket.gif) bottom left no-repeat;"><tr valign="top"><td height="67"><div><img alt="" src="/imgs/clear.gif" width="66" height="66" class="pngBg" style="margin-left:9px;" /></div></td><td><div style="padding:33px 15px 0px 5px;"><img alt="" src="/imgs/backet/backet_title.gif" width="96" height="17" /></div></td></tr><tr valign="top"><td colspan="2" height="76" id="basket_div3" style="padding:10px 5px 10px 15px;font-size:90%;"><span id="price_caption3"><strong style="font-size:140%;">&nbsp;</strong></span><span id="price_value3"></span></td></tr></table>';
	fade(box, uid, tO);
}

fade = function(box, uid, tO) {
	var cX = parseFloat(objX('orderControl_' + uid) - 208);
	var cY = parseFloat(objY('orderControl_' + uid) - 60);
	fadePlay(box, cX, cY, tO);
}


/* */
createFadeItem = function(uid, tO) {
	if (!tO) {var tO = 0;}
	
	var boxParent = getObj('smallBasket');
	var lb = getObj('msg');
	if (lb != null) {
		boxParent.removeChild(lb);
		bildItem(boxParent, uid, tO);
	}
	else {
		bildItem(boxParent, uid, tO);
	}
}

bildItem = function(boxParent, uid, tO) {
	if(boxParent.style.display='none') {boxParent.style.display='block'}
	var msg = document.createElement("div");
	msg.setAttribute('id', 'msg');
	boxParent.appendChild(msg);
	var box = getObj('msg');
	box.style.display = 'none';
	box.style.position = 'absolute';
	box.style.top = '0px';
	box.style.left = '0px';
	box.style.width = '180px';
	box.style.height = '10px';
	box.innerHTML = '<table width="199" cellpadding="0" cellspacing="0" style="background:url(/imgs/smallBasket.gif) bottom left no-repeat;"><tr valign="top"><td height="67"><div><img alt="" src="/imgs/clear.gif" width="66" height="66" class="pngBg" style="margin-left:9px;" /></div></td><td><div style="padding:33px 15px 0px 5px;"><img alt="" src="/imgs/backet/backet_title.gif" width="96" height="17" /></div></td></tr><tr valign="top"><td colspan="2" height="76" id="basket_div3" style="padding:10px 5px 10px 15px;font-size:90%;"><span id="price_caption3"><strong style="font-size:140%;">&nbsp;</strong></span><span id="price_value3"></span></td></tr></table>';
	fadeItem(box, uid, tO);
}

fadeItem = function(box, uid, tO) {
	var cX = parseFloat(objX('orderControl_' + uid) - 270);
	var cY = parseFloat(objY('orderControl_' + uid) - 60);
	fadePlay(box, cX, cY, tO);
}
/* */

fadePlay = function(box, cX, cY, tO) {
	box.style.left = cX;
	box.style.top = cY;
	box.style.display = 'block';
	box.style.zIndex = '888';
	fadeIn(box, 0, tO);
}

fadeIn = function(box, count, tO) {
	count = parseFloat(count + 100);
	setOpacity(box, count);
	timer = setTimeout(function(){fadeIn(box, count)}, 1);
	
	if (tO == 1) {
		UpdateWholePriceOnlyLite(2);
	}
	else {
		UpdateWholePriceOnlyLite(0);
	}
	
	if (count==100) {
		clearTimeout(timer);
		setTimeout(function() {fadeOut(box, 100, tO)}, 1500);
	}
}

fadeOut = function(box, count) {
	count = parseFloat(count - 5);
	setOpacity(box, count);
	timer = setTimeout(function(){fadeOut(box, count)}, 1);
	if (count==0) {
		clearTimeout(timer);
		box.style.display = 'none';
	}
}

/* сеттер прозрачности */
setOpacity = function(box, value) {
  if (navigator.userAgent.indexOf("Firefox") != -1) {
    if (value == 100) { value = 99.999; }
  }
  box.style.filter = "alpha(opacity=" + value + ")"; // IE/Win
  box.style.KhtmlOpacity = (value / 100);            // Safari 1.1 or lower, Konqueror
  box.style.MozOpacity = (value / 100);              // Older Mozilla+Firefox
  box.style.opacity = (value / 100);                 // Safari 1.2, Firefox+Mozilla
}
/* геттер y-координаты */
objY = function(uid) {
	if (nn4) {return document.layers[uid].pageY;} else {
		var element = (dom)? document.getElementById(uid) : document.all[uid];
		var coordsY = element.offsetTop;
		while (element.offsetParent != null) {
			element = element.offsetParent;
			coordsY += element.offsetTop;
			if (element.tagName == 'BODY') break;
		} return coordsY;
	}
}
/* геттер x-координаты */
objX = function(uid) {
	if (nn4) {
		return document.layers[uid].pageX;
	} else {
		var element = (dom)? document.getElementById(uid) : document.all[uid];
		var coordsX = element.offsetLeft;
		while (element.offsetParent != null) {
			element = element.offsetParent;
			coordsX += element.offsetLeft;
			if (element.tagName == 'BODY') break;
		} return coordsX;
	}
}
/* геттер объекта */
getObj = function(uid) {
	return element = (dom) ? document.getElementById(uid) : document.all[uid];
}




/* Подсветка инпута */
fadeInput = function(box, count, color) {
	count = parseFloat(count + 100);
	setOpacity(box, count);
	timer = setTimeout(function(){fadeOutInput(box, count, color)}, 10);
	if (count==100) {
		clearTimeout(timer);
		setTimeout(function() {fadeOut2(box, count, color)}, 600);
	}
}

fadeOut2 = function(box, count, color) {
	count = parseFloat(count - 50);
	setOpacity(box, count);
	timer = setTimeout(function(){fadeOut2(box, count, color)}, 1);
	if (count==0) {
		clearTimeout(timer);
		setOpacity(box, 100);
		box.style.border = "1px solid " + color;
		box.style.backgroundColor = "#FFFFFF";
		box.style.color = "#000000";
	}
}



/* Phone Box */
helperBox = function(uid, text) {
	document.getElementById('helperLink').style.display='none';
	var x = 0;
	var nua=navigator.userAgent.toLowerCase();
	if (nua.indexOf('msie') !=-1) {
		if(!cursor) var cursor = window.event;
		x = cursor.clientX + document.body.scrollLeft;
	}
	else {
		x = parseFloat(objX('ob_' + uid) - 58);
	}

	var cX = x;
	var cY = parseFloat(objY('ob_' + uid) - 15);
	var box = getObj('helper');
	
	box.style.position = "absolute";
	box.style.top = cY + "px";
	box.style.left = cX + "px";
	box.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" class=\"boxHelp\" onmouseover=\"ClearAltTimeOut();\" onmouseout=\"HideAlt();\"><tr><td id=\"bh2\" nowrap=\"nowrap\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" id=\"bh3\"><tr><td height=\"30\" id=\"bh4\">Ростов-на-Дону, пр. Буденновский 80,<br>оф. 306<br />тел.: <span>(863) 261-82-71</span></td></tr></table></td></tr></table>";
	box.style.display = 'block'; 
}

var ato = 0;
function ClearAltTimeOut() {
	if (ato != 0 && ato != null) clearTimeout(ato);
	ato = 0;
}

function HideAlt() {
	ato = setTimeout("document.getElementById('helper').style.display='none';",350);
}


/* Email Box */
helperBox2 = function(uid, text) {
	document.getElementById('helper').style.display='none';
	var x = 0;
	var nua=navigator.userAgent.toLowerCase();
	if (nua.indexOf('msie') !=-1) {
		if(!cursor) var cursor = window.event;
		x = cursor.clientX + document.body.scrollLeft;
	}
	else {
		x = parseFloat(objX('ob_' + uid) - 58);
	}

	var cX = x;
	var cY = parseFloat(objY('ob_' + uid) - 15);
	var box = getObj('helperLink');
	
	box.style.position = "absolute";
	box.style.top = cY + "px";
	box.style.left = cX + "px";
	box.style.display = 'block';
	box.style.zIndex = "100";
}

var ato2 = 0;
function ClearAltTimeOut2() {
	if (ato2 != 0 && ato != null) clearTimeout(ato2);
	ato2 = 0;
}

function HideAlt2() {
	ato2 = setTimeout("document.getElementById('helperLink').style.display='none';",350);
}


changeColor = function(obj, rul) {
	var box = getObj(obj);
	if (rul == 1) {
		box.style.backgroundColor='#F9701F';
	}
	else {
		box.style.backgroundColor='#BCBDC1';
	}
}

changeColsColor = function(obj, rul) {
	var box = obj;
	if (rul == 1) {
		box.style.backgroundColor='#F9701F';
	}
	else {
		box.style.backgroundColor='#BCBDC1';
	}
}
