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);
	}
}

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

var psODSrsid;
function initSupportWindow(){
	var src=(location.protocol.indexOf("https")==0?"https://secure.providesupport.com/image":"http://image.providesupport.com")+"/js/rx-partners/safe-standard.js?ps_h=ODSr\u0026ps_t="+new Date().getTime();
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', src);
	document.getElementById('live_support').appendChild(js);
}
function openSupportWindow(){
	if(psODSrsid){
		if(!ods.support_window || ods.support_window.closed){
			ods.support_window=popItUp('http://messenger.providesupport.com/messenger/rx-partners.html?ps_s=' + psODSrsid + '&ps_mht=' + psODSrmht,'support_window',500,560);
		}else{
			ods.support_window.focus();
		}
	}else{
		popItUp('about:blank','support_window',500,560);
		initSupportWindow();
		var timer = setInterval(function(){
			if(psODSrsid){
				clearInterval(timer);
				openSupportWindow();
			}
		}, 5);
	}
}
var imgCodeUrl;
function reloadImageCode(){
	var img=document.getElementById('vcode_img');
	if(!imgCodeUrl) imgCodeUrl=img.src;
	img.src=imgCodeUrl+'?'+Math.random();
}

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 showCertificate(){
	if(!ods.cert_window || ods.cert_window.closed){
		ods.cert_window=popItUp('https://mysecurebilling.com/certificates.php','cert_window',500,350);
	}else{
		ods.cert_window.focus();
	}
}

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

// 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';
	}
}

function popImg(src)
{
	var w=380,h=350,left=(screen.availWidth-w)/2,top=(screen.availHeight-h)/2
	var wnd=window.open("",'blistWind','toolbar=0,location=0,directories=0,menubar=0,resizable,scrollbars=0,width='+w+',height='+h+',top='+top+',left='+left)
	wnd.document.write("<title>Click it to close</title><style>html,body,table{margin:0px;padding:0px;height:100%;width:100%;}</style><body name=body><table><tr><th><img src='"+src+"'></table><script>document.body.onclick=function(){close()}</script></body>")
	wnd.focus()
	return false
} 

