");
}
}
if(params.avatar_num_questions[idx] != 0)
{
//only add the top frame when the browser doesn't support flash
if(!params.avatar_support_flash || !json.flv_exists)
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/avatar_topframe.png", "avatar_topframe"+idx, 438, 46, '', 'class="avatar_img"', '');
}
else
{
//only add the top frame when the browser doesn't support flash
if(!params.avatar_support_flash || !json.flv_exists)
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/avatar_topframe_476x46.png", "avatar_topframe"+idx, 476, 46, '', 'class="avatar_img"', '');
}
$("#avatar_cont"+idx).append("");
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/lowerbar_smartV2.png", "avatar_lowerbarcontainer"+idx, 672, 46, '', 'class="avatar_img"', "avatar_lowerbar"+idx);
//write the IFoundYouThrough from to the document
if(params.avatar_hasSurvey[idx])
{
$("#avatar_cont"+idx).append("
I found you through...
(check all that apply)
");
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/survey/smart_next_form_btmbarV2.png", "avatar_btmBarContainer"+idx,672,16,'','class="avatar_img"',"avatar_formBtmbar"+idx);
}
$("#avatar_cont"+idx).append("");
//Write HTML for scrolling question div if scrolling is enabled, otherwise create non-scrolling div
//-----------------------------------------------------------------
if(params.avatar_num_questions[idx] != 0)
{
if(json.avatar_data[0].scrolling==false)
{
$("#avatar_cont"+idx).append("
Frequently Asked Questions
"+avatar_questions+"
");
}
else
{
$("#avatar_cont"+idx).append("
Frequently Asked Questions
"+avatar_questions+"
");
}
if(question_panel_height == 338)
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/sliderV2.png","avatar_textImage"+idx,246,338, '','class="avatar_img"','');
else
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/slider.png","avatar_textImage"+idx,246,271, '','class="avatar_img"','');
}
if(params.avatar_hasSurvey[idx] && $.smartsite_readCookie(params.avatar_oid+"survey")== null)
{//if the IFoundYouThrough form has not been submitted
if(params.avatar_num_questions[idx] !=0)
{
$("#avatar_cont"+idx).append('
Please take a quick moment to tell me how you found us...
');
}
}
//If click to call is enabled, create a div for it
//-----------------------------------------------------------------
if(params.avatar_db_response[idx].avatar_data[0].click_to_call=="1"){
$('#avatar_cont'+idx).append("");
$("#avatar_avatarcallclosebutton"+idx).css('left',Number(params.avatar_db_response[idx].avatar_data[0].left)+Number(109)+'px');
$("#avatar_avatarcallclosebutton"+idx).css('top', Number(params.avatar_db_response[idx].avatar_data[0].top)+Number(10)+'px');
}
//If avatar is set to show a transcript of the question, create a div for that
//-----------------------------------------------------------------
if(params.avatar_num_questions[idx] != 0 && params.avatar_db_response[idx].avatar_data[0].transcript=="1")
{
$("#avatar_cont"+idx).append("");
$("#avatar_cont"+idx).append("
Transcript
");
//write images for the transcript panel
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/transcript_panel.png", "transcript_image"+idx, 181,241, '','class="avatar_img"', '');
}
//Write images for the bar and panels
//-----------------------------------------------------------------
$.writeImage("http://www.elocallink.tv/zyte/zyte_images/callpanel_reversed.png","calldivback"+idx, 412,57, '','class="avatar_img"',"calldivbackimage"+idx);
//Begin the opening animation
//-----------------------------------------------------------------
$(this).avatar('open',idx);
}
else
{
return;
}
},
//Begin opening the avatar
open:function(idx){
//Calculate the auto center position and refresh HTML element position
//-----------------------------------------------------------------
$.avatar_checkAutoCenter(idx);
$.avatar_refreshDependentPositions(idx);
params.avatar_now_opened=idx;
//If another avatar is opening or closing, cancel the current opening, as the opening/closing animation must finish before any action is taken
//-----------------------------------------------------------------
if(params.avatar_opening==true || params.avatar_closing==true ) return;
//Check to see if opening is allowed
//-----------------------------------------------------------------
try{
if(smartsite_requestPermission()==false)
return;
}
catch(e){}
var avatar_frame = '';
avatar_frame = "";
if(params.avatar_num_questions[idx] == 0)
{
avatar_frame += "";
}
else
{
avatar_frame += "";
}
var initialClip_url = params.avatar_db_response[idx].avatar_data[0].initial_clip;
if(initialClip_url.lastIndexOf('.') == -1)
{
has_ext = false;
}
if(has_ext)
{
initialClip_url = params.avatar_db_response[idx].avatar_data[0].rootdir + initialClip_url.substring(0, initialClip_url.lastIndexOf('.'))+video_extension;
}
else
{
initialClip_url = params.avatar_db_response[idx].avatar_data[0].rootdir + initialClip_url+ clip_suffix[video_extension] +video_extension;
}
var occ_clip1_url = params.avatar_db_response[idx].avatar_data[0].occ_clip1;
if(has_ext)
{
occ_clip1_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip1_url.substring(0, occ_clip1_url.lastIndexOf('.'))+video_extension;
}
else
{
occ_clip1_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip1_url + clip_suffix[video_extension]+video_extension;
}
if(params.avatar_support_flash)
{
//Create the SWF that will play the avatar
//-----------------------------------------------------------------
var so = new SWFObject("http://www.elocallink.tv/zyte/avatarplayer6.swf", "recorder"+idx, "400", "300", "7", "#FFFFFF");
//Add the 'waiting' clips to the SWF's flashvars
//-----------------------------------------------------------------
var waitClip_url = params.avatar_db_response[idx].avatar_data[0].loop_clip1;
if(has_ext)
{
waitClip_url = params.avatar_db_response[idx].avatar_data[0].rootdir + waitClip_url.substring(0, waitClip_url.lastIndexOf('.')) + video_extension;
}
else
{
waitClip_url = params.avatar_db_response[idx].avatar_data[0].rootdir + waitClip_url+ clip_suffix[video_extension] + video_extension;
}
//so.addVariable("waitClip1", waitClip_url.substring(0, waitClip_url.lastIndexOf('.'))+video_extension);
so.addVariable("waitClip1", waitClip_url);
var waitClip2_url = params.avatar_db_response[idx].avatar_data[0].loop_clip2;
if(has_ext)
{
waitClip2_url = params.avatar_db_response[idx].avatar_data[0].rootdir + waitClip2_url.substring(0, waitClip2_url.lastIndexOf('.'))+video_extension;
}
else
{
waitClip2_url = params.avatar_db_response[idx].avatar_data[0].rootdir + waitClip2_url + clip_suffix[video_extension] + video_extension;
}
//so.addVariable("waitClip2", waitClip2_url.substring(0, waitClip2_url.lastIndexOf('.'))+video_extension);
so.addVariable("waitClip2", waitClip2_url);
so.addParam("allowScriptAccess", "always");
//Add the initial clip to the SWF's flashvars
//-----------------------------------------------------------------
if(params.avatar_db_response[idx].avatar_data[0].initial_clip!=""){
if(params.avatar_hasSurvey[idx])
{
if($.smartsite_readCookie(params.avatar_oid+"survey")== null){
so.addVariable("initialClip", initialClip_url);
}
else{
so.addVariable("initialClip", occ_clip1_url);
}
}
else
{
so.addVariable("initialClip", initialClip_url);
}
}
//Add the 'occasional' clips to the SWF's flashvars
//-----------------------------------------------------------------
if(params.avatar_db_response[idx].avatar_data[0].occ_clip1!=""){
so.addVariable("occasionalClip1", occ_clip1_url);
so.addVariable("probability1", params.avatar_db_response[idx].avatar_data[0].occ_prob1);
}
if(params.avatar_db_response[idx].avatar_data[0].occ_clip2!=""){
var occ_clip2_url = params.avatar_db_response[idx].avatar_data[0].occ_clip2;
if(has_ext)
occ_clip2_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip2_url.substring(0, occ_clip2_url.lastIndexOf('.'))+video_extension;
else
occ_clip2_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip2_url + clip_suffix[video_extension] + video_extension;
so.addVariable("occasionalClip2", occ_clip2_url);
so.addVariable("probability2", params.avatar_db_response[idx].avatar_data[0].occ_prob2);
}
if(params.avatar_db_response[idx].avatar_data[0].occ_clip3!=""){
var occ_clip3_url = params.avatar_db_response[idx].avatar_data[0].occ_clip3;
if(has_ext)
occ_clip3_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip3_url.substring(0, occ_clip3_url.lastIndexOf('.'))+video_extension;
else
occ_clip3_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip3_url + clip_suffix[video_extension] + video_extension;
so.addVariable("occasionalClip3", occ_clip3_url);
so.addVariable("probability3", params.avatar_db_response[idx].avatar_data[0].occ_prob3);
}
if(params.avatar_db_response[idx].avatar_data[0].occ_clip4!=""){
var occ_clip4_url = params.avatar_db_response[idx].avatar_data[0].occ_clip4;
if(has_ext)
occ_clip4_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip4_url.substring(0, occ_clip4_url.lastIndexOf('.'))+video_extension;
else
occ_clip4_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip4_url + clip_suffix[video_extension] + video_extension;
so.addVariable("occasionalClip4", occ_clip4_url);
so.addVariable("probability4", params.avatar_db_response[idx].avatar_data[0].occ_prob4);
}
if(params.avatar_db_response[idx].avatar_data[0].occ_clip5!=""){
var occ_clip5_url = params.avatar_db_response[idx].avatar_data[0].occ_clip5;
if(has_ext)
occ_clip5_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip5_url.substring(0, occ_clip5_url.lastIndexOf('.'))+video_extension;
else
occ_clip5_url = params.avatar_db_response[idx].avatar_data[0].rootdir + occ_clip5_url + clip_suffix[video_extension] + video_extension;
so.addVariable("occasionalClip5", occ_clip5_url);
so.addVariable("probability5", params.avatar_db_response[idx].avatar_data[0].occ_prob5);
}
//Set wmode to allow flash to appear over HTML content
//-----------------------------------------------------------------
so.addParam("wmode", "transparent");
//Add the SWF to the page
//-----------------------------------------------------------------
so.write("avatar_avatarvideo"+idx);
$("#avatar_avatarvideo"+idx+" #recorder"+idx).css('display','block').css('position','relative').css('float','left');
if(!params.avatar_db_response[idx].flv_exists)
{
$("#avatar_avatarvideo"+idx).prepend(""+avatar_frame);
if(params.avatar_num_questions[idx] == 0)
{
$("#avatar_avatarvideo"+idx).append("");
//$("#avatar_avatarvideo"+idx+" .avatar_rightframe").css('position','relative').css('top','0px');
}
}
}
else
{
//Create the html5 avatar
//-----------------------------------------------------------------
var screenshot = params.avatar_db_response[idx].avatar_data[0].rootdir+ params.avatar_screenshot[idx];
if(!has_ext)
{
screenshot = screenshot+".jpg";
}
if(params.avatar_db_response[idx].avatar_data[0].initial_clip!=""){
if(params.avatar_num_questions[idx] == 0)
{
var float_text = 'How did you find us?';
var span_width = 176;
}
else
{
var float_text = 'Go ahead! Ask me a question!';
var span_width = 230;
}
if($.smartsite_readCookie(params.avatar_oid+"survey")== null){
$("#avatar_avatarvideo"+idx).append(""+avatar_frame+"
");
if(params.avatar_num_questions[idx] == 0)
{
$("#avatar_avatarvideo"+idx+" .avatar_overlay span").css('display','none');
}
}
var span_to_left = (400 -span_width)/2 + 20;
$("#avatar_avatarvideo"+idx+" .avatar_overlay span").css('left',span_to_left+'px').css('top','200px');
$("#avatar_avatarvideo"+idx+" video").bind('ended',function(){
$("#avatar_avatarvideo"+idx+" .avatar_overlay").css('visibility','visible');
$(this).bind('playing',function(){
$("#avatar_avatarvideo"+idx+" .avatar_overlay").css('visibility','hidden');
});
});
if(params.avatar_num_questions[idx] == 0)
{
//$("#avatar_avatarvideo"+idx+" .ht").css('right','20px');
$("#avatar_avatarvideo"+idx).append("");
}
}
if(isMobile.any())
{
$("#avatar_avatarvideo"+idx+" .avatar_overlay").bind('touchstart',function(e){
$("#avatar_avatarvideo"+idx+" video").bind('playing',function(){
$("#avatar_avatarvideo"+idx+" .avatar_overlay").css('visibility','hidden');
});
$(this).next().trigger('play');
});
}
else
{
$("#avatar_avatarvideo"+idx+" .avatar_overlay img, #avatar_avatarvideo"+idx+" .avatar_overlay span").bind('click',function(e){
$("#avatar_avatarvideo"+idx+" video").bind('playing',function(){
$("#avatar_avatarvideo"+idx+" .avatar_overlay").css('visibility','hidden');
});
$(this).parent().next().trigger('play');
});
}
}
$('#smartsite_avatar'+idx).css('zIndex',9999);
if($('#avatar_avatarvideo'+idx).children().length>0)
{
//$('#avatar_avatarvideo'+idx).children().last().css('width','400px');
//$('#avatar_avatarvideo'+idx).children().last().css('height','300px');
$('#avatar_avatarvideo'+idx).children('video').css('width','400px');
$('#avatar_avatarvideo'+idx).children('video').css('height','300px');
}
//Change the icon
//-----------------------------------------------------------------
$('#avatar_icon_standard'+idx).css("display","none");
$('#avatar_icon_over'+idx).css("display","none");
$('#avatar_icon_close'+idx).css("display","block");
//Lock SmartConnect tools so no other tools can open while the animtion is occurring
//-----------------------------------------------------------------
params.avatar_opening=true;
try{smart_z_lock();}catch(e){}
var lowerbar_topDist = $('#smartsite_avatar'+idx).height()/2-23+'px';
//If sliding out to the left, calculate and begin left slide animation
//-----------------------------------------------------------------
if(params.avatar_db_response[idx].avatar_data[0].direction=="left"){
//write_log('move to left');
$('#avatar_lowerbarcontainer'+idx).css('top',lowerbar_topDist);
$('#avatar_lowerbarcontainer'+idx).css('left','-672px');
$('#avatar_lowerbar'+idx).css('left','672px');
params.avatar_opening_effectobj.MoveEffect(-672, 0, 1, "avatar_lowerbar"+idx, function(){$(this).avatar('movebardown',idx);});
//$("#avatar_lowerbar"+idx).animate({left: '-=672'},1000,'linear',function(){$(this).avatar('movebardown',idx);});
}
else
{
//write_log('move to right');
$('#avatar_lowerbarcontainer'+idx).css('top',lowerbar_topDist);
$('#avatar_lowerbarcontainer'+idx).css('left',$("#smartsite_avatar"+idx).css('width'));
$('#avatar_lowerbar'+idx).css('left','-672px');
params.avatar_opening_effectobj.MoveEffect(672, 0, 1, "avatar_lowerbar"+idx, function(){$(this).avatar('movebardown',idx);});
//$("#avatar_lowerbar"+idx).animate({left: '+=672'},1000,'linear',function(){$(this).avatar('movebardown',idx);});
}
$('#avatar_cont'+idx).css("display","block");
},
//Perform the second stage of the animation, moving the sliding bar into the position that the avatar will appear in
movebardown:function(idx){
//Store the position of the bar at this stage of the animation so it may be returned to when closing
//-----------------------------------------------------------------
params.avatar_initialX[idx]=$('#avatar_lowerbarcontainer'+idx).position().left;
params.avatar_initialY[idx]=$('#avatar_lowerbarcontainer'+idx).position().top;
params.avatar_opening_effectobj.MoveEffect(params.avatar_db_response[idx].avatar_data[0].left-params.avatar_initialX[idx], params.avatar_db_response[idx].avatar_data[0].top-params.avatar_initialY[idx], 1, "avatar_lowerbarcontainer"+idx, function(){$(this).avatar('showpanel',idx)});
//$("#avatar_lowerbarcontainer"+idx).animate({left:'+='+(params.avatar_db_response[idx].avatar_data[0].left-params.avatar_initialX[idx]), top:'+='+(params.avatar_db_response[idx].avatar_data[0].top-params.avatar_initialY[idx])},1000,'linear',function(){$(this).avatar('showpanel',idx);});
},
//Perform the third stage of the animation, sliding the avatar panel out of the bar
showpanel:function(idx){
//Show the avatar panel by sliding it from the bar
//-----------------------------------------------------------------
var leftDist=$('#avatar_lowerbarcontainer'+idx).position().left +8;
var topDist = $('#avatar_lowerbarcontainer'+idx).position().top;
if(params.avatar_num_questions[idx] != 0 && params.avatar_db_response[idx].avatar_data[0].transcript=="1")
{
$('#avatar_transcript'+idx).css('left',leftDist + 140 +'px');
$('#avatar_transcript'+idx).css('top',topDist + 13 + 'px');
}
if($("#avatar_avatarcallclosebutton"+idx).length>0)
$("#avatar_avatarcallclosebutton"+idx).css("display","block");
//$('#avatar_avatarvideo'+idx).css('left',leftDist+'px');
//$('#avatar_avatarvideo'+idx).css('top',topDist + 8 + 'px');
//Put panel div in correct position
//-----------------------------------------------------------------
if(params.avatar_num_questions[idx] != 0)
{
if(!params.avatar_support_flash || !params.avatar_db_response[idx].flv_exists )
{
$('#avatar_videoholder'+idx).css('left',leftDist + 29-38 +'px');
$('#avatar_videoholder'+idx).css('top',topDist - 292-38 + 'px');
$('#avatar_avatarvideo'+idx).css('left','438px');
$('#avatar_avatarvideo'+idx).css('top','38px');
}
else
{
$('#avatar_videoholder'+idx).css('left',leftDist +20 +'px');
$('#avatar_videoholder'+idx).css('top',topDist - 292 + 'px');
$('#avatar_avatarvideo'+idx).css('left','0px');
$('#avatar_avatarvideo'+idx).css('top','0px');
}
$('#avatar_textAreaContainer'+idx).css('top',topDist - (question_panel_height-8) +'px').css('left',leftDist + 420 + 'px');
if($('#avatar_transcript_panel'+idx).length>0)
{
$('#avatar_transcript_panel'+idx).css('top',topDist - 75 + 'px').css('left',leftDist + 658 + 'px').css('display','block');
}
//slide down the IFoundYouThrough form after avatar is fully opened
params.avatar_opening_effectobj.MoveEffect(0, -1*question_panel_height, 1, "textArea"+idx, function(){
if(params.avatar_hasSurvey[idx]){
if($.smartsite_readCookie(params.avatar_oid+"survey")== null)
{
$(this).avatar('showform',idx);
}
else
{
$(this).avatar('fullyopened',idx);
}
}
else
{
$(this).avatar('fullyopened',idx);
}
});
}
else
{
if(!params.avatar_support_flash || !params.avatar_db_response[idx].flv_exists )
{
$('#avatar_videoholder'+idx).css('left',leftDist + 29-38 +'px');
$('#avatar_videoholder'+idx).css('top',topDist - 292-38 + 'px');
$('#avatar_avatarvideo'+idx).css('left','18px');
$('#avatar_avatarvideo'+idx).css('top','338px');
}
else
{
$('#avatar_videoholder'+idx).css('left',leftDist + 20 +'px');
$('#avatar_videoholder'+idx).css('top',topDist - 292 + 'px');
$('#avatar_avatarvideo'+idx).css('left','0px');
$('#avatar_avatarvideo'+idx).css('top','300px');
}
if(params.avatar_hasSurvey[idx] && $.smartsite_readCookie(params.avatar_oid+"survey")== null)
{
$(this).avatar('showform',idx);
}
else
{
$(this).avatar('fullyopened',idx);
}
}
//Display the transcript if there is one
//-----------------------------------------------------------------
if(params.avatar_num_questions[idx] != 0 && $('#avatar_transcript'+idx).length>0)
$('#avatar_transcript'+idx).css('display','block');
$('#avatar_statusDiv'+idx).css('display','block');
},
//Perform the Fourth stage of the animation, sliding down the IFoundYouThrough form
showform:function(idx){
//get the top position for the form container
var toTop = $('#avatar_lowerbarcontainer'+idx).position().top + $('#avatar_lowerbarcontainer'+idx).height() -10;
$('#avatar_formDivContainer'+idx).css('top',toTop + 'px');
//fixing position problems in certain browers like safari
var toLeft = $('#avatar_lowerbarcontainer'+idx).position().left;
$('#avatar_formDivContainer'+idx).css('left',toLeft + 'px');
var formHeight = $('#avatar_formDivContainer'+idx).height();
//put the form out of the container
$('#avatar_formDiv'+idx).css('top', -1*formHeight + 'px');
//animate the form to move it back to the container
params.avatar_opening_effectobj.MoveEffect(0, formHeight, 1, "avatar_formDiv"+idx, function(){$(this).avatar('fullyopened',idx);});
},
//Finalize the video opening process
fullyopened:function(idx){
//Display the avatar div
//-----------------------------------------------------------------
if(params.avatar_num_questions[idx] != 0)
{
var avatar_width = $("#avatar_avatarvideo"+idx).width();
if($("#avatar_topframe"+idx).length > 0)
{
$('#avatar_avatarvideo'+idx).css("display","block");
var avatar_topframe_width = $("#avatar_topframe"+idx).width();
$("#avatar_topframe"+idx).css('display','block');
params.avatar_trans_effectobj.MoveEffect(-1*avatar_topframe_width, 0, 0.4, "avatar_topframe"+idx, function(){
});
params.avatar_opening_effectobj.MoveEffect(-1*avatar_width, 0, 0.5, "avatar_avatarvideo"+idx, function(){
$(this).avatar('finish',idx);
});
}
else
{
//no frames around the video
$('#avatar_avatarvideo'+idx).css('left', '0px').css('display','block');
$(this).avatar('finish',idx);
}
}
else
{
if($("#avatar_topframe"+idx).length > 0)
{
$('#avatar_avatarvideo'+idx).css("display","block");
$("#avatar_topframe"+idx).css('display','block');
params.avatar_trans_effectobj.MoveEffect(0, -1*$("#avatar_videoholder"+idx).height(), 0.5, "avatar_topframe"+idx, function(){
});
params.avatar_opening_effectobj.MoveEffect(0, -300, 0.5, "avatar_avatarvideo"+idx, function(){
$(this).avatar('finish',idx);
});
}
else
{
$('#avatar_avatarvideo'+idx).css('top', '0px').css('display','block');
$(this).avatar('finish',idx);
}
}
},
finish:function(idx){
if(params.avatar_num_questions[idx] != 0){
$('#avatar_scrolling_div'+idx).css("display","block");
}
//Now that the avatar is finished opening, unlock to allow closing or other SmartConnect tools opening
//-----------------------------------------------------------------
params.avatar_opening=false;
smart_z_unlock();
params.avatar_opened=true;
setSwapFunc($.avatar_closeAvatarDiv, idx);
}
};
$.fn.avatar = function( method ) {
if ( methods[method] ) {
//execute a method of avatar
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
//initialize avatar
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.avatar' );
}
};
$.avatar_ccInitiate = function(idx){
//If the panel is in the process of being closed, don't allow this action
//-----------------------------------------------------------------
if(params.avatar_showClickTransitioning==true) return;
//Make sure a phone number has been entered
//-----------------------------------------------------------------
if($("#avatar_ccform"+idx+" #tocall").val() == '' || $("#avatar_ccform"+idx+" #tocall").val() == "Enter Your Phone Number")
{
alert("Please enter your phone number.");
}
//Post to iframe to connect the call
//-----------------------------------------------------------------
else
{
//Save the phone number in a cookie
$.smartsite_createCookie("avatar_phone",$("#avatar_ccform"+idx+" #tocall").val(),90);
$('#avatar_postframe'+idx).attr('src','http://www.elocallink.tv/zyte/call_it_s.php?number='+$("#avatar_ccform"+idx+" #tocall").val()+'&destcall='+params.avatar_db_response[idx].avatar_data[0].remote_click_to_call_phone+'&cc_notify='+params.avatar_db_response[idx].avatar_data[0].remote_cc_email);
$.avatar_retractClickCall(idx);
}
}
$.create_survey_options = function(json, idx){
var numOfOptions = json.surveyopt.length;
var numOfRows = Math.ceil(numOfOptions/3) ;
//creating options
for(var i=1; i<=numOfOptions; i++)
{
var current_row = Math.ceil(i/3);
switch(i%3)
{
case 1:
if(json.surveyopt[i-1].option == 'Other')
{
$('#IFoundYouForm'+idx).append("");
$('#form'+idx+'_row'+current_row).append("
");
}
break;
}//end of switch
}//end of for loop
//creating a submit button
$('#IFoundYouForm'+idx).append('
If you see this, leave this form field blank and invest in CSS support.
');
}
//Check if the video should be auto-centered, if so, calculate the center
//-----------------------------------------------------------------
$.avatar_checkAutoCenter = function(num){
//If the video should be auto-centered, calculate the center
//-----------------------------------------------------------------
var avatar_offset = $('#smartsite_avatar'+num).offset();
var avatar_leftDistance= avatar_offset.left;
var avatar_topDistance = avatar_offset.top;
var scrolldist = $(document).scrollTop();
if(params.avatar_db_response[num].avatar_data[0].autocenter==true){
params.avatar_db_response[num].avatar_data[0].left= ($(document).width()-672)/2 - avatar_leftDistance;
if(params.avatar_hasSurvey[num] && $.smartsite_readCookie(params.avatar_oid+"survey")== null)
{
params.avatar_db_response[num].avatar_data[0].top=$(window).height()/2-avatar_topDistance+141+scrolldist -170/2; //170 is the average form height
//params.avatar_db_response[num].avatar_data[0].top=($(window).height()-avatar_topDistance+scrolldist)/2 + -170/2; //170 is the form height
}
else
{
params.avatar_db_response[num].avatar_data[0].top=$(window).height()/2-avatar_topDistance+141+scrolldist;
}
}
/* write_log("window width:"+$(window).width());
write_log("window height:"+$(window).height());
write_log("avatar left:"+params.avatar_db_response[num].avatar_data[0].left);
write_log("avatar top:"+params.avatar_db_response[num].avatar_data[0].top);
write_log("scrolldist:"+scrolldist);*/
//Set the direction the avatar panel should slide out
//-----------------------------------------------------------------
if(params.avatar_db_response[num].avatar_data[0].left>-120)
params.avatar_db_response[num].avatar_data[0].direction='right';
else
params.avatar_db_response[num].avatar_data[0].direction='left';
}
//Update the position of elements within the avatar panel HTML
//-----------------------------------------------------------------
$.avatar_refreshDependentPositions = function(num){
if($("#avatar_statusDiv"+num).length>0){
if(params.avatar_num_questions[num] != 0)
{
$("#avatar_statusDiv"+num).css('left',(Number(params.avatar_db_response[num].avatar_data[0].left)+155)+"px");
}
else
{
$("#avatar_statusDiv"+num).css('left',(Number(params.avatar_db_response[num].avatar_data[0].left)+125)+"px");
}
$("#avatar_statusDiv"+num).css('top',(Number(params.avatar_db_response[num].avatar_data[0].top)+17)+"px");
}
if($("#avatar_avatarcallclosebutton"+num).length>0){
$("#avatar_avatarcallclosebutton"+num).css('left',(Number(params.avatar_db_response[num].avatar_data[0].left)+109)+"px");
$("#avatar_avatarcallclosebutton"+num).css('top',(Number(params.avatar_db_response[num].avatar_data[0].top)+10)+"px");
}
if($("#avatar_calldiv"+num).length>0){
$("#avatar_calldiv"+num).css('left',(Number(params.avatar_db_response[num].avatar_data[0].left)+112)+"px");
$("#avatar_calldiv"+num).css('top',(Number(params.avatar_db_response[num].avatar_data[0].top)+28)+"px");
}
}
//Show click to call panel
//-----------------------------------------------------------------
$.avatar_showClickCall = function(num)
{
//If click to call is already animating, cancel this
//-----------------------------------------------------------------
if(params.avatar_showClickTransitioning==true) return;
//If click to call is open, hide it
//-----------------------------------------------------------------
if(params.avatar_showClickOpen==true) {$.avatar_retractClickCall(num); return;}
params.avatar_showClickTransitioning=true;
$('#avatar_calldiv'+num).css('display','block');
//Move the click to call panel
//-----------------------------------------------------------------
params.avatar_click_effectobj.MoveEffect(0, 45, 1, "calldivback"+num, function(){params.avatar_showClickTransitioning=false;params.avatar_showClickOpen=true;});
//Check to see if a pre-existing number is saved in a cookie
//-----------------------------------------------------------------
preexistingNumber=$.smartsite_readCookie("avatar_phone");
if(preexistingNumber!=null){
$("#avatar_ccform"+num+" #tocall").val(preexistingNumber);
}
else{
$("#avatar_ccform"+num+" #tocall").val("Enter Your Phone Number");
}
}
//Play an avatar clip
//Change the title to the default, "Go ahead, ask me a question"
//-----------------------------------------------------------------
$.avatar_playClip = function(ival, pos){
//Change the transcript text, if there is one
//-----------------------------------------------------------------
if(params.avatar_db_response[pos].avatar_data[0].transcript==true)
$("#current_transcript"+pos).html(params.avatar_db_response[pos].questions[ival].transcript);
if(params.avatar_last_clicked != -1)
{
$("#avatar_cont"+pos+" .avatar_question_text").eq(params.avatar_last_clicked).css('color','white');
}
$("#avatar_cont"+pos+" .avatar_question_text").eq(ival).css('color','#888');
//Store the last question clicked
//-----------------------------------------------------------------
params.avatar_last_clicked=ival;
//Trim the question title length and display it
//-----------------------------------------------------------------
if(params.avatar_db_response[pos].questions[ival].question.length<80)
$('#avatar_statusDiv'+pos).html(params.avatar_db_response[pos].questions[ival].question);
else
$('#avatar_statusDiv'+pos).html(params.avatar_db_response[pos].questions[ival].question.substr(0,71)+"...");
//Post universal_tracking script to iframe to track this question playback
//-----------------------------------------------------------------
$("#avatar_postframe2_"+pos).attr("src","http://www.smartsite.tv/tracking/universal_tracking.php?pid="+params.avatar_oid+"&insert_type=avatar&etx="+params.avatar_db_response[pos].questions[ival].enc_question);
var question_clip = params.avatar_db_response[pos].questions[ival].clip_url;
if(has_ext)
question_clip = params.avatar_db_response[pos].avatar_data[0].rootdir + question_clip.substring(0, question_clip.lastIndexOf('.'))+video_extension;
else
question_clip = params.avatar_db_response[pos].avatar_data[0].rootdir + question_clip + clip_suffix[video_extension] + video_extension;
if(params.avatar_support_flash)
{
//Send command to SWF to play new clip
//-----------------------------------------------------------------
$.avatar_getSWF("recorder"+pos).playNewClip(question_clip, true);
}
else
{
//play html5 video
$.playHtml5Video(question_clip, pos, ival);
}
}
$.playHtml5Video = function(url, num, q_idx){
var myvideo = document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0];
if(!myvideo.paused)
{
myvideo.pause();
}
/*if(!document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].paused)
{
document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].pause();
}*/
$("#avatar_avatarvideo"+num+" .avatar_overlay span").text('Thinking...');
var span_to_left = (400 -$("#avatar_avatarvideo"+num+" .avatar_overlay span").outerWidth())/2 + 20;
$("#avatar_avatarvideo"+num+" .avatar_overlay span").css('left',span_to_left+'px').css('top','200px');
$("#avatar_avatarvideo"+num+" .avatar_overlay").css('visibility','visible');
$("#avatar_avatarvideo"+num+" video source").attr('src','');
//document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].load();
$("#avatar_avatarvideo"+num+" video").remove();
//$("#avatar_avatarvideo"+num+" video source").attr('src',url);
//myvideo.load();
//document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].load();
$("#avatar_avatarvideo"+num).append("");
$("#avatar_avatarvideo"+num+" video").bind('playing',function(){
if(isMobile.Android())
{
$("#avatar_avatarvideo"+num+" video").bind('timeupdate',function(){
if(document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].currentTime >0)
{
//write_log(document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].currentTime);
$("#avatar_avatarvideo"+num+" .avatar_overlay").css('visibility','hidden');
}
});
}
else
{
$("#avatar_avatarvideo"+num+" .avatar_overlay").css('visibility','hidden');
}
});
document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].play();
/* setTimeout(function(){
//myvideo.play();
//$("#avatar_avatarvideo"+num+" video").trigger('play');
document.getElementById("avatar_avatarvideo"+num).getElementsByTagName('video')[0].play();
},200);*/
$("#avatar_avatarvideo"+num+" video").bind('ended',function(){
$("#avatar_avatarvideo"+num+" .avatar_overlay span").text('Go ahead! Ask me a question!');
span_to_left = ($("#avatar_avatarvideo"+num+" video").width() -$("#avatar_avatarvideo"+num+" .avatar_overlay span").outerWidth())/2 + 20;
$("#avatar_avatarvideo"+num+" .avatar_overlay span").css('left',span_to_left+'px').css('top','200px');
$("#avatar_avatarvideo"+num+" .avatar_overlay").css('visibility','visible');
});
}
/*window.onorientationchange = $.detectIPadOrientation;
$.detectIPadOrientation = function() {
if ( orientation == 0 ) {
alert ('Portrait Mode, Home Button bottom');
}
else if ( orientation == 90 ) {
alert ('Landscape Mode, Home Button right');
}
else if ( orientation == -90 ) {
alert ('Landscape Mode, Home Button left');
}
else if ( orientation == 180 ) {
alert ('Portrait Mode, Home Button top');
}
}*/
//Cross-browser function to obtain reference to embedded SWF
//-----------------------------------------------------------------
$.avatar_getSWF = function(movieName) {
//If user is using Internet Explorer, attempt to get SWF reference
//-----------------------------------------------------------------
if (navigator.appName.indexOf("Microsoft") != -1) {
if(window[movieName] != undefined){
return window[movieName];
}
else{
/*for(i=0;i 0)
{
//have frames around the video
var topframe_width = $("#avatar_topframe"+num).width();
//retract the top frame back to the question panel
params.avatar_trans_effectobj.MoveEffect(topframe_width, 0, 0.5, "avatar_topframe"+num, function(){
$("#avatar_topframe"+num).css('display','none');
});
//retract the video back to the question panel
params.avatar_closing_effectobj.MoveEffect(420, 0, 0.4, "avatar_avatarvideo"+num, function(){
if(params.avatar_support_flash){
$.avatar_getSWF("recorder"+num).fadeOut();
}
else
{
$("#avatar_avatarvideo"+num+" video")[0].pause();
$("#avatar_avatarvideo"+num+" video").fadeOut();
}
$.retract_questions(num);
});
}
else
{
//no frames around the video. fadeout the video directly
if(params.avatar_support_flash){
$.avatar_getSWF("recorder"+num).fadeOut();
}
else
{
$("#avatar_avatarvideo"+num+" video")[0].pause();
$("#avatar_avatarvideo"+num+" video").fadeOut();
}
$.retract_questions(num);
}
}
else
{
//contain the question panel
var y1 = $("#avatar_avatarvideo"+num).position().top + $("#avatar_avatarvideo"+num).height();
var y2 = $("#avatar_videoholder"+num).height();
//move the video down
params.avatar_closing_effectobj.MoveEffect(0, y1 , 0.5, "avatar_avatarvideo"+num, function(){
if(params.avatar_support_flash){
$.avatar_getSWF("recorder"+num).fadeOut();
}
else
{
$("#avatar_avatarvideo"+num+" video")[0].pause();
$("#avatar_avatarvideo"+num+" video").fadeOut();
}
$.retract_questions(num);
});
if($("#avatar_topframe"+num).length > 0)
{
params.avatar_trans_effectobj.MoveEffect(0, y2, 0.5, "avatar_topframe"+num, function(){
$("#avatar_topframe"+num).css('display','none');
});
}
}
}
$.retract_questions = function(num){
//-----------------------------------------------------------------
params.avatar_closing=true;
smart_z_lock();
params.avatar_opened=false;
clearSwapFunc();
if(params.avatar_num_questions[num] != 0){
$('#avatar_scrolling_div'+num).css('display','none');
}
//Change the icon
//-----------------------------------------------------------------
$('#avatar_icon_standard'+num).css('display','block');
$('#avatar_icon_over'+num).css('display','none');
$('#avatar_icon_close'+num).css('display','none');
//Close the text panel after a set amount of time
//-----------------------------------------------------------------
setTimeout(function(){
params.avatar_closing=true;
smart_z_lock();
$("#avatar_avatarvideo"+num).css('display','none');
$("#avatar_lowershadow"+num).html('');
if(params.avatar_num_questions[num] != 0){
params.avatar_closing_effectobj.MoveEffect(0, question_panel_height, 1, "textArea"+num, function(){
if(params.avatar_hasSurvey[num]){
if($.smartsite_readCookie(params.avatar_oid+"survey")== null){
$.avatar_closeForm(num);
}
else{
$.avatar_closeBar(num);
}
}
else
{
$.avatar_closeBar(num);
}
if(params.avatar_redirection_address != ""){
window.location = params.avatar_redirection_address;
}
});
}
else
{
if(params.avatar_hasSurvey[num]){
if($.smartsite_readCookie(params.avatar_oid+"survey")== null){
$.avatar_closeForm(num);
}
else{
$.avatar_closeBar(num);
}
}
else
{
$.avatar_closeBar(num);
}
if(params.avatar_redirection_address != ""){
window.location = params.avatar_redirection_address;
}
}
}, 600);
}
//Second stage of closing animation, animate the form returning to its original slid-out position
$.avatar_closeForm = function(num){
//get the height of the form
var formHeight = $("#avatar_formDivContainer"+num).height();
params.avatar_closing_effectobj.MoveEffect(0, -1*formHeight, 1, "avatar_formDiv"+num, function(){$.avatar_closeBar(num);});
}
//Third stage of closing animation, animate the bar returning to its original slid-out position
//-----------------------------------------------------------------
$.avatar_closeBar = function(num){
//Hide elements
//-----------------------------------------------------------------
if($("#avatar_avatarcallclosebutton"+num).length>0) $("#avatar_avatarcallclosebutton"+num).css('display','none');
if($("#avatar_transcript"+num).length>0) $("#avatar_transcript"+num).css('display','none');
$("#avatar_transcript_panel"+num).css('display','none');
$("#avatar_statusDiv"+num).css('display','none');
if(params.avatar_hasSurvey[num] && $.smartsite_readCookie(params.avatar_oid+"survey")== null){
if(params.avatar_num_questions[num] != 0){
$("#avatar_statusDiv"+num).text('Please take a quick moment to tell me how you found us...');
}
else
{
$("#avatar_statusDiv"+num).html('Please take a quick moment to tell me how you found us...');
}
}
else if(params.avatar_hasSurvey[num] && $.smartsite_readCookie(params.avatar_oid+"survey")!= null){
if(params.avatar_num_questions[num] != 0){
$("#avatar_statusDiv"+num).text('Go ahead, ask me a question.');
}
else
{
$('#avatar_statusDiv'+num).html('Thank you. You already told us how you found us.');
}
}
else if(!params.avatar_hasSurvey[num]){
if(params.avatar_num_questions[num] != 0){
$("#avatar_statusDiv"+num).text('Go ahead, ask me a question.');
}
else
{
$('#avatar_statusDiv'+num).html('');
}
}
$('#avatar_avatarvideo'+num).html('');
//Get the current bar position
//-----------------------------------------------------------------
var cx=$('#avatar_lowerbarcontainer'+num).css('left');
pos=cx.indexOf("p");
cx=String(cx).substr(0,pos);
var cy=$('#avatar_lowerbarcontainer'+num).css('top');
pos=cy.indexOf("p");
cy=String(cy).substr(0,pos);
//Slide the bar back to its original, slid-out position
//-----------------------------------------------------------------
params.avatar_closing_effectobj.MoveEffect(params.avatar_initialX[num]-cx, params.avatar_initialY[num]-cy, 1, "avatar_lowerbarcontainer"+num, function(){$.avatar_retractBar(num);});
}
//Fourth stage of closing animation, retract the bar back into the icon
//-----------------------------------------------------------------
$.avatar_retractBar = function(num){
//Depending on the direction the bar originally slid out from, animate it sliding back into the icon
//-----------------------------------------------------------------
if(params.avatar_db_response[num].avatar_data[0].direction=="left"){
params.avatar_closing_effectobj.MoveEffect(672, 0, 1, "avatar_lowerbar"+num, function(){$.avatar_hideAvatarDiv(num);});
}
else{
params.avatar_closing_effectobj.MoveEffect(-672, 0, 1, "avatar_lowerbar"+num, function(){$.avatar_hideAvatarDiv(num);});
}
//$("#avatar_cont"+num).find(".avatar_highlighted_question").removeClass('avatar_highlighted_question');
$("#avatar_cont"+num).find(".avatar_question_text").css('color','white');
}
$.submit_IFYT_form = function(pos, options_count){
var result_arr = [];
var result_option_arr = [];
var numOfCheckbox = options_count-1;
var numOfChecked = 0;
var theIP = "3.147.72.65";
var isValid = false;
var user_email = $("#avatar_source_div input").val();
for(i=1;i<=numOfCheckbox;i++){
var checkboxId = "form"+pos+"_option"+i;
var option_id = "form" + pos+"_optionId"+i;
//if(document.getElementById(checkboxId).checked)
if($("#"+checkboxId).is(':checked'))
{
result_arr.push($("#"+checkboxId).val());
result_option_arr.push($("#"+option_id).val());
numOfChecked++;
}
}
if(numOfChecked == 0){
if($('#form'+pos+'_text').val() == ''){
alert("You must choose at least an option");
isValid = false;
}
else{
isValid = true;
var other_tf = $('#form'+pos+'_text').val();
result_option_arr.push($("#form" + pos +"_optionId"+options_count).val());
if(user_email == '')
$("#avatar_postframe2_"+pos).attr("src","http://www.nxnotes.com/proc/next_db_responder.php?action_request=process_smartavatar_next&other="+encodeURIComponent(other_tf)+"&pid="+params.avatar_oid+"&userIP="+theIP+"&result_options="+result_option_arr);
}
}
else{
isValid = true;
if(user_email == '')
{
if($('#form'+pos+'_text').val() == ''){
$("#avatar_postframe2_"+pos).attr("src","http://www.nxnotes.com/proc/next_db_responder.php?action_request=process_smartavatar_next&results="+result_arr+"&pid="+params.avatar_oid+"&userIP="+theIP+"&result_options="+result_option_arr);
}
else{
var other_tf = $('#form'+pos+'_text').val();
result_option_arr.push($("#form" + pos +"_optionId"+options_count).val());
$("#avatar_postframe2_"+pos).attr("src","http://www.nxnotes.com/proc/next_db_responder.php?action_request=process_smartavatar_next&results="+result_arr+"&other="+encodeURIComponent(other_tf)+"&pid="+params.avatar_oid+"&userIP="+theIP+"&result_options="+result_option_arr);
}
}
}
if(isValid)
{
if(params.avatar_support_flash)
{
//console.log(params.avatar_db_response[pos].avatar_data[0].rootdir+params.avatar_db_response[pos].avatar_data[0].occ_clip1);
$.avatar_getSWF("recorder"+pos).playNewClip(params.avatar_db_response[pos].avatar_data[0].rootdir+params.avatar_db_response[pos].avatar_data[0].occ_clip1, true);
}
else
{
//play html5 "thanks" video
}
var formHeight = $('#avatar_formDivContainer'+pos).height();
params.avatar_closing_effectobj.MoveEffect(0, -1*formHeight, 1, "avatar_formDiv"+pos, function(){
//remove the form DIV from the document
$('#avatar_formDiv'+pos).remove();
//creating a cookie
$.smartsite_createCookie(params.avatar_oid+"survey","true", 365);
if(params.avatar_num_questions[pos] != 0)
{
$('#avatar_statusDiv'+pos).html("Go ahead, ask me a question.");
}
else
{
$("#avatar_avatarvideo"+pos+" .avatar_overlay span").css('display','none');
$('#avatar_statusDiv'+pos).html('Thank you.');
setTimeout(function(){
$.avatar_closeAvatarDiv(pos);
},3000);
}
});
}
}
//Finalize avatar closing animation
//-----------------------------------------------------------------
$.avatar_hideAvatarDiv = function(num){
$('#avatar_cont'+num).css('display','none');
//avatarShowing=false;
params.avatar_closing=false;
smart_z_unlock();
params.avatar_now_opened=-1;
$('#smartsite_avatar'+num).css('zIndex',params.avatar_originalZ);
}
//$.extend($.fn.avatar, params);
//This function not renamed 'smartavatar' because it is called from the swf file
//Change the title to the default, "Thank you. You already told us how you found us."
//-----------------------------------------------------------------
$.avatar_resetStatusDesc = function(){
var opened_avatar_idx = params.avatar_now_opened;
if(params.avatar_hasSurvey[opened_avatar_idx] && $.smartsite_readCookie(params.avatar_oid+"survey")== null){//if the IFoundYouThrough form exists
if(params.avatar_num_questions[opened_avatar_idx] != 0)
{
$('#avatar_statusDiv'+params.avatar_now_opened).html("Please take a quick moment to tell me how you found us...");
}
else
{
$('#avatar_statusDiv'+params.avatar_now_opened).html('Please take a quick moment to tell me how you found us...');
}
}
else if(params.avatar_hasSurvey[opened_avatar_idx] && $.smartsite_readCookie(params.avatar_oid+"survey")!= null){
if(params.avatar_num_questions[opened_avatar_idx] != 0)
{
$('#avatar_statusDiv'+params.avatar_now_opened).html("Go ahead, ask me a question.");
}
else
{
$('#avatar_statusDiv'+params.avatar_now_opened).html('Thank you. You already told us how you found us.');
}
}
else if(!params.avatar_hasSurvey[opened_avatar_idx])
{
if(params.avatar_num_questions[opened_avatar_idx] != 0)
{
$('#avatar_statusDiv'+params.avatar_now_opened).html("Go ahead, ask me a question.");
}
else
{
$('#avatar_statusDiv'+params.avatar_now_opened).html('');
}
}
}
$.stripslashes = function(str) {
return (str + '').replace(/\\(.?)/g, function (s, n1) {
switch (n1) {
case '\\':
return '\\';
case '0':
return '\u0000';
case '':
return '';
default:
return n1;
}
});
}; /*
###Default implementation
smartobject initiation
*/
$(function(){
if(!+"\v1"){smartsite_is_IE6 = ((parseFloat(navigator.userAgent.substring((navigator.userAgent.indexOf("MSIE"))+5))==6)?1:0); }
$('smartobject').smartobject();
//If the tools included on the page require smart_z_manager.js, which manages auto-opening, and there are no image icons to load, dynamically add smart_z_manager.js
//--------------------------------------------------------------------------------
if(smart_v_included==true && waitingForImageCounter==0){
$.addScript("http://www.smartsite.tv/remote/smart_z_managerV2.js", 0);
}
});
/* #AVOID COLLISIONS #*/
})(jQuery);
/* #AVOID COLLISIONS #*/
//This function not renamed 'smartavatar' because it is called from the swf file
//Change the title to the default, "Thank you. You already told us how you found us."
//-----------------------------------------------------------------
function ZyteAvatar_resetStatusDesc(){
if(jQuery){
jQuery.avatar_resetStatusDesc();
}
}