var site_root = 'http://www.scottishwidows.co.uk/';
var form_confirm_apply = 'Please confirm that you have read the Information about our services document before applying';
var form_confirm_continue = 'Please confirm that you have read the Information about our services document before continuing';
var flash_required = 7;

function swap_class(elementid,classname){
	document.getElementById(elementid).className = classname;
}

function open_window(url, width, height){
	var top = (screen.height - height)/2;
	var left = (screen.width - width)/2;

	str = "";
	str += "resizable=1,titlebar=0,menubar=0,";
	str += "toolbar=0,location=0,directories=0,status=0,";
	str += "scrollbars=0,";
	str += "width=" + width + ",";
	str += "height=" + height + ",";
	str += "top=" + top + ",";
	str += "left=" + left + ",";
	str += "resizable=no";
	
	var popUpPage = window.open(url, name, str);

	popUpPage.focus();
}

function toggle_footer(){
	switch(document.getElementById("footer-container").style.display){
		case "block":
			displaymode = "none";
			image = "contracted";
			break;
		case "none":
			displaymode = "block";
			image = "expanded";
			break;
	}
	document.getElementById("footer-container").style.display = displaymode;
	document.getElementById("footer-title").style.backgroundImage = "url(" + site_root + "images/generic/legal_arrow_" + image + ".gif)";
}

function write_flash_to_screen(movie_path,width,height,vars) {
	var embed_string = '';
	
	embed_string += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="" align="middle" viewastext>';
	embed_string += '<param name="allowScriptAccess" value="sameDomain" />';
	embed_string += '<param name="movie" value="../swb_files/'+movie_path+'?'+vars+'" />';
	embed_string += '<param name="quality" value="high" />';
	embed_string += '<param name="scale" value="noscale" />';
	embed_string += '<param name="salign" value="t" />';
	embed_string += '<embed src="../swb_files/'+movie_path+'?'+vars+'" scale="noscale" salign="t" quality="high" width="'+width+'" height="'+height+'" name="" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	embed_string += '</object>';
	
	return embed_string;
}

function render_flash(){
	//array elements
	//0: flash movie path
	//1: movie width
	//2: movie height
	//3: movie container div
	//4: movie paramaters
	//5: alternative non-flash image
	//6: url for alternative non-flash image
	//7: target for alternative non-flash image
	//8: alt text for alternative non-flash image

	url_supplied = false;
	target_supplied = false;
	if (run_twice){ flash_details = flash_details2; }
	
	if(flash.ver[flash_required]){
		document.getElementById(flash_details[3]).innerHTML = write_flash_to_screen(flash_details[0],flash_details[1],flash_details[2],flash_details[3],flash_details[4],flash_details[5]);
	}
	else{
		if(((typeof(flash_details[5]) != 'undefined') && (flash_details[5]) != null) && (flash_details[5] != 'null') && (flash_details[5] != '')){
			var image_html = '';

			//check for alternative image href
			if(((typeof(flash_details[6]) != 'undefined') && (flash_details[6]) != null) && (flash_details[6] != 'null') && (flash_details[6] != '')){
				image_html += '<a href="' + flash_details[6] + '"';				
				url_supplied = true;
				
				//check for alternative image target
				if(((typeof(flash_details[7]) != 'undefined') && (flash_details[7]) != null) && (flash_details[7] != 'null') && (flash_details[7] != '')){
					image_html += ' target="' + flash_details[7] + '"';
					target_supplied = true;
				}
				
				//check for alternative image alt text
				if(((typeof(flash_details[8]) != 'undefined') && (flash_details[8]) != null) && (flash_details[8] != 'null') && (flash_details[8] != '')){
					image_html += ' title="' + flash_details[8] + '"';
				}				
				
				image_html += '>';			
			}
			
			image_html += '<img src="' + flash_details[5] + '" height="' + flash_details[2] + '" width="' + flash_details[1] + '"';
			
			if(url_supplied || target_supplied){
				image_html += ' border="0"></a>';
			}
			else{
				image_html += '>';
			}
			
			document.getElementById(flash_details[3]).innerHTML = image_html;
		}
		else{
			//if no alternative image has been supplied, display the following message within the flash container div
			document.getElementById(flash_details[3]).innerHTML = '<div class="body-text"><br /><br />You will need to have the Adobe Flash Player installed on your PC in order to view this content.<br /><br />This can be downloaded for free from <a class="pink-link" href="http://www.adobe.com" target="_blank">the Adobe website</a>.<br /><br /></div>';
		}
	}
}