// JavaScript Document
var is_IE = 0;
var loaded = 0;
nav  = navigator.userAgent

re = /MSIE/gi
if(nav.match(re)){
	is_IE = 1;
}




var styles = new Array();

styles['default'] = Array({top_back:"images/top_back_default.jpg",backgroundColor:"#32336a",logo:"images/logoanim_small.gif"});
styles['financial'] = Array({top_back:"images/top_back_financial.jpg",backgroundColor:"#8baea2",logo:"images/icon_fin.gif"});
styles['insurance'] = Array({top_back:"images/top_back_insurance.jpg",backgroundColor:"#4f97b9",logo:"images/icon_ins.gif"});
styles['risk'] = Array({top_back:"images/top_back_risk.jpg",backgroundColor:"#9ea374",logo:"images/icon_risk.gif"});

//alert(styles['default'][0]['top_back']);
var images = new Array();
images[0] = "images/header_images.jpg";
images[1] = "images/watson_laurie_logo.gif";


function loadPageStyle(s){
	
	/*items to change
		
		logo_id		// swap logo image
		header  	// change background color & background-image
		left_row	// change background color
		middle_row	// change background color
		right_row	// change background color
		
	
	*/
	
	
	
	if(!s){
		s = "default";
	}
	
	//load style
	backgroundColor = styles[s][0]['backgroundColor'];
	top_back = styles[s][0]['top_back'];
	logo = styles[s][0]['logo'];
	
	
	
	document.getElementById('logo_id').src  = logo;
	document.getElementById('header').style.backgroundColor = backgroundColor;
	document.getElementById('header').style.backgroundImage = "url("+top_back+")";
	document.getElementById('left_row').style.backgroundColor = backgroundColor;
	document.getElementById('middle_row').style.backgroundColor = backgroundColor;
	document.getElementById('right_row').style.backgroundColor = backgroundColor;
	
}


function loadPage(page){
	
	document.getElementById('main_frame').src = "scripts/pages.php?p="+page;
	

}

function faq(){
	
	
	document.getElementById('main_frame').src = "scripts/pages.php?faq";
	
	
}


function loading(){
	
	colors = Array("#4f97b9","#9ea374","#8baea2","#3a6e8f");
	
	
	if(loaded == 0){
		
		if(document.getElementById('loading')){
			
			num = Math.floor(Math.random()*colors.length)
			
			document.getElementById('loading').innerHTML += "<span style='color:"+colors[num]+"'> .</span>";
			
			setTimeout(loading,250);
			
		}
		
	}
	
	
	
}


function askQuestion(){
	
	
	document.getElementById('main_frame').src = "scripts/ask_question.php?edit=new";
	
	
}

function editDetails(id){
	
	document.getElementById('main_frame').src = "scripts/register.php?edit="+id;
	
	
}



function showTable(){
	
		//loadPageStyle();
		
		resizeFrame();
		
		setTimeout(hideLoading,2000);
		
	
	
}
function hideLoading(){
		loaded = 1;
		document.getElementById('loading').style.display="none";
		resizeFrame();
}


var first_run = 1;

function resizeFrame(){
	

	
	
	h = document.body.clientHeight;
	w = document.body.clientWidth;
	
	document.getElementById('left_row').style.width = "200px";
	document.getElementById('right_row').style.width = "200px";
	
	if(Math.abs(w) < 950){
		
		
		
		minw = 700;
		
		if(w > minw){
			document.getElementById('main_table').style.width = (w) + "px";
			document.getElementById('top_row').style.width = (w) + "px";
			document.getElementById('header').style.width = (w) + "px";
			
			document.getElementById('middle_row').style.width = (w-400) + "px";
			
		
		}else{
			
			document.getElementById('main_table').style.width = (minw) + "px";
			document.getElementById('top_row').style.width = (minw) + "px";
			document.getElementById('header').style.width = (minw) + "px"
			
			document.getElementById('middle_row').style.width = (minw-400) + "px";
		}
		
		
		
		
	}else{
		
		document.getElementById('main_table').style.width = (950) + "px";
		document.getElementById('top_row').style.width = (950) + "px";
		document.getElementById('header').style.width = (950) + "px";
			
		document.getElementById('middle_row').style.width = (950-400) + "px";
		
		
		
	}
	
	//alert(w);
	//alert(document.getElementById('middle_row').style.width);
	
	
	
	this_h = h ;
	
	//alert(h)
	//alert(document.getElementById('main_frame').style.height);
	document.getElementById('main_frame').style.height = ((this_h - 160) > 10)?(this_h - 160):10;
	document.getElementById('right_frame').style.height =((this_h - 160) > 10)?(this_h - 160):10;
	document.getElementById('links_frame').style.height = ((this_h - 160) > 10)?(this_h - 160):10;
	
	try{document.main_frame.checkScroll();}catch(e){}
		
	try{document.links_frame.checkScroll();}catch(e){}
	try{document.right_frame.checkScroll();}catch(e){}
	
	if(first_run == 1){
		
		first_run = 0;
		
	}
	
}

function drawLogo(){
	
	//document.getElementById('logo').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="180" height="216" id="logo" align="right"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="logo.swf" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="allowscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ff0000" /><embed src="logo.swf" menu="false" quality="high" scale="allowscale" wmode="transparent" bgcolor="#ff0000" width="180" height="216" name="logo" align="right" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	//document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="180" height="216" id="logo" align="right"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="logo.swf" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="allowscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ff0000" /><embed src="logo.swf" menu="false" quality="high" scale="allowscale" wmode="transparent" bgcolor="#ff0000" width="180" height="216" name="logo" align="right" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
	
	
}








var dis_arr = Array();

function openEditWin(page){
	
			
				if(document.links_frame.document.theForm){
					
						for(i=0;i<document.links_frame.document.theForm.length;i++){
							
							if(document.links_frame.document.theForm[i].disabled == false){
									
									document.links_frame.document.theForm[i].disabled  = true;
									dis_arr.push(document.links_frame.document.theForm[i]);
								
							}
							
						}
				
				}
				
				
				if(document.main_frame.document.theForm){
					
						for(i=0;i<document.main_frame.document.theForm.length;i++){
							
							if(document.main_frame.document.theForm[i].disabled == false){
									
									document.main_frame.document.theForm[i].disabled  = true;
									dis_arr.push(document.main_frame.document.theForm[i]);
								
							}
							
						}
				
				}
				
				
				if(document.right_frame.document.memberForm){
					
						for(i=0;i<document.right_frame.document.memberForm.length;i++){
							
							if(document.right_frame.document.memberForm[i].disabled == false){
									
									document.right_frame.document.memberForm[i].disabled  = true;
									dis_arr.push(document.right_frame.document.memberForm[i]);
								
							}
							
						}
				
				}
				
				
				
				
				
	
				switch(page){
		

					case "page8" : thisPage = document.getElementById('page8');
									docu = "editFrame8";
									pageW =500;
									pageH = 450;
									
									
					break;
					
					
					
				}
			
	
				screenW = document.body.clientWidth;
				screenH = document.body.clientHeight;
				
				
				
				if(screenH < (pageH)){
							
								pageH = screenH - 10;
							
				}
				
							
				
				
				
				
					
				
				leftpos = (screenW - pageW)/ 2;

				toppos = (screenH - pageH)/2;
				
				
				if(leftpos <= 0){
								
					leftpos = 0;
				}
				
				if(toppos <= 0){
								
					toppos = 0;
				}
				
				
				
				
				document.getElementById(docu).style.width = pageW;
				document.getElementById(docu).style.height = pageH;
				thisPage.style.top = toppos;
				
				
				thisPage.style.left = leftpos;
	
					
	
}

function resizePage(page){
	
	
				switch(page){
		

					case "page8" : thisPage = document.getElementById('page8');
									docu = "editFrame8";
									pageW =500;
									pageH = 450;
									
									
					break;
					
					
					
				}
				
				if((document.getElementById(page).style.top != "-2000px")&&(document.getElementById(page).style.top != "")){
	
							screenW = document.body.clientWidth;
							screenH = document.body.clientHeight;
							
							
							if(page == "page8"){
									if(screenH < (pageH)){
									
												pageH = screenH - 10;
												
									}
									document.editFrame8.checkScroll();
							
							}
							
								
							
							leftpos = (screenW - pageW)/ 2;
			
							toppos = (screenH - pageH)/2;
							
							
							if(leftpos <= 0){
											
								leftpos = 10;
							}
							
							if(toppos <= 0){
											
								toppos = 10;
							}
							
							
							
							
							document.getElementById(docu).style.width = pageW;
							document.getElementById(docu).style.height = pageH;
							thisPage.style.top = toppos;
							thisPage.style.left = leftpos;
				
				}
	
	
}






function closePage(page,refreshStr){
				
	
				for(i=0;i<dis_arr.length;i++){
					
					dis_arr[i].disabled = false;
					
				}
				
				dis_arr.length = 0;
				dis_arr = Array();
				
				
				
	
	switch(page){
		

						
		case "page8"  :	document.getElementById('editFrame8').src = ""
						document.getElementById('editFrame8').style.width = "0px";
						document.getElementById('editFrame8').style.height ="0px";
						document.getElementById('page8').style.top = "-2000px";
						document.getElementById('page8').style.left = "-2000px";

						break;
						
		
		
	}
	
	
		
		
	
	
}

