if (typeof vcc != "object")
	vcc = new Object();

vcc.win = (navigator.userAgent.toLowerCase().indexOf("win") > -1);
vcc.mac = (navigator.userAgent.toLowerCase().indexOf("mac") > -1);
vcc.ie = (navigator.userAgent.indexOf("MSIE") > -1);
vcc.w3c = (document.getElementById && !vcc.ie);
vcc.opera = (navigator.userAgent.toLowerCase().indexOf("opera") > -1);
if (vcc.ie) vcc.version = parseFloat(navigator.appVersion.match(/MSIE\s(\d+\.\d+)/)[1]);
else if(vcc.w3c) vcc.version = parseFloat(navigator.userAgent.match(/[\d\.]+$/)[0]);

vcc.getObj = function(strLayer) {
	if(typeof(strLayer) == "object") return strLayer;
	var elmLayer = document.getElementById(strLayer);
	if (!elmLayer)
		elmLayer = document.getElementsByName(strLayer)[0];
	return elmLayer;
}

vcc.show = function() {
	for (var i=0; i<vcc.show.arguments.length; i++) {
		if ((elmLayer=vcc.getObj(vcc.show.arguments[i])))
			elmLayer.style.visibility = "visible";
	}
}

vcc.hide = function() {
	for (var i=0; i<vcc.hide.arguments.length; i++) {
		if ((elmLayer=vcc.getObj(vcc.hide.arguments[i])))
			elmLayer.style.visibility = "hidden";
	}
}

vcc.getX = function(strLayer,blnGlobal) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	var currentX = elmLayer.offsetLeft;
	if (blnGlobal) {
		while (elmLayer.offsetParent) {
			elmLayer = elmLayer.offsetParent;
			currentX += elmLayer.offsetLeft;
		}
	}
	return currentX;
}

vcc.getY = function(strLayer,blnGlobal) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	var currentY = elmLayer.offsetTop;
	if (blnGlobal) {
		while (elmLayer.offsetParent) {
			elmLayer = elmLayer.offsetParent;
			currentY += elmLayer.offsetTop;
		}
	}
	return currentY;
}

vcc.getW = function(strLayer) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	if (window.getComputedStyle) {
		var style=getComputedStyle(elmLayer, null);
		return parseInt(style.getPropertyValue('width'));
	}
	else if (elmLayer.style.pixelWidth)
		return elmLayer.style.pixelWidth;
	else if(elmLayer.offsetWidth)
		return elmLayer.offsetWidth;
}

vcc.getH = function(strLayer) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	if (window.getComputedStyle) {
		var style=getComputedStyle(elmLayer, null);
		return parseInt(style.getPropertyValue('height'));
	}
	else if (elmLayer.style.pixelHeight)
		return elmLayer.style.pixelHeight;
	else if(elmLayer.offsetHeight)
		return elmLayer.offsetHeight;
}

vcc.getScrollW = function(strLayer) {
	if (!(elmLayer=vcc.getObj(strLayer))) return false;
	if (vcc.ie)
		return (vcc.mac) ? elmLayer.offsetWidth : elmLayer.scrollWidth;
	else if(vcc.w3c)
		return elmLayer.offsetWidth;
}

vcc.moveTo = function(strLayer, x, y) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	if (x || x==0) elmLayer.style.left = x + "px";
	if (y || y==0) elmLayer.style.top = y + "px";
}

vcc.moveBy = function(strLayer, x, y) {
	vcc.moveTo(strLayer, vcc.getX(strLayer) + x, vcc.getY(strLayer) + y);
}

vcc.clip = function(strLayer,t,r,b,l) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	elmLayer.style.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)";
}

vcc.clipBy = function(strLayer,dt,dr,db,dl){
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	var c=elmLayer.style.clip.substr(5);
	c=c.substr(0,c.length-3).split("p");
	c[1] = c[1].substr(2);
	c[2] = c[2].substr(2);
	c[3] = c[3].substr(2);
	var t=dt+(c[0]*1);
	var r=dr+(c[1]*1)+dl;
	var b=db+(c[2]*1)+dt;
	var l=dl+(c[3]*1);
	elmLayer.style.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
}
vcc.overlap = function(obj1,obj2) {
	var objFirst = { x: vcc.getX(obj1,true), y: vcc.getY(obj1,true), width: obj1.offsetWidth, height: obj1.offsetHeight }
	var objSecond = { x: vcc.getX(obj2,true), y: vcc.getY(obj2,true), width: obj2.offsetWidth, height: obj2.offsetHeight }
	var xOverlap = true;
	var yOverlap = true;
	
	if (objFirst.x < objSecond.x) {
		xOverlap = (objFirst.x + objFirst.width > objSecond.x) ? true: false;
	} else {
		xOverlap = (objSecond.x + objSecond.width > objFirst.x) ? true: false;
	}
	if (objFirst.y < objSecond.y) {
		yOverlap = (objFirst.y + objFirst.height > objSecond.y) ? true: false;
	} else {
		yOverlap = (objSecond.y + objSecond.height > objFirst.y) ? true: false;
	}
	return (xOverlap && yOverlap) ? true: false;
}

vcc.preload = function(strName, strSrc, blnDoNotPreload) {
	if(blnDoNotPreload) eval(strName + " = new Object();");
	else eval(strName + " = new Image();");
	eval(strName+".src = '"+strSrc+"';");
}


vcc.swapImage = function(strTarget, strNewPic, urlNewPic){
	var objImage=vcc.getObj(strTarget);
	if(objImage){
		if(strNewPic && eval("typeof(" + strNewPic +  ")") == "object")
			objImage.src=eval(strNewPic+".src");
		else if (urlNewPic)
			objImage.src = urlNewPic;
	}
}

vcc.setOpacity = function(strLayer, intValue) {
	var objLayer=vcc.getObj(strLayer)
	if(objLayer) {
		objLayer.style.filter = "alpha(opacity=" + intValue + ")";
	}
}

vcc.getDocumentWidth = function(blnContent) {
	var w
	if (window.innerWidth) // Mozilla
		w = (blnContent) ? document.documentElement.offsetWidth : window.innerWidth
	else // IE
		w = (blnContent) ? document.body.scrollWidth : document.body.clientWidth
	return w
}

vcc.getDocumentHeight = function(blnContent) {
	var w
	if (window.innerHeight) // Mozilla
		w = (blnContent) ? document.documentElement.offsetHeight : window.innerHeight
	else // IE
		w = (blnContent) ? document.body.scrollHeight : document.body.clientHeight
	return w
}


vcc.addEvent = function(strLayer, strEvent, strFunction) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	if (elmLayer.addEventListener) {
		elmLayer.addEventListener(strEvent, eval(strFunction), false);
	} else if (elmLayer.attachEvent) {
		elmLayer.attachEvent("on" + strEvent, eval(strFunction));
	} else { // For browsers that don't have any of the addEventListener or attachEvent methods, we create a attachEvent method (NN4.x and IE 5.x on Mac)
		if (!eval("elmLayer.addedEventFunctions_" + strEvent))
			eval("elmLayer.addedEventFunctions_" + strEvent + " = ''");
		eval("elmLayer.addedEventFunctions_" + strEvent + " += '" + strFunction + "(); '");
		eval("elmLayer.on" + strEvent + " = new Function('" + eval("elmLayer.addedEventFunctions_" + strEvent) + "')");
	}
}

// The attachEvent method does not exist on IE 5.x on Mac (or NN 4.x...), so we have to create it
/*vcc.createAttachEventMethod = function(strLayer, strEvent, strFunction) {
	if (!(elmLayer=vcc.getObj(strLayer)))
		return false;
	if (!eval("elmLayer.addedEventFunctions_" + strEvent))
		eval("elmLayer.addedEventFunctions_" + strEvent + " = ''");
	eval("elmLayer.addedEventFunctions_" + strEvent + " += '" + strFunction + "(); '");
	eval("elmLayer.on" + strEvent + " = new Function('" + eval("elmLayer.addedEventFunctions_" + strEvent) + "')");
}*/

vcc.getElementsByClassName = function (strClassName, strTagName, elmLayer) {
	strTagName = strTagName || "*";
	elmLayer = elmLayer || document;
	var arAllElements = elmLayer.getElementsByTagName(strTagName);
	var arElements = [];
	for (var i=0; i<arAllElements.length; i++) {
		if (arAllElements[i].className == strClassName)
			arElements[arElements.length] = arAllElements[i];
	}
	return arElements.slice(0);
}

vcc.openWindow = function(strURL,strName,strOptions) {
	if (!strOptions) strOptions = "location=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,";
	else {
		//parse the strOptions variable to get width and height
		var arWidth = strOptions.match(/width=[0-9]+/i);
		var arHeight = strOptions.match(/height=[0-9]+/i);
		if (arWidth != null) {
			//Center window horizontally
			var intWidth = arWidth[0].substring(arWidth[0].lastIndexOf("=") + 1);
			var x = (screen.width - intWidth) / 2;
			x = (x<0) ? 0 : x
			strOptions += ",left=" + x;
		}
		if (arHeight != null) {
			//Center window vertically
			var intHeight = arHeight[0].substring(arHeight[0].lastIndexOf("=") + 1);
			var y = (screen.height - intHeight) / 2;
			y = (y<0) ? 0 : y
			strOptions += ",top=" + y;
		}
	}
	var popup = window.open(strURL,strName,strOptions);
}

vcc.getQS = function(strWhich){
	var re = new RegExp( "[&\?]"+strWhich+"=([^&]*)&?", "i" );
	re.exec(window.location.href);
	return RegExp.$1;
}

// Returns the named attribute from an XML node.
vcc.getXmlNodeAttribute = function(elmNode, strAttribute) {
	var arAttributes = new Enumerator(elmNode.attributes);
	for (;!arAttributes.atEnd();arAttributes.moveNext()) {
		if (arAttributes.item().name == strAttribute)
			return arAttributes.item().value;
	}
	arAttributes = null;
	return null;
}

vcc.setXmlNodeAttribute = function(elmNode, strAttribute, strValue) {
	var arAttributes = new Enumerator(elmNode.attributes);
	for (;!arAttributes.atEnd();arAttributes.moveNext()) {
		if (arAttributes.item().name == strAttribute)
			arAttributes.item().value = strValue;
	}
	arAttributes = null;
}

if(vcc.ie && !vcc.mac){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('Function VBflashCheck(reqVersion)\n'); 	
	document.write('on error resume next \n');
	document.write('reqInstalled = false \n');
	document.write('for i=reqVersion to 8 \n');
	document.write('isInstalled=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash."&i)) \n');
	document.write('if isInstalled then \n');
	document.write('reqInstalled=true \n');
	document.write('end if \n');
	document.write('next \n');
	document.write('VBflashCheck=reqInstalled \n');
	document.write('End function\n');
	document.write('</SCR' + 'IPT\> \n');
}

vcc.flashCheck = function(intReqVersion){
	if (navigator.plugins){	
		if (navigator.plugins["Shockwave Flash"]){
			var flashDescription = navigator.plugins["Shockwave Flash"].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			return (flashVersion>=intReqVersion) ? true:false
		}
		else if(vcc.ie && !vcc.mac) return VBflashCheck(intReqVersion)
		else return false
	}
	else return false
}
