var InputFields=new function(){this.forms=[];this.textInputs=[];this.selects=[];this.radios=[];this.checkboxes=[];this.textareas=null;this.timeout=null;this.init=function(){var self=InputFields;self.getInputs();self.showBoxes()};this.getInputs=function(){var self=InputFields;$('input').each(function(){var current=this;if(current.id!='undefined'&&current.id!=''){var type=$("#"+current.id).attr('type');if(type!=''&&(type=='text'||type=='password')){self.textInputs.push(current.id);$(current).addClass("dimmed");$(current).bind('focus',function(event){$(event.target).removeClass("dimmed").addClass("highlighted");$(event.target).select()});$(current).bind('blur',function(event){$(event.target).removeClass("highlighted").addClass("dimmed")})}}if($(current).attr("readonly")){$(current).css("backgroundColor","#ddd")}})};this.showBoxes=function(){var self=InputFields;self.initCustomBorders();$(".box").fadeIn("slow");$(".box1").fadeIn("slow");$(".box2").fadeIn("slow");$(".box3").fadeIn("slow");if($(".errors").is(":visible")){var errorsTotalLength=0;$(".errors").find("li").each(function(){errorsTotalLength=errorsTotalLength+$(this).text().length});if(errorsTotalLength>90){$(".errors").find("ul").prepend("<li style=\"float:right;height:0px;width: 40px\"><a id=\"buttonClose\" href=\"\#\" onclick=\"this.blur();\" onmouseout=\"this.blur();\" class=\"button\"><span><b>x</b></span></a></li>");$("#buttonClose").click(function(){$(".errors").fadeOut(1000)})}else{$(".errors").fadeIn('slow').animate({opacity:1.0},2000).fadeOut(1500)}};if($(".error_free").is(":visible")){$(".error_free").fadeIn('slow').animate({opacity:1.0},2000).fadeOut(500)};if($(".exl").is(":visible")){$(".exl").fadeIn('slow').animate({opacity:1.0},2000).fadeOut(500)}};this.createElement=function(element){if(typeof document.createElementNS!='undefined'){return document.createElementNS('http://www.w3.org/1999/xhtml',element)}if(typeof document.createElement!='undefined'){return document.createElement(element)}return false};this.insertTop=function(obj){var self=InputFields;d=self.createElement("div");d.className="bt";d2=self.createElement("div");d.appendChild(d2);obj.insertBefore(d,obj.firstChild)};this.insertBottom=function(obj){var self=InputFields;d=self.createElement("div");d.className="bb";d2=self.createElement("div");d.appendChild(d2);obj.appendChild(d)};this.initCustomBorders=function(){var self=InputFields;var divs=$("div");var cbDivs=[];for(var i=0;i<divs.length;i++){if(/\bcbb\b/.test(divs[i].className))cbDivs[cbDivs.length]=divs[i]}var thediv,outer,i1,i2;for(var i=0;i<cbDivs.length;i++){thediv=cbDivs[i];outer=self.createElement('div');outer.className=thediv.className;outer.className=thediv.className.replace('cbb','cb');thediv.className='i3';thediv.parentNode.replaceChild(outer,thediv);i1=self.createElement('div');i1.className='i1';outer.appendChild(i1);i2=self.createElement('div');i2.className='i2';i1.appendChild(i2);i2.appendChild(thediv);self.insertTop(outer);self.insertBottom(outer)}}};$(document).ready(function(){InputFields.init()});function selectionValidation(index){var subIsNotSelected=false;var mainIsNotSelected=false;var inputIsNotEntered=false;var textareaIsNotEntered=false;$("input[id^='radio-y"+index+"-c']").each(function(subInx){var main=$(this);if($(main).is(":checked")){if($("input[id^='radio-y"+index+"-d"+subInx+"-']").length>0){$("input[id^='radio-y"+index+"-d"+subInx+"-']").each(function(opInx){var sub=$(this);if(!$(sub).is(":checked")){if(!$("#radio-n"+index+"-d"+subInx+"-"+opInx).is(":checked")){subIsNotSelected=true}}})}}else if(!$(main).is(":checked")){if(!$("#radio-n"+index+"-c"+subInx).is(":checked")){mainIsNotSelected=true}}});if($.trim($("#input"+index).val()).length==0){inputIsNotEntered=true};if($.trim($("#textarea"+index).val()).length==0){textareaIsNotEntered=true};if(subIsNotSelected){alert("All sub questions must be selected!")}else if(mainIsNotSelected){alert("All main questions must be selected!")}else if(inputIsNotEntered){alert("Last question must be answered!")}else if(textareaIsNotEntered){alert("Comments must be provided")}else{eval("document.questionsForm"+index+".submit()")}};