/**
 * Copyright (c) 2004 TeliaSonera AB. All Rights Reserved.
 */
 
/* For webbguide.telia.se */
document.domain="telia.se";
 
/**
 * Run script to automatically display objects
 * embedded to the html page.
 * Requires prototype-library (v.1.4.0)
 */
Event.observe(window,'load',function() {
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObject = theObjects[i];
		matchDocumentProtocol(theObject,'codebase');
		// Fix to display object automatically
		theObject.outerHTML = theObject.outerHTML;
	}},false);

/**
 * Update object attribute to match protocol for
 * document.location - if applicable. 
 * @param {Object} obj
 * @param {Object} attr
 */
function matchDocumentProtocol(obj, attr) {
	if(typeof(obj)!='undefined' && typeof(attr)!='undefined') {
		var _value = obj.getAttribute(attr);
		// Make attribute protocol match document
		// protocol, if applicable
		if(typeof(_value)!='undefined') {
			_protocol = document.location.protocol;
			// Check if we need to switch between http and https
			if(_value.match(/^http:/i) && _protocol.match(/^https:/i)) {
				obj.setAttribute(attr, _value.replace(/http:/i,"https:"));
			} else if (_value.match(/^https:/i) && _protocol.match(/^http:/i)) {
				obj.setAttribute(attr, _value.replace(/https:/i,"http:"));
			} 
		} 
	}
}
