var siteScript={videoURL:"",player:null,_init:function(){$('a[rel="external"]').attr("target","_blank");this.videoPlayerInit();solutionLink=document.location.href.replace(/.*\/read\/#/,"");if(solutionLink.length==10){siteScript.loadBrightSolution(solutionLink)}$('input[name="upload_video"]').click(function(a){if(a.currentTarget.value=="Yes"){$("#video_fields").slideDown()}else{$("#video_fields").slideUp()}});$('input[name="upload_photos"]').click(function(a){if(a.currentTarget.value=="Yes"){$("#photo_fields").slideDown()}else{$("#photo_fields").slideUp()}})},videoPlayerInit:function(){if(document.location.href.replace(/.*\/BrightSolutions\/$/,"")==""){flashvars={file:"http://www.youtube.com/watch?v=m5QIZKYf1hc",image:"/BrightSolutions/images/tvspot_still.jpg",frontcolor:"48aa43",lightcolor:"f4d962",backcolor:"f6f6f6",skin:"/BrightSolutions/flash/stijl.swf",stretching:"fill"};if(document.cookie.indexOf("TVSpotSeenOnFirstVisit=true")==-1){flashvars.autostart=true;document.cookie="TVSpotSeenOnFirstVisit=true"}params={allowscriptaccess:"always",allowfullscreen:"true",wmode:"transparent"};attributes={id:"VideoPlayer",name:"VideoPlayer",wmode:"transparent"};swfobject.embedSWF("/BrightSolutions/flash/player.swf","VideoPlayer","600","350","9.0.0","expressInstall.swf",flashvars,params,attributes)}else{flashvars={frontcolor:"48aa43",lightcolor:"f4d962",backcolor:"f6f6f6",skin:"/BrightSolutions/flash/stijl.swf",stretching:"fill"};params={allowscriptaccess:"always",allowfullscreen:"true",wmode:"transparent"};attributes={id:"VideoPlayer",name:"VideoPlayer",wmode:"transparent"};swfobject.embedSWF("/BrightSolutions/flash/player.swf","VideoPlayer","600","350","9.0.0","expressInstall.swf",flashvars,params,attributes)}},playVideo:function(a){$.ajax({type:"POST",url:"/BrightSolutions/xhr/getBrightSolution.php",data:{v:a},success:function(b){$("#AboutVideo").html("<b>"+$("Title",b).text()+"</b><p>"+$("BrightSolution",b).text()+"</p><small>Submitted by: "+$("Name",b).text()+"</small>");$("#ParentID").val(a);siteScript.player.sendEvent("LOAD",$("URL",b).text());siteScript.player.sendEvent("PLAY","true");siteScript.populateComments(b)}})},submitComment:function(a){parentID=$("#ParentID").val();name=$("#"+a+" input[name='name']").val();name_obj=$("#"+a+" input[name='name']");email=$("#"+a+" input[name='email']").val();email_obj=$("#"+a+" input[name='email']");comment=$("#"+a+" textarea[name='comment']").val();comment_obj=$("#"+a+" textarea[name='comment']");receive=$("#"+a+" input[name='receive']:checked").val();receive_obj=$("#"+a+" input[name='receive']:checked");$("#"+a+" .validation").removeClass("validation");if($.trim(name)==""){name_obj.parent().parent().addClass("validation");name_obj.focus();alert("Please enter your name.");return false}else{if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)==false){email_obj.parent().parent().addClass("validation");email_obj.focus();alert("Please enter a valid e-mail address.");return false}else{if($.trim(comment)==""){comment_obj.parent().parent().addClass("validation");comment_obj.focus();alert("Please enter a comment.");return false}}}post={id:parentID,name:name,email:email,receive:receive,comment:comment};$.ajax({type:"POST",url:"/BrightSolutions/xhr/postComment.php",data:post,success:function(c,b){if($("Error",c).length==1){alert($("Error",c).text())}else{if($("Success",c).length==1){document.getElementById(a).getElementsByTagName("form")[0].reset();alert($("Success",c).text())}else{alert("An error has occurred. Please try again shortly.")}}}})},submitBrightSolution:function(){$("#SubmitForm .validation").removeClass("validation");name=$("#SubmitForm input[name='name']").val();name_obj=$("#SubmitForm input[name='name']");email=$("#SubmitForm input[name='email']").val();email_obj=$("#SubmitForm input[name='email']");comment=$("#SubmitForm textarea[name='comment']").val();comment_obj=$("#SubmitForm textarea[name='comment']");upload_video=$("#SubmitForm input[name='upload_video']:checked").val();video_url=$("#SubmitForm input[name='video_url']").val();video_url_obj=$("#SubmitForm input[name='video_url']");video_title=$("#SubmitForm input[name='video_title']").val();video_title_obj=$("#SubmitForm input[name='video_title']");receive=$("#SubmitForm input[name='receive']:checked").val();receive_obj=$("#SubmitForm input[name='receive']:checked");if($.trim(name)==""){name_obj.parent().parent().addClass("validation");name_obj.focus();alert("Please enter your name.");return false}else{if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)==false){email_obj.parent().parent().addClass("validation");email_obj.focus();alert("Please enter a valid e-mail address.");return false}else{if($.trim(comment)==""){comment_obj.parent().parent().addClass("validation");comment_obj.focus();alert("Please enter your Bright Solution.");return false}else{if(upload_video=="Yes"){if(video_url.match(/youtube\.com\/watch\?v=([a-z0-9-_]+)/i)==null){video_url_obj.parent().parent().addClass("validation");video_url_obj.focus();alert("Please enter a valid YouTube Video URL.");return false}else{if($.trim(video_title)==""){video_title_obj.parent().parent().addClass("validation");video_title_obj.focus();alert("Please enter your Video Title.");return false}}}}}}post={name:name,email:email,receive:receive,comment:comment,upload_video:upload_video,video_url:video_url,video_title:video_title};$.ajax({type:"POST",url:"/BrightSolutions/xhr/postBrightSolution.php",data:post,success:function(b,a){if($("Error",b).length==1){alert($("Error",b).text())}else{if($("Success",b).length==1){document.getElementById("SubmitForm").getElementsByTagName("form")[0].reset();$("#video_fields").hide();alert($("Success",b).text())}else{alert("An error has occurred. Please try again shortly.")}}}})},populateComments:function(a){if($("Comment",a).length==0){$("#Comments .comments").html('<div class="comment">No comments have been submitted.</div>')}else{$("#Comments .comments").text("");var b=1;page=1;comment="";commentLimit=5;len=$("Comment",a).length;$("Comment",a).each(function(d,c){if(b==1){if(page==1){comment='<div class="paging page'+page+' active_page">'}else{comment='<div class="paging page'+page+'" style="display: none;">'}page++}if(d+1==len){comment=comment+'<div class="comment last_comment">'}else{comment=comment+'<div class="comment">'}comment=comment+$(c).text()+"<br /><small>By: "+$(c).attr("name")+"</small></div>";if(b==commentLimit||d==len-1){comment=comment+"</div>";$("#Comments .comments").append(comment);b=1}else{b++}})}if($("#Comments .paging").length>1){pages='<div class="paging_links">';pages=pages+'<div class="pageing_count">Page 1 of  '+$("#Comments .paging").length+"</div>";pages=pages+'<div class="pageing_nav">';pages=pages+'<span class="prev" style="display: none;"><a href="#" onclick="siteScript.prevPage(\'Comments\'); return false;">Previous</a></span>';pages=pages+'<span class="next">&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="siteScript.nextPage(\'Comments\'); return false;">Next</a></span>';pages=pages+"</div>";pages=pages+"</div>";$("#Comments .comments").append(pages)}$("#Comments").show()},loadBrightSolution:function(a){$.ajax({type:"POST",url:"/BrightSolutions/xhr/getBrightSolution.php?id="+a,data:{v:a},success:function(b){$("#AboutSolution").html("<p>"+$("BrightSolution",b).text()+"</p><small>Submitted by: "+$("Name",b).text()+"</small>");$("#ParentID").val(a);siteScript.populateComments(b);$("#ThoughtContainer").show()}})},nextPage:function(a){active=$("#"+a+" .active_page");active.hide();active.removeClass("active_page");active.next().show();active.next().addClass("active_page");$("#"+a+" .pageing_count").html("Page "+($("#"+a+" .paging").index($("#"+a+" .active_page"))+1)+" of "+$("#"+a+" .paging").length);if($("#"+a+" .active_page .last_comment").length==1){$("#"+a+" .pageing_nav .next").hide()}if($("#"+a+" .paging").index($("#"+a+" .active_page"))!=0){$("#"+a+" .pageing_nav .prev").show()}},prevPage:function(a){active=$("#"+a+" .active_page");active.hide();active.removeClass("active_page");active.prev().show();active.prev().addClass("active_page");$("#"+a+" .pageing_count").html("Page "+($("#"+a+" .paging").index($("#"+a+" .active_page"))+1)+" of "+$("#"+a+" .paging").length);$("#"+a+" .pageing_nav .next").show();if($("#"+a+" .paging").index($("#"+a+" .active_page"))==0){$("#"+a+" .pageing_nav .prev").hide()}},validateInput:function(a,b){if($.trim($(a).val())==""){$(a).parent().parent().addClass("validation");$(a).focus();alert(b);return false}else{return $(a).val()}}};$(document).ready(function(){siteScript._init()});function playerReady(a){siteScript.player=document.getElementById(a.id);videoLink=document.location.href.replace(/.*\/watch\/#Video/,"");if(videoLink.length==10){siteScript.playVideo(videoLink)}if(siteScript.videoURL!=""){siteScript.player.sendEvent("LOAD",siteScript.videoURL);siteScript.player.sendEvent("PLAY","true")}};