/**
 * @author Ramalingesha ML
 */
Tp.ui.view.candidate.ResumeView = Class
		.create( {

			/**
			 * default constructor
			 * 
			 * @param resumeConfig { }
			 * 
			 */
			initialize : function(resumeConfig, handlers) {
				Ext.QuickTips.init();
				this.config = resumeConfig;
				this.handlers = handlers;
				this.details = resumeConfig.data;
				if (this.details != null) {
					this.gender = this.details.gender;
				} else {
					this.gender = " ";
				}

				this.initView();

			},

			isNotEmpty : function(obj) {
				if (obj != null && obj.length > 0) {
					return false;
				}
				return true;
			},

			initView : function() {
				var path;
				var candidatePhoto;
				if (this.config.photo) {
					path = this.config.photo;
				} else {
					path = this.config.data.photo;
				}
				
				if (path == 'null' || !path || path == null || path == '') {
					candidatePhoto = "images/icon_man.gif";
					if (this.gender.match("Female")) {
						candidatePhoto = "images/icon_women.gif";
					}
				} else {
					candidatePhoto = "imageDownload?name=" + path;
				}

				var localObject = this;
				var contactDetails;
				if (this.config.roleId != 5) {
					contactDetails = this.config.data.address
				} else {
					contactDetails = []
				}
				var Education;

				if (this.config.data.educationDetails == '') {
					Education = ''
				} else {
					Education = '<span class="resume-header">Education</span>'
				}
				var WorkExperience;
				if (this.config.data.workExpDetails == '') {
					WorkExperience = ''
				} else {
					WorkExperience = '<span class="resume-header">Work Experience</span>'
				}
				var Internship;
                
				if (this.config.data.internshipDetails == '') {
					Internship = ''
				} else {
					Internship = '<span class="resume-header">Summer Internship/Training</span>'
				}
				var contract;				
				if (this.config.data.contractDetails == '') {
					contract = ''
				} else {
					contract = '<span class="resume-header">Contract</span>'
				}
				var LiveProjects;
				if (this.config.data.liveProjectDetails == '') {
					LiveProjects = ''
				} else {
					LiveProjects = '<span class="resume-header">Live Projects</span>'
				}
				var Certification;
				if (this.config.data.certDetails == '') {
					Certification = ''
				} else {
					Certification = '<span class="resume-header">Certification</span>'
				}
				var projectDetails;
				if (this.config.data.projectDetails == '') {
					projectDetails = ''
				} else {
					projectDetails = '<span class="resume-header">Academic Projects</span>'
				}
				this.candidateRegForm = new Ext.FormPanel(
						{
							padding :'10px',
							autoHeight :false,
							autoScroll :true,
							width :750,
							height :450,
							frame :true,
							layout :'anchor',
							id :'resumeForm',
							cls :'resume-form',
							items : [
									{
										layout :'column',
										cls :'resumeHead',
										items : [
												{
													columnWidth :.75,
													layout :'form',
													items : [ {
														html :'<div class="resumeName">'
																+ this.config.data.name
																+ '</div> <div><b>Age: </b>'
																+ this.config.data.age
																+ ', '
																+ this.config.data.gender
																+ '<br>'
																+ contactDetails
																//+ '</br>'
																+ '</div>'
													} ]
												}, {
													columnWidth :.25,
													layout :'form',
													cls :'resumeAdd',
													items : [ {
														xtype :'box',
														cls :'faceIcon',
														height :108,
														width :85,
														autoEl : {
															tag :'img',
															// src
															// :this.genderIcon
															src :candidatePhoto

														}

													} ]
												} ]

									},
									// Education Details
									{
										html :Education
									},
									{
										html :this.config.data.educationDetails
									},
									// Work Experience Details
									{
										html :WorkExperience
									},
									{
										html :this.config.data.workExpDetails
									},
									// Summer Internship/Training
									{
										html :Internship
									},
									{
										html :this.config.data.internshipDetails
									},
									{
										html :contract
									},
									{
										html :this.config.data.contractDetails
									},
									// Live Projects
									{
										html :LiveProjects
									},
									{
										html :this.config.data.liveProjectDetails
									},
									// Technical Skills
									{
										html :this.config.data.technicalSkills
									},
									// Certification
									{
										html :Certification
									},
									{
										html :this.config.data.certDetails
									},
									// Academic Achievements
									{
										html :this.config.data.accademicAchievements
									},
									// Academic Projects
									{
										html :projectDetails
									},
									{
										html :this.config.data.projectDetails
									},
									// Positions of responsibility
									{
										html :this.config.data.positionsOfResponsibility
									},
									// Co-curricular Achievements/Participation
									{
										html :this.config.data.coCuricularAchievements
									},
									// Extracurricular
									// Achievements/Participation
									{
										html :this.config.data.extAchievements
									},
									// Seminars
									{
										html :this.config.data.seminars
									},
									// Strengths/Behavior
									{
										html :this.config.data.strengths
									},
									// Strengths/Behavior
									{
										html :this.config.data.otherInformation
									},{
										html : this.config.data.footer
									} ]
							/*buttons : [ {
								text :'Print',
								handler : function() {
								var fromDivContents = document.getElementById('resumeView');
								var toDivContents = document.getElementById('printContent');
								toDivContents.innerHTML = fromDivContents.innerHTML;
								toDivContents.style.display='block';
								document.write(data);
								window.print();
								try{
									var oIframe = document.getElementById('printFrame');
									var oContent = document.getElementById('divToPrint').innerHTML;
									var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
									if (oDoc.document) oDoc = oDoc.document;
									oDoc.write("<head><title>title</title>");
									oDoc.write("</head><body onload='this.focus();this.print();'>");
									oDoc.write(oContent + "</body>");
									oDoc.close();
									}
									catch(e){
									self.print();
									}
									
									*//**
									 * Prints the contents of an Ext.Panel
									 *//*
									Ext.ux.Printer.PanelRenderer = Ext
											.extend(
													Ext.ux.Printer.BaseRenderer,
													{
														*//**
														 * Generates the HTML
														 * fragment that will be
														 * rendered inside the
														 * <html> element of the
														 * printing window
														 *//*
														generateBody : function(
																panel) {
														
															return String
																	.format(
																			"<div class='x-panel-print'>{0}</div>",
																			panel.body.dom.innerHTML);
														}
													});

									Ext.ux.Printer.registerRenderer('panel',
											Ext.ux.Printer.PanelRenderer);

									//Ext.ux.Printer
											.print(localObject.candidateRegForm);
									

								}
							} ]*/
						});

				if (document.getElementById("voicePanelApplet") != null) {
					document.getElementById("voicePanelApplet").style.visibility = "hidden";
				}

				this.resumePanel = new Ext.Window(
						{

							width :765,
							autoScroll :false,
							autoHeight :true,
							id :'resumeView',
							cls :'resume-view',
							title :'Resume Details',
							modal :true,
							stateful :false,
							closable :true,
							loadMask :true,
							maximizable :false,
							draggable :false,
							resizable :false,
							listeners : {
								'close' : function() {
									if (document
											.getElementById("voicePanelApplet") != null) {
										document
												.getElementById("voicePanelApplet").style.visibility = "visible";
									}
								}
							},
							items : [ this.candidateRegForm ]
						});
				this.resumePanel.show();
			},
			
			getView : function() {
				return this.candidateRegForm;
			}

		});
