function StatementViewer(type, id){
	var oWindow;
	var sHost = document.location.protocol+"//"+document.location.hostname;
	if(id != ""){
		if(type == "stmt"){
			location.href = sHost + "/Gremlin/Accounts/StatementViewer.aspx?type=" + type + "&id=" + id
//			oWindow = window.open(sHost+"/Gremlin/Accounts/StatementViewer.aspx?type=" + type + "&id=" + id,"Viewer","resizable=1,width=800,height=700;");	
		}		
		else if(type == "zip"){
			oWindow = window.open(sHost+"/Gremlin/Accounts/StatementViewer.aspx?type=" + type + "&id=" + id,"Viewer","resizable=1,width=1,height=1,top=10000;");			
		}	
	}	
}	

function documentViewer(type, docid){
	if (docid == "") return;

	var sHost = document.location.protocol + "//" + document.location.hostname;

	if(type == "stmt"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=stmt&rid=" + docid;
	}else if(type == "pers"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=stmt&fid=" + docid;
	}else if(type == "zipstmt"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=zip&rid=" + docid;
	}else if(type == "zippers"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=zip&fid=" + docid;
	}else if(type == "ext"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=stmt&exid=" + docid;
	}else if(type == "zipext"){
		location.href = sHost + "/Gremlin/Accounts/DocumentViewer.aspx?type=zip&exid=" + docid;
	}
}//documentViewer	

function SelectAll(obj,name){
	if(obj.checked){
		SelectCheckbox(name,true);		
	}else{
		SelectCheckbox(name,false);			
	}	
}	
function SelectCheckbox(name,selected){
	for(var i = 0; i < document.forms[0].elements.length; i++){		
		var elm = document.forms[0].elements[i];
		if(elm.type == "checkbox"){	
			var elmID = elm.id;
			if(elmID.indexOf(name) != -1){					
				elm.checked = selected;		
			}
		}	
	}
}
function SelectHeader(obj){
	obj.checked = false;	
}

function DownloadZip(name){
	var files = "";	
	var download = false;	
	for(var i = 0; i < document.forms[0].elements.length; i++){		
		var elm = document.forms[0].elements[i];
		if(elm.type == "checkbox"){	
			var elmID = elm.id;
			if(elmID.indexOf(name) != -1){
				if(elm.checked){
					var elmStmt = elm.value;
					var aSplit = elmStmt.split("|");
									
					if(aSplit[0] != ""){
						files += aSplit[0] + "|";
					}
					if(name != "PersonalC"){
					if(aSplit[1] != ""){
						files += aSplit[1] + "|";
					}
					if(aSplit.length == 3){					
						if(aSplit[2] != ""){
							files += aSplit[2] + "|";
						}
					}
					}						
					if(files == ""){
						download = false;	
					}else{
						download = true;	
					}														
				}						
			}
		}				
	}	
	
	if(download){
		StatementViewer('zip',files);			
	}else{
		alert("You must have at least one statement selected to continue.");
	}	
	
}

function DownloadStatementsZip(name){
	var files = "";	
	var download = false;	
	for(var i = 0; i < document.forms[0].elements.length; i++){		
		var elm = document.forms[0].elements[i];
		if(elm.type == "checkbox"){	
			var elmID = elm.id;
			if(elmID.indexOf(name) != -1){
				if(elm.checked){
					var elmStmt = elm.value;
					var aSplit = elmStmt.split("|");
									
					if(aSplit[0] != ""){
						files += aSplit[0] + "|";
					}
					if(name != "PersonalC"){
					if(aSplit[1] != ""){
						files += aSplit[1] + "|";
					}
					if(aSplit.length == 3){					
						if(aSplit[2] != ""){
							files += aSplit[2] + "|";
						}
					}
					}						
					if(files == ""){
						download = false;	
					}else{
						download = true;	
					}														
				}						
			}
		}				
	}	
	
	if(download){
		documentViewer('zipstmt', files);			
	}else{
		alert("You must have at least one statement selected to continue.");
	}	
}