/**********************************************************************/
function getCookie(n) 
{
	var dc = document.cookie;
	var prefix = n + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{   begin = dc.indexOf(prefix);
		if (begin != 0) 
			return null;
	} 
	else
		begin += 2;
		
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

/***********************************************************************/
function setCookie(name,value,days,domain,hrs,mins,secure,httponly)
{
	var expires="",ck="",date=""; ttl="";
	
	if((hrs) || (mins) || (days))
	{
		date = new Date();
		if(days) { ttl = date.getTime()+(days*24*60*60*1000); }
		if(hrs)	 { ttl+= date.getTime()+(hrs*60*60*1000); }
		if(mins) { ttl+= date.getTime()+(mins*60*1000); }
		
		date.setTime(ttl);
		expires = "; expires="+date.toGMTString();
	}
	ck = name+"="+value+expires+"; path=/" + ";domain=" +domain;
	
	if(secure)
		ck += "; secure";
	
	if(httponly)
		ck += "; HttpOnly";
	
	if (days != -1)
		document.cookie = ck;
}


function toggleObject(string)
{
	obj = document.getElementById(string);
	
    if (obj.style.display == "none") 
    {
        showObject(obj,'')
    } else {
        hideObject(obj)
    }
}

// show a section of matching categories (more/fewer)
function showObject(obj,str)
{
	if(!obj) { obj = document.getElementById(str); }
	obj.style.display="";
}

function hideObject(obj,str)
{
	if(!obj) { obj = document.getElementById(str); }
	obj.style.display="none";
}


//------------------------------- stringSplit -------------------------------------------//
function stringSplit(str,del)
{
	if(str == null || str == "")
	{
		return null;
	}
	else if(str.split != null)
	{
		return str.split(del);
	}
	else
	{
		var ar = new Array();
		var i = 0;
		var start = 0;
		
		while(start >= 0 && start < str.length)
		{
			var end = str.indexOf (del,start) ;
			
			if( end >= 0 )
			{
				ar[i++] = str.substring (start,end);
				start = end+1;
			}
			else
			{
				ar[i++] = str.substring (start,str.length);
				start = -1;
			}
		} //end while
		return ar;
	} //end else
} //end function


//-------- form obj ---------------------------
function scan_quans(f)
{
	var flag = false;
	for(n=0; n<f.elements.length; n++)
	{
		if(f.elements[n].name.match(/^quan/))
		{
			if(f.elements[n].value > 0)
			{ flag=true; break; }
		}
	}
	return flag;
}

//-------- form obj, confirm message -----------
function confirm_continue(f,m)
{
	if(scan_quans(f) == false)
	{ var a = confirm(m); return a; }
}



//-------- url, window height, window width -----------
function openWin(url,h,w)
{
	if((h=="") || (typeof(h) =='undefined'))
	{ h=568; }
		
	if((w=="") || (typeof(w) =='undefined'))
	{ w=768; }
		
	var nameW='feature'
	if (navigator.appVersion.indexOf('4') != -1)
	{
		// Vars for centering the new window on Version 4 Browsers
		var xTop = screen.w/2 - (w/2);
		var yTop = screen.h/2 - (h/2);
		var newwindow = window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=yes,resizable=yes,menubar=no,toolbar=no,status=no,left=' + xTop + ',top=' + yTop + '');
	}
	else
	{
		var newwindow = window.open(url, nameW, 'height='+h+',width='+w+',scrollbars=yes,resizable=yes,menubar=no,toolbar=no,status=no,left=150,top=200');
	}
    if (window.focus) { newwindow.focus(); }
}


function fetchPrice(f)
{ f.action=f.cs_action.value; f.r.value=f.cs_request.value; if(f.target != "") { f.target=""; } f.submit(); }


var jx_mc=jQuery.noConflict();
jx_mc(document).ready(function() {
	jx_mc.ajax({
	type: "POST",
	url: "/modperl/wbsrvcs/mini_cart.cgi",
	data:"r=get_cart_info",
	dataType: 'json',
	//timeout: 10000,
	success: function(json) {
		var mc = json.items + ' ITEMS $' + json.subtotal;
		jx_mc("#miniCartView").replaceWith(mc);
	}
	//},
	//error:function(XMLHttpRequest, textStatus, errorThrown) { alert('error loading mini cart icraw4 ' + textStatus + '  ' + errorThrown); }
	});
});

var domain=".overtons.com"; var covrssn="co_onvpg";
if(window.vrx_co_onvpg==undefined) {setCookie(covrssn,'0','',domain,'','-10',1);}

