function imgswap(img_name, img_src) {
   document[img_name].src = img_src;
}

/**
 * Appends a JavaScript file to the page.
 * @param {string} url
 */
function pvDdownloadJScript(url, callback) {
  var script = document.createElement('script');
	script.type = "text/javascript";
	if (!callback) {
  	script.src = url;
	} else {
  	script.src = url + '&callback=' + callback;
	}
  document.body.appendChild(script);
	//alert(script.src);
}

function pvClientWidth () {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		return window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return document.body.clientWidth;
	}
}
function pvClientHeight () {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		return window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return document.body.clientHeight;
	}
}
function pvVisibleTop () {
	if (self.pageYOffset){	// all except Explorer
		return self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict{
		return document.documentElement.scrollTop;
	} else if (document.body) { // all other Explorers
		return document.body.scrollTop;
	}
}
function pvLinkOutside (url, pageid, activityid, activaddressid) {
	document.write ('<a href="/linkOutside.php?url=' + url + '&amp;width=' + pvClientWidth() + '&amp;height=' + pvClientHeight() + '&amp;pageid=' + pageid
					+ '&amp;activityid=' + activityid + '&amp;activaddressid=' + activaddressid + '" target="_blank">Website<\/a>');
}

function columnize(cont, elem) {
	unit=$$(cont);
	unit.each( function(u) {
		h3=$A(u.getElementsByClassName(elem)); /* One or several class names, separated by space*/
		var lft=0, rgt=0;
		if (h3) {
			h3.each( function(b) {
				b.removeClassName(elem);
				if (lft <= rgt) {
					b.addClassName(elem + '-L');
					lft += b.getHeight();
				} else {
					b.addClassName(elem + '-R');
					rgt += b.getHeight();
				}
			});
		}
	});
}
Event.observe(window, 'load', function(event) {columnize('.unitblock', 'h3blk');});

function pvEnableSend() {
	if (document.mesForm.acceptCondtions.checked) {
		document.mesForm.SubmitButton.disabled = false;
	} else {
		document.mesForm.SubmitButton.disabled = true;
	}
}
function pvSetAllBoxes(category, checkcategory) {
	var boxes = eval('document.getElementsByName("' + category + '[]")');
	var state = eval('document.mesForm.' + checkcategory + '.checked');
	for ( var i = 0; i < boxes.length; i++) {
		boxes[i].checked = state ;
	}
}
function pvRemoveHtmlSpecialAmpCharacters(wkStr) {
	/*while (wkStr.indexOf('&') != -1 || wkStr.indexOf(';') != -1) {*/
 		wkStr = string.replace(/&[^;]*;/g, ''); /* /g enables "global" matching. When using the replace() method */
	/*}*/
	return string;
}
