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

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

function openSupportWindow(u){
    u=u||'out/?id=live_support_url';
    if(!ods.support_window || ods.support_window.closed){
        ods.support_window=popItUp(u,'support_window',500,560);
    }else{
        ods.support_window.focus();
    }
}

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
} 
