var jQ,ods={};

jQuery.noConflict();
jQ=jQuery;

if(jQ.browser.msie && jQ.browser.version<7){
	try{document.execCommand('BackgroundImageCache',false,true);}catch(e){};
}
jQ(document).ready(function(){
	setCartEvents();
});
function setCartEvents(){
	var pm=jQ('td.qty i');
	if(pm.length>0)pm.click(chgQty);
}
function chgQty(){
	var i,inp;
	i=jQ(this), inp=i.siblings('input');
	if(i.hasClass('plu')){
		inp.val(Number(inp.val())+1);
	}else if(inp.val()>0){
		inp.val(Number(inp.val())-1);
	}
}


/* --- common utils --- */

var utilVars={projName:'stimul-cash'}, psWWWrsid;
function initSupportWindow(){
	var src=(location.protocol.indexOf("https")==0?"https://secure.providesupport.com/image":"http://image.providesupport.com")+"/js/"+utilVars.projName+"/safe-standard.js?ps_h=WWWr\u0026ps_t="+new Date().getTime();
	var js = document.createElement('script');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', src);
	document.getElementById('live_support').appendChild(js);
}

function openSupportWindow(){ showWindow('support_window','/out/?id=live_support_url',500,560); }

function showCertificate(u){
	u=u||'out/?id=certificates_url';
	showWindow('cert_window',u,500,350);
}
function showSpecialOffer(u){
	u=u||'out/?id=special_offer_url';
	showWindow('spo_window',u,620,620);
}
function showWindow(id,u,w,h){
	if(!utilVars[id] || utilVars[id].closed){
		utilVars[id]=popItUp(u,id,w,h);
	}
	utilVars[id].focus();
}
function popItUp(u,n,w,h){
	var l=(screen.availWidth  - w) / 2, t=(screen.availHeight - h) / 2
	,op='toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+w+',height='+h+',left='+l+',top='+t
	,n=n||'_blank';
	return window.open(u,n,op);
}
function reloadImageCode(){
	var img=document.getElementById('vcode_img');
	if(!utilVars.imgCodeUrl) utilVars.imgCodeUrl=img.src;
	img.src=utilVars.imgCodeUrl+'?'+Math.random();
}
function makeBookmark(){
	var host=document.location.host, u='http://'+host+'/';
	try{
		if (window.sidebar){
		window.sidebar.addPanel(this.title, u, '');
		}else if(document.all){
		window.external.AddFavorite(u, this.title);
		}
	}catch(ex){alert(ex.message)}
	return false;
}

function popImg(u){
	var u=u||'imgs/pills/blisters/'+this.getAttribute('prod')+'.jpg';
	var h='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
	+'<head><title></title>'
	+'<style>html,body,table{margin:0;padding:0;height:100%;width:100%;text-align:center}</style>'
	+'</head><body onclick="close();"><table><tr><td><img src="'+u+'" /></td></tr></table></body></html>';
	var wnd=popItUp('about:blank','img_window',520,520);
	wnd.document.write(h);
	wnd.focus();
	return false;
}


/* ----------------- */

// fixPNG(); http://www.tigir.com/js/fixpng.js (author Tigirlas Igor)
function fixPNG(element){
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
		var src;
		if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "imgs/blank.gif";
			}
		}else{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if (src){
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
		element.className='png1';
	}
}


