// globals

var CO = new _CO();
window.onload = function() { CO.onPageLoad(); }

// classdef

function _CO()
{
	this._aImages = new Array();
	
	this.onPageLoad = _CO_onPageLoad;
	this.onPageLoad_Add = _CO_onPageLoad_Add;

	this.initImages = _CO_initImages;
	this.rollImage = _CO_rollImage;
	
	this.isOnIE4 = _CO_isOnIE4;
	
	this.playVideo = _CO_playVideo;
	this.clickToCall = _CO_clickToCall;
}

function _CO_onPageLoad()
{
	if (typeof(OnPageLoad) == "function") OnPageLoad();
	if (this._aOnPageLoadFunc != null) {
		for (var i = 0; i < this._aOnPageLoadFunc.length; i++) {
			var f = this._aOnPageLoadFunc[i];
			if (typeof(f) == "function") f();
		}
	}
}
	
function _CO_onPageLoad_Add(f)
{
	if (this._aOnPageLoadFunc == null) this._aOnPageLoadFunc = new Array();
	this._aOnPageLoadFunc[this._aOnPageLoadFunc.length] = f;
}
	
function _CO_initImages(/*arguments*/)
{
	var j = this._aImages.length;
	for (var i = 0; i < arguments.length; i += 2) {
		var s0 = arguments[i];
		var s1 = arguments[i+1], o1 = new Image(); o1.src = s1;
		this._aImages[j++] = new Array(s0, s1, o1);
	}
}

function _CO_rollImage(t, n)
{
	var sSrc = t.src;
	for (var i = 0; i < this._aImages.length; i++) {
		var a = this._aImages[i], sImg = a[n];
		if (sSrc.indexOf(sImg) == (sSrc.length - sImg.length)) {
			t.src = a[n == 0 ? 1 : 0];
			break;
		}	
	}
}

function _CO_isOnIE4()
{
	return (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
}

function _CO_playVideo(u, b)
{
	var w = window.open("/playvideo.asp?u="+u, "wVideo", "scrollbars=0,menubar=0,width=410,height=310");
	w.focus();
}

function _CO_clickToCall()
{
	var w = window.open("https://prodca.click4talk.com/zt/plink/popup.php?cid=9045&linker=1&referral="+location.href,"_blank","height=380,width=530,left=20,top=20,resizable=no,menubar=0,toolbar=0,status=0");
	w.focus();
}