
// Search form
var device = "";
var  carouselQuestionjs = "";
var disableOmnitureTrnxnTrac ="true";

jQuery(document).ready(function() {
jQuery("#txtSearch").autocomplete("http://search.sprint.com/inquiraapp/autosearch.jsp?jsoncallback=?", {
		dataType: 'jsonp',
		parse: function(data) {
			var rows = new Array();
			data = data.autoSuggestedKeys;
			for(var i=0; i<data.length; i++){
				rows[i] = { data:data[i], value:data[i].SearchKey, result:data[i].SearchKey };
			}
			return rows;
		},
		formatItem: function(row, i, n) {
			return row.SearchKey;
		},
		extraParams: {
			q: function () { return jQuery("#txtSearch").val() } ,
			limit: 10,
			style: 'full',
			maxRows: 10
		},
		width: 125,
		selectFirst: false,
		max: 10
	}); 
    jQuery("#txtSearch").result(function(event, data, formatted) {
        if (data){
            jQuery("#btnSearchGo").click();
        }
    });
    jQuery("#frmSearch").bind("submit", function(event) {
        if (jQuery.trim(jQuery("#txtSearch").val()) == "") {
            event.preventDefault();
        }
		var	value="";
		if(document.getElementById("txtSearch")){

		value = document.getElementById("txtSearch").value;

			}
			var emailfilter="/\'<>";


			  for (var i = 0; i < value.length; i++) {
				if (emailfilter.indexOf(value.charAt(i)) != -1) {
					
					value = value.replace((value.charAt(i)),"");
				}
			  }
				
				if(document.getElementById("txtSearch")){

			 document.getElementById("txtSearch").value = value;;

			}
			return true;
    });
	/* fix for predictive search from Search Global Header - ends here */
	jQuery("#txtSearchSupport").autocomplete("http://search.sprint.com/inquiraapp/autosearch.jsp?jsoncallback=?", {
		dataType: 'jsonp',
		parse: function(data) {
			var rows = new Array();
			data = data.autoSuggestedKeys;
			for(var i=0; i<data.length; i++){
				rows[i] = { data:data[i], value:data[i].SearchKey, result:data[i].SearchKey };
			}
			return rows;
		},
		formatItem: function(row, i, n) {
			return row.SearchKey;
		},
		extraParams: {
			q: function () { return jQuery("#txtSearchSupport").val() } ,
			limit: 10,
			style: 'full',
			maxRows: 10
		},
		width: 324,
		selectFirst: false,
		max: 10
	}); 

    jQuery("#txtSearchSupport").result(function(event, data, formatted) {
        if (data){
            jQuery("#btnSearchSupport").click();
        }
    });

    jQuery("#frmSearchSupport").bind("submit", function(event) {
        if (jQuery.trim(jQuery("#txtSearchSupport").val()) == "") {
            event.preventDefault();
        }
		var	value="";
		if(document.getElementById("txtSearchSupport")){

		value = document.getElementById("txtSearchSupport").value;

			}
			var emailfilter="/\'<>";


			  for (var i = 0; i < value.length; i++) {
				if (emailfilter.indexOf(value.charAt(i)) != -1) {
					
					value = value.replace((value.charAt(i)),"");
				}
			  }
				
				if(document.getElementById("txtSearchSupport")){

			 document.getElementById("txtSearchSupport").value = value;;

			}
			return true;
    });
    jQuery("#frmPSearch").bind("submit", function(event) {
		
      	var	value="";
			 if(document.getElementById("txtEmailQuestion")){
			value = document.getElementById("txtEmailQuestion").value;
			document.getElementById("originalQuestion").value = value;
			}
			var emailfilter="/\'<>";


			  for (var i = 0; i < value.length; i++) {
				if (emailfilter.indexOf(value.charAt(i)) != -1) {
					
					value = value.replace((value.charAt(i)),"");
				}
			  }
				
			if(document.getElementById("txtEmailQuestion")){
			document.getElementById("txtEmailQuestion").value = value;;
			document.getElementById("originalQuestion").value = value;
			}
			return true;
    });

    jQuery("#facetsDivId #article_type input[type='checkbox']").live("click", function(event) {
	
			if(document.getElementById("disableOmnitureTrnxnTrac")){
	
	disableOmnitureTrnxnTrac = document.getElementById("disableOmnitureTrnxnTrac").value;
	}
        if (disableOmnitureTrnxnTrac=="false") {
            if (this.checked) {
                Analytics.Search.trackSearchShowRemove(this.value);
            } else {
                Analytics.Search.trackSearchShowAdd(this.value);
            }
        }
        window.location.search = '?ui_mode=navigate&sub_nav=true&facet=' + this.value;
    });

});


// Process Wizard Support

var completedSteps = new Array();

function addAnswer(currStep, newStep) {
	
    completedSteps.push([currStep,newStep]);
    renderQuestionStack();
}

function getRatingClass( rating ){
    var ratingClass = "";
    switch(rating){
        case 1:     return "ratingOneStar";
        case 2:     return "ratingTwoStars";
        case 3:     return "ratingThreeStars";
        case 4:     return "ratingFourStars";
        case 5:     return "ratingFiveStars";
        default:     return "";
    }
}

function updateSearchResults( searchString ){
	searchString = searchString.split('##userdevice##');
		
	device = device.replace(/[^A-zÑñ0-9]/ig,' ');
	
	//device=device.split('&reg;');
		searchString =searchString +device;

    //break if this element doesnt exist
    if( jQuery("#pageUpdateServiceURL").length < 1 ){    return false; }

    //grab the service URL and append params
    var serviceURL = jQuery("#pageUpdateServiceURL").html();
    var currUrl = window.location.href;
    var urlParams = currUrl.split('?');
    var queryParams;
    if(urlParams.length > 1){
        queryParams = urlParams[1].split('&');
        var len=queryParams.length;
        for(var i=0; i<len; i++) {
            var value = queryParams[i];
            if(i == 0){
                serviceURL += "?";
            } else {
                serviceURL += "&";
            }

             if(value.indexOf('question_box') > -1){
				value="question_box="+searchString;			
               serviceURL +=  encodeURI(value);
				
            } else {
                serviceURL += value;
            }
        }
		
    }

    // TODO: Add the current facets

    //make the ajax call
    jQuery.getJSON( serviceURL, {} , function(json){

        var numArticles = 0;
var flg = false;
        //update the articles
        var newGroupList = "";
		var facet = "";
		
		
		for( var i in json.response.groupings ){

            var groupInfo = json.response.groupings[i];
			
	
            var group = "<div class=\"headerWrapperPrimary\">";
					
                     group+=   "    <h3 class=\"corporate\">"+groupInfo.title+"</h3>";
					
                      group+=    "</div>";

                         group+="<p>"+groupInfo.description+"</p>";

            group += "<ul class=\"groupListing\">";

			   

			
            var newArticleList = "";
            var classCounter = 0;
            for( var j in groupInfo.articles ){
				var articleInfo = groupInfo.articles[j];
				
                var article = "";
                classCounter++;
                var articleClasses = "";
                //this is the case for the row separator
				if(articleInfo.title!="" && articleInfo.title!=undefined){
                //this is the case for the row separator
				
                if(  classCounter % 2 == 1 ){
					if(classCounter!=1){
                    articleClasses = "rowSeparator";
					}
                    var article =     "<li class='"+articleClasses+"'></li>";
                    newArticleList += article;
                    //classCounter = 0;
                    articleClasses = "topicListing rowStart";
                    numArticles++;
                //this is the case for non-row-starting articles
                } else if( classCounter % 2== 0 ) {
					
                    articleClasses = "topicListing";
                    numArticles++;
                //ths is the case for row starting articles
                } else {
                    articleClasses = "topicListing rowStart";
                    numArticles++;
                }

              

                var article =     "<li class='"+articleClasses+"'>"+
                                  "    <div class=\"icon\">"+articleInfo.icon+"</div>"+
                                "    <div class=\"content\">"+
                                "        <h3><a href=\""+articleInfo.link+"\">"+articleInfo.title+"</a></h3>"+
                                "        <p class=\"last\">"+articleInfo.description+"</p>"+
                                "        <div class=\"tutorialDetails\">"+
                                "            <span class=\"tertiary\">Created on</span> "+
                                "            <span class=\"date\">"+articleInfo.date+"</span> "+
                                // "            <br/><span class=\"tertiary\">Average user rating: </span>"+
                                // "            <div class=\"rating "+getRatingClass(articleInfo.rating)+"\"><em>"+articleInfo.rating+" stars</em></div>"+
                                "        </div>"+
                                "    </div>"+
                                "</li>";


				}else if(articleInfo.displayURL !=undefined && articleInfo.displayURL!="" ){
					
					 
					var url="";
					var displayURL= "";
					displayURL=articleInfo.displayURL;
					if(displayURL.lastIndexOf('?') == -1){
						url+=displayURL+"?";
					}else{
						url+=displayURL+"&amp;";
					}
					url+="id16=";
					url+= encodeURI(json.response.question, "UTF-8");
					 var priceIndx = articleInfo.promoPriceIndex;
						 priceIndx=priceIndx.replace("(\\.\\d+)$", "<sup>$1</sup>");
				 article += "<li class=\"phoneListing\">"+
                                "<div class=\"phone\">"+
									"<a href="+url+"><img src=\"http:\//"+articleInfo.shopImagesHostName +""+ articleInfo.promoImageURLIndex+"\" alt=\""+articleInfo.productNameIndex+"\" /></a>"+
                               " </div>  <div class=\"phoneInfo\">"+
                                    "<h4><sup>$</sup>"+priceIndx+"</h4>"+
                                    "<h5><a href="+url+">"+articleInfo.productNameIndex+"</h5>"+
                                   " <a href="+url+">See details</a>"+
                                "</div>"+
                           "</li>";


			
                if ((classCounter % 2) == 0) {
			
                            article +="<li class=\"rowSeparator\"></li>";

                }
				}
				
                newArticleList += article;

            }

            group += newArticleList;
            group += "</ul>";
            newGroupList += group;
        		
		 
	}
	
	
	facet = "<ul class='topicsFilterList'>"+
                   " <li>"+
                        "<h5>Search Categories</h5>"+
                        "<ul id='category' class='topicLinkCategory'>"+
                           " <li class='linkContainer'>"+
                                "<a class='topicFilter' >All Categories</a>"+
                            "</li>";
		  var urlEncodeVar1;
		 
        for(var k in json.response.facets )	{
		var facetsInfo = json.response.facets[k];
		//alert(searchString);
		var urlString ="?ui_mode=navigate&amp;question_box="+searchString+"&amp;facet="+facetsInfo.facetId;
		
		urlEncodeVar1 = encodeURI(urlString);
		
		
		
		if(facetsInfo.facetCount!=0){
		if(facetsInfo.facetIsSelected=="T"){
			
			 facet +="<li class='linkContainer'>";
			 facet +="<a class=\"topicFilter filterSelected\" href="+urlEncodeVar1+" id=\"category_id_"+facetsInfo.facetId+"\">"+facetsInfo.facetDesc+"</a>";
			 	facet +="</li>";	   
	
		}else
			{
			
			facet +="<li class='linkContainer'>";
			 facet +="<a class=\"topicFilter \" href="+urlEncodeVar1+" id=\"category_id_"+facetsInfo.facetId+"\" >"+facetsInfo.facetDesc+"</a>";
			 facet +="</li>";	 
		 }
		 }


		

	
}

facet += "</ul>"+" </li>";
for(var k in json.response.facets ){
	var facetsInfo = json.response.facets[k];
	
if(facetsInfo.facetIsSelected=="T" && json.response.childrenCount!=0){
			
			 facet += "<li>"+
                        "<h5>"+
							"Filter by"+
						"</h5>"+
                        "<ul class=\"topicFilterCategory\" id=\"article_type\">";
               for(var p in json.response.children ){
				var childInfo = json.response.children[p];

       
		 facet +="<li class=\"chkContainer\">";
		 if(childInfo.childIsSelected=="T"){
           facet+= "<input type=\"checkbox\" id=\"chkShow_"+childInfo.childId+"\" name=\"chkShow_"+childInfo.childId+"\" checked=\"checked\" value=\""+childInfo.childId+"\"/>"+
			 " "+childInfo.childDesc+
            "<div class=\"filterBottom\"/>";
		 }else{
		 facet+= "<input type=\"checkbox\" id=\"chkShow_"+childInfo.childId+"\" name=\"chkShow_"+childInfo.childId+"\" value=\""+childInfo.childId+"\"/>"+
			 " "+childInfo.childDesc+
            "<div class=\"filterBottom\"/>";
		 }
       	 "</li>";
		
			   }
		facet +="</ul></li>";
		}
}
		facet +="</ul>";
		jQuery('#mostRelevantResult #loadingImageHolder').hide();
        jQuery("#searchPageArticles").html(newGroupList);
		jQuery("#facetsDivId").html(facet);
        jQuery(".resultHeader").html("Results for &quot;"+ searchString + "&quot;");
        jQuery('.resultMessage').html('<p><h3>Displaying results for: ' + searchString + '</h3></p>');
		jQuery("ul.groupListing li.topicListing").parent().toggleMoreResults(); 
		
		jQuery("ul.groupListing li.phoneListing").parent().toggleMoreResults({min:4, max:100, showLinkText:"See more phones", hideLinkText: "See less phones"});
    });
}
var s1="";
var tempString ="";
function selectWizardAnswer(currNode, stepId, selectId){
var omnitureStepArray = new Array();

if((document.getElementById("omnitureId")!='undefined' && document.getElementById("omnitureId")!="") && (disableOmnitureTrnxnTrac=="false")){
var omnitureSteps = document.getElementById("omnitureId").value;
var stepIdChoppedNumber = stepId.substr(0,1);
var stepIdChoppedChar = stepId.substr(1,1);
var stepCurrNodeClassChopped  ="";
var carouselFlag = 0;
var number = parseInt(stepIdChoppedNumber)+1;
var requiredOmnStepId = (number.toString())+stepIdChoppedChar;

if(omnitureSteps.indexOf(requiredOmnStepId)!=-1){

Analytics.Search.trackTransactions('Answer Center','complete','','','Awesome! Glad we could help.');
}
}

	if(stepId=="1A" && (disableOmnitureTrnxnTrac=="false")){
		
	Analytics.Search.trackTransactions('Answer Center','start');
	}


    addAnswer(stepId,selectId);
    var stepIdClass = '#step'+stepId;
	
    jQuery(stepIdClass).addClass('hideMe');

    var stepCurrNodeClass = jQuery(currNode).val();
	
	
    if (stepCurrNodeClass == '') {
        stepCurrNodeClass = currNode.id.slice(4);
    }

    stepCurrNodeClass = '#step' + stepCurrNodeClass;
	var stepCurrNodeClassChopped  =jQuery(stepCurrNodeClass).html();
	
	var thisHasCarousel = jQuery(stepCurrNodeClass).find('#frmSearchSelManufacturer');
	
	if(thisHasCarousel.length > 0){
		carouselFlag = 1;
	}	
		if(stepCurrNodeClassChopped.indexOf('|||')>-1 ){
			stepCurrNodeClassChopped  = jQuery(stepCurrNodeClass).html();
			s1=stepCurrNodeClassChopped.substring((stepCurrNodeClassChopped.indexOf('|||')),(stepCurrNodeClassChopped.lastIndexOf('|||')+3));
			
			stepCurrNodeClassChopped = stepCurrNodeClassChopped.replace(s1,"");
			tempString = stepCurrNodeClassChopped;
			
		}
	
	//stepCurrNodeClass = '#step3A';
	
    //Should we perform an auto-search?
    if((jQuery(stepCurrNodeClass).text().indexOf('|||') > -1) || (jQuery(stepCurrNodeClass).html()==tempString)){
		
			if(disableOmnitureTrnxnTrac=="false"){
				
		Analytics.Search.trackTransactions('Answer Center','complete','','','Awesome! Glad we could help.');
			}
        var fullStringVal = jQuery(stepCurrNodeClass).text();
		var searchStringArr = "";
		
		if(s1!=""){
			
		jQuery(stepCurrNodeClass).text(fullStringVal+s1);
		
		fullStringVal = jQuery(stepCurrNodeClass).text();
		
		}
        var searchStringArr = fullStringVal.split('|||');
		
		
        if(searchStringArr.length > 1){
            var searchString = searchStringArr[1];
		
        }
      //  jQuery('.resultMessage').html('<p><h3>Automatically searching for: ' + searchString + '</h3></p>');
		jQuery('#mostRelevantResult').remove();
		//jQuery('#mostRelevantResult #mostReleventTest1').remove();
		jQuery('#searchPageArticles #loadingImageHolder').show();
        updateSearchResults(searchString);

    } 

	if(stepCurrNodeClassChopped!="" && carouselFlag == 0){
		jQuery(stepCurrNodeClass).html(stepCurrNodeClassChopped);
	}
        var newNode = jQuery(stepCurrNodeClass);
	
        if (newNode.size() > 0) {
            newNode.removeClass('hideMe');
        } else {
            jQuery(currNode).parents('.disclosureContent').find('.resultMessage').hide();
			if(disableOmnitureTrnxnTrac=="false"){
			Analytics.Search.trackTransactions('Answer Center','complete','','','Awesome! Glad we could help.');
			}
        }
    
}


function wizardShowNextStep(currNode, nextStepVal){
	
	if(document.getElementById("disableOmnitureTrnxnTrac")){
	
	disableOmnitureTrnxnTrac = document.getElementById("disableOmnitureTrnxnTrac").value;
	}
    jQuery(currNode).parent().next().removeClass('hideMe');
    var stepValName = '#step' + nextStepVal;
    var nextStep = jQuery(currNode).parent().next().find(stepValName);
    if (nextStep.size() > 0) {
        nextStep.removeClass('hideMe');
    } else {
        jQuery(currNode).parents('.disclosureContent').find('.resultMessage').hide();
    }
    jQuery(currNode).parent().addClass('hideMe');
}


function renderQuestionStack() {
	
	
	
	
    jQuery('#questionStack').html('');
    for (var i = 0; i < completedSteps.length; i++) {
		
        var html = '<p class="wizStepComplete">'
                 + '<a href="javascript:;"';
				
				 if(disableOmnitureTrnxnTrac=="false"){
                 html =html+ ' onclick="popQuestionStack(' + i + ', \'' + completedSteps[i][0] + '\');Analytics.Search. trackAnswerCenterEdit ();"';
				 }else{
				   html =html+ ' onclick="popQuestionStack(' + i + ', \'' + completedSteps[i][0] + '\');"';
				 }
                  html =html+ ' class="wizStepEdit">Edit</a>'+ '<img src="/global/images/icons/ico_check.gif" />';
        if (jQuery('#step' + completedSteps[i][0] + ' select').size() > 0) {
			if(jQuery('#step' + completedSteps[i][0] + ' select').attr('name')!= 'selManufacturer'){
				
            html += 'You answered "'
                  + jQuery('#step' + completedSteps[i][0] + ' option:selected').text()
                  + '" to the question "'
                  + jQuery('#step' + completedSteps[i][0] + ' div').contents().get(0).nodeValue + '"';
			}else {
				html += 'You answered "'
                  + device
                  + '" to the question: "'
                  + carouselQuestionjs+'"';
				 
			}
        } else if (jQuery('#step' + completedSteps[i][0] + ' input[type=\'radio\']').size() > 0) {
            var selectedID = jQuery('#step' + completedSteps[i][0] + ' input:checked').get(0).id;
            html += 'You answered "'
                  + jQuery('#step' + completedSteps[i][0] + ' label[for=\'' + selectedID + '\']').text()
                  + '" to the question: "'
                  + jQuery('#step' + completedSteps[i][0] + ' div').contents().get(0).nodeValue + '"';
        } else {
            var firstTextNode = jQuery('#step' + completedSteps[i][0] + ' div').contents();
			if(jQuery(firstTextNode).text()==""){
			firstTextNode = jQuery('#step' + completedSteps[i][0] + ' div').contents().get(0);
			}
            if (firstTextNode) {
                if (firstTextNode.nodeType == 3) {
					
                    html += firstTextNode.nodeValue;
                } else {
					
                    html += jQuery(firstTextNode).text();
                }
            } else {
                html += jQuery('#step' + completedSteps[i][0] + ' p:first').text();
            }
        }
		

        html += '</p>';
        jQuery('#questionStack').append(html);
    }
}

function popQuestionStack(position, stepId) {
    while (completedSteps.length > position) {
                var step = completedSteps.pop();
        jQuery('#step' + step[0] + ' input:checked').removeAttr('checked');
        jQuery('#step' + step[0] + ' option:selected').removeAttr('selected');
        jQuery('#step' + step[0] + ' input[type=\'text\']').val('');
    
    }
    renderQuestionStack();
    jQuery('.wizardStep').addClass('hideMe');
    jQuery('#step' + stepId).removeClass('hideMe');
}

function serializeCompletedSteps(){
    return JSON.stringify(completedSteps);
}

function getQuestionAsKey(){
    return encodeURI(jQuery('#txtSearchSupport').attr('value'));
}


// Search Ratings

jQuery(document).ready(function() {
    jQuery('.radRateArticle').click(function() {
        jQuery("fieldset.ratingUserComments").hide();
        jQuery(jQuery(this).prev()).attr('checked',true);
        submitFeedback();
    });
});

function submitFeedback(){
    var checkedRadioBtn = jQuery("input:checked[type='radio'][name='radRateArticle']");
    var ratingValue = checkedRadioBtn.attr('value');
    var commentVal = document.getElementById("textAreaUserComments").value;
    jQuery.post("acceptFeedback.jsp", { rating: ratingValue, comment: commentVal } );

    jQuery('#rateSearch').html('<h5>Thank you for submitting feedback on your search.</h5>');

    return false;

//    document.getElementById("saved").value = "Pin"
//    setTimeout("document.doSubmit()", 50);
}

function submitForm() {
		var form = document.getElementById("carouselForm");
		form.submit();  
		
  
selectWizardAnswer(document.getElementById("2A.networkType"),'2A','I');
}


function setTextField(fieldName,networkTransId,networkId,deviceName,pictureMailCapable,stepGetId,carouselQuestion){
	

	fieldName.value =  networkTransId;
	device = deviceName;
	carouselQuestionjs= carouselQuestion;

sendAjaxdevicefn(deviceName,networkTransId,pictureMailCapable,'',networkId,'',stepGetId,'','');
//selectWizardAnswer(fieldName,stepGetId,networkTransId);

}
var ptnStatusCurrentNode ="";
var netIdCurrentNode ="";
var pictureMailCurrentNode ="";
function sendAjaxdevicefn(deviceName,networkTransId,pictureMailCapable,ptnStatus,netId,eligibleForUpgrade,ptnstepId,currentNode,selectId) {

 jQuery.ajax({
	
   type: "GET",
   url: "deviceCarouselAjaxHandler.jsp",
   processData: false,
   data: "deviceName="+deviceName+"&networkTransId="+networkTransId+"&ptnStatus="+ptnStatus+"&ptnstepId="+ptnstepId+"&pictureMailCapable="+pictureMailCapable+"&netId="+netId+"&eligibleForUpgrade="+eligibleForUpgrade,
   dataType:"json",
	    beforeSend: function(){
    
   },
	    complete: function(){
	  
	   if((ptnStatusCurrentNode!=undefined) && (ptnStatusCurrentNode!="")){
		
		currentNode.value = ptnStatusCurrentNode;
		selectWizardAnswer(currentNode, ptnstepId,selectId); return false;
	   }
	   if((netIdCurrentNode!=undefined) && (netIdCurrentNode!="")){
		
		currentNode.value = netIdCurrentNode;
		selectWizardAnswer(currentNode, ptnstepId,selectId); return false;
	   }
	   if((pictureMailCurrentNode!=undefined) && (pictureMailCurrentNode!="")){
		
		currentNode.value = pictureMailCurrentNode;
		selectWizardAnswer(currentNode, ptnstepId,selectId); return false;
	   }
	 
   },
   success: function(msg){
		
	   var output = eval(msg);
	   
		var deviceTransId = output.deviceTransId;
		var pictureMailTransId = output.pictureMailTransId;
		
		
		 ptnStatusCurrentNode= output.ptnStatusTransId;	
		 var netTransId=output.netIdTansId;
		 netIdCurrentNode = output.netIdTansIdAuth;
		pictureMailCurrentNode = output.pictureTransId;
		
		if(netTransId!=null){
		jQuery("#netTransId").val(netTransId);
		 }else{
		 jQuery("#deviceName").val('netTransId');
		 }
		 if(deviceTransId!=null){
		jQuery("#deviceName").val(deviceTransId);
		 }else{
		 jQuery("#deviceName").val('defaultStep');
		 }
		 
		 if(pictureMailTransId!=null){
			
			//document.getElemenyById("picturemail").value=pictureMailTransId;
		jQuery("#picturemail").val(pictureMailTransId);
		 }else{
		 jQuery("#picturemail").val('defaultStep');
		 }
   }
 });
}	
function setDeviceName(fieldName,deviceName,deviceTransId,carouselQuestion)
{
	if(fieldName!=null){
	fieldName.value = deviceTransId;
	}
	device = deviceName;
	carouselQuestionjs = carouselQuestion;
	//selectWizardAnswer(nextStepId,'','');
}
function setPtnStatus(currentNode, stepId, selectId,ptnStatus,userdevice)
{
	
	device = userdevice;
	//ptnStatus='false';
	if(currentNode.value=="defaultStep"){
	sendAjaxdevicefn('','','',ptnStatus,'','',stepId,currentNode,selectId); 
	}else{
	//document.getElementById("3E.yourdevice").value="yes";
	selectWizardAnswer(currentNode, stepId, selectId);
	}
}
function setNetworkType(currentNode, stepId, selectId,netId,userdevice)
{
	device = userdevice;
if(currentNode.value=="defaultStep"){
	sendAjaxdevicefn('','','','',netId,'',stepId,currentNode,selectId); 
	}else{
	selectWizardAnswer(currentNode, stepId, selectId);
	}
}
function setPictureMail(currentNode, stepId, selectId,netId,pictureCapable,eligibleForUpgrade,userdevice)
{
	
	device = userdevice;
	//ptnStatus='false';
	if(currentNode.value=="defaultStep"){
	sendAjaxdevicefn('','',pictureCapable,'',netId,eligibleForUpgrade,stepId,currentNode,selectId); 
	}else{
		
	//document.getElementById("3E.yourdevice").value="yes";
	selectWizardAnswer(currentNode, stepId, selectId);
	}
}

function showCustomerTypeStep(currentNode, nextStep, currentAccountType)
{
//currentAccountType="Corporate/H";

	if(currentAccountType=="I" || currentAccountType == "C/H" || currentAccountType=="C/I" || currentAccountType=="G/4" || currentAccountType=="G/3" || currentAccountType=="B/Q" || currentAccountType=="B/U" ){
	wizardShowNextStep(currentNode, '2A');
	}else{
	//document.getElementById("3E.yourdevice").value="yes";
	wizardShowNextStep(currentNode, '2B');
	}

}


//Added for Sub Facet Analytics on ui page

function toggleAnalyticsForSubFacet(facet){
	if(disableOmnitureTrnxnTrac=="false"){
	if(document.getElementById(facet).checked){
		Analytics. Search.trackSearchShowAdd(facet);
		
	}else{
		Analytics.Search.trackSearchShowRemove(facet);		
	}
	}
}

function checkchar()
{
var	value="";
if(document.getElementById("txtSearchSupport")){

value = document.getElementById("txtSearchSupport").value;




}else if(document.getElementById("txtEmailQuestion")){
value = document.getElementById("txtEmailQuestion").value;
document.getElementById("originalQuestion").value = value;
}else if(document.getElementById("txtSearch")){
value=document.getElementById("txtSearch").value;
}
var emailfilter="%/\'<>";


  for (var i = 0; i < value.length; i++) {
  	if (emailfilter.indexOf(value.charAt(i)) != -1) {
		
		value = value.replace((value.charAt(i)),"");
  	}
  }
	
	if(document.getElementById("txtSearchSupport")){

 document.getElementById("txtSearchSupport").value = value;;

}else if(document.getElementById("txtEmailQuestion")){
document.getElementById("txtEmailQuestion").value = value;;
document.getElementById("originalQuestion").value = value;
}else if(document.getElementById("txtSearch")){
document.getElementById("txtSearch").value = value;;
}
return true;
}

