
var openDiv = 0;
var count =0;

/*	function: newOpener - loads URL on the parent window
			newURL: 
*/
function newOpener(newURL)
{
	opener.document.location = newURL;
}


/*	function: newWin - opens a new window
			newWin 			takes on 7 values:
			WinURL: 		the URL to be loaded into the new window
			WinNAME:		the NAME of the popup window
			WinWIDTH: 	the WIDTH of the popup window (currently set at 700px)
			WinHEIGHT:	the HEIGHT of the popup window (currently set at 480px)
			WinRESIZE:	the "yes" or "no" value for the resize window property
			WinSCROLL:	the "yes" or "no" value for the scrollbars window property
			WinTOOLBAR: the "yes" or "no" value for the toolbar property
*/

function newWin(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, WinSCROLL, WinTOOLBAR)
{	
	/*	variables passed by the link calling the function	*/
	var URL = WinURL;
	var WINDOW_NAME = WinNAME;
	var POPUP_WIDTH = WinWIDTH;
	var POPUP_HEIGHT = WinHEIGHT;
	var POPUP_RESIZE = WinRESIZE;
	var POPUP_SCROLL = WinSCROLL;
	var POPUP_TOOLBAR = WinTOOLBAR;

	/*	window properties that determine the window attributes depending on what values are passed by the link calling the function	*/
	var window_toolbar = POPUP_TOOLBAR;
	var window_resize = POPUP_RESIZE;
	var window_scroll = POPUP_SCROLL;
	var window_width = POPUP_WIDTH;
	var window_height = POPUP_HEIGHT;
	var screen_balance_w = ((screen.width)-(window_width))/2;
	var screen_balance_h = ((screen.height)-(window_height))/2;
	var set_top = screen_balance_h;
	var set_left = screen_balance_w;	

	win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + ',top=' +  set_top + ',left=' + set_left + '');
	win.focus();
}

function newWinAddress(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, WinSCROLL, WinTOOLBAR)
{	
	/*	variables passed by the link calling the function	*/
	var URL = WinURL;
	var WINDOW_NAME = WinNAME;
	var POPUP_WIDTH = WinWIDTH;
	var POPUP_HEIGHT = WinHEIGHT;
	var POPUP_RESIZE = WinRESIZE;
	var POPUP_SCROLL = WinSCROLL;
	var POPUP_TOOLBAR = WinTOOLBAR;

	/*	window properties that determine the window attributes depending on what values are passed by the link calling the function	*/
	var window_toolbar = POPUP_TOOLBAR;
	var window_resize = POPUP_RESIZE;
	var window_scroll = POPUP_SCROLL;
	var window_width = POPUP_WIDTH;
	var window_height = POPUP_HEIGHT;
	var screen_balance_w = ((screen.width)-(window_width))/2;
	var screen_balance_h = ((screen.height)-(window_height))/2;
	var set_top = screen_balance_h;
	var set_left = screen_balance_w;	

	win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + ',top=' +  set_top + ',left=' + set_left + ',location=yes');
	win.focus();
}


/*	function: closeWin - closes the child window	*/

function closeWin()
{
	top.window.close();
}


/*	
THIS JAVASCRIPT ALLOWS FOR AUTOMATIC FIELD TABBING FOR PHONE NUMBERS AND STUFF 
*/
var downStrokeField;
function autojump(fieldName,nextFieldName,fakeMaxLength)
{
var myForm=document.forms[document.forms.length - 1];
var myField=myForm.elements[fieldName];
myField.nextField=myForm.elements[nextFieldName];

if (myField.maxLength == null)
   myField.maxLength=fakeMaxLength;

myField.onkeydown=autojump_keyDown;
myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
this.beforeLength=this.value.length;
downStrokeField=this;
}

function autojump_keyUp()
{
if (
   (this == downStrokeField) && 
   (this.value.length > this.beforeLength) && 
   (this.value.length >= this.maxLength)
   )
   this.nextField.focus();
downStrokeField=null;
}

function check_field(f){
illegal = /[^\w._\-]/
email = f.EMAILADDR.value;

if (email.length<6 || email.indexOf('@')==-1 || email.indexOf('.')==-1)
	email="";
else { 
	At = email.indexOf('@');
	Period = email.lastIndexOf('.');
	DNS1 = email.substring(0,At);
	if (DNS1.length<1 || DNS1.match(illegal)!=null) email="";
		DNS2 = email.substring(At+1,Period);
	if (DNS2.length<1 || DNS2.match(illegal)!=null) email="";
		DNS3 = email.substring(Period+1,email.length);
	if (DNS3.length<2 || DNS3.match(illegal)!=null) email="";}

if (email.length==0) {
	alert("The email address you have entered is not valid.\nPlease re-enter a valid  email address.");
	f.EMAILADDR.focus();
	return false;} 
	
if(f.FIRSTNAME.value == ''){
 alert("Please enter your first name");
	f.FIRSTNAME.focus();
 return false;}
if(f.LASTNAME.value == ''){
 alert("Please enter your last name");
	f.LASTNAME.focus();
 return false;} 

return true;
}

function newExitWin(WinURL, WinNewUrlParam, WinNewUrl, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, 
WinSCROLL, WinTOOLBAR) 
	{       
	        /*      variables passed by the link calling the function       */ 
	        var newUrl = WinNewUrl; 
	        newUrl = newUrl.replace('?','%3F'); 
	        while (newUrl.indexOf('=') > -1){ 
	                newUrl = newUrl.replace('=','%3D'); 
	        } 
	        while (newUrl.indexOf('&') > -1){ 
	                newUrl = newUrl.replace('&','%26'); 
	        } 
	        
	        var URL = WinURL+'&'+WinNewUrlParam+'='+newUrl; 
	        var WINDOW_NAME = WinNAME; 
	        var POPUP_WIDTH = WinWIDTH; 
	        var POPUP_HEIGHT = WinHEIGHT; 
	        var POPUP_RESIZE = WinRESIZE; 
	        var POPUP_SCROLL = WinSCROLL; 
	        var POPUP_TOOLBAR = WinTOOLBAR; 

	        /*      window properties that determine the window attributes depending on what values 
are passed by the link calling the function     */

	        var window_toolbar = POPUP_TOOLBAR; 
	        var window_resize = POPUP_RESIZE; 
	        var window_scroll = POPUP_SCROLL; 
	        var window_width = POPUP_WIDTH; 
	        var window_height = POPUP_HEIGHT; 
	        var screen_balance_w = ((screen.width)-(window_width))/2; 
	        var screen_balance_h = ((screen.height)-(window_height))/2; 
	        var set_top = screen_balance_h; 
	        var set_left = screen_balance_w; 

	        win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + 
window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + 
',top=' +  set_top + ',left=' + set_left + '');

	        win.focus(); 
	} 

function handleDropDown(sellist) {
	if ( sellist.selectedIndex != 0 )
		window.open(sellist.options[sellist.selectedIndex].value);
	sellist.selectedIndex = 0;
}


function initRequest() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        isIE = true;
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
}



function removeProduct(productId,imagePath, productType){

	var url="/a2w/productAction.do?action=removeProduct&id=" +  productId;
	var req = initRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                    if(productType == 'Prescription Medicines'){
					document.getElementById("SelectedValue").innerHTML = parseXML(req.responseXML,"addedList",imagePath,productType);
                   }else{
                    document.getElementById("SelectedValue").innerHTML = parseConsumerXML(req.responseXML,"addedList",imagePath,productType);
                   }
                   	prdType = req.responseText;
                    delete req;
                    req = null;
                } else {
       				 alert("Problem with server response:\n " + req.statusText);
     			 }
              }
        };
	
	req.open("post",url,true);
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.send(null);
}
function displayDiv(id1,id2){
   document.getElementById("tabButtons").style.display = 'block';
	document.getElementById("prescriptionDiv").style.display = 'block';
	document.getElementById("consumerId").style.display = 'none';
	selectHighlited(id1,id2);
}
function openConsumerDiv(){
  document.getElementById("tabButtons").style.display = 'none';
	document.getElementById("prescriptionDiv").style.display = 'none';
	document.getElementById("consumerId").style.display = 'block';
}
function addProduct(productId,productName1,stand,productName2,
						description,category,imagePath,productType,chkBox){

if(chkBox.checked === undefined){
chkBox.checked = '1';
}
if(chkBox.checked==1){
var url="/a2w/productAction.do?action=addProduct&id=" +  productId + "&name1=" + productName1;
url = url + "&stand="+stand+ "&name2="+productName2;
url = url + "&desc=" + description + "&category="+category;
url = url + "&productType="+productType;
var req = initRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                    if(productType == 'Prescription Medicines'){
                	 document.getElementById("SelectedValue").innerHTML = parseXML(req.responseXML,"addedList",imagePath,"Prescription Medicines");
                    }else{
                     document.getElementById("SelectedValue").innerHTML = parseConsumerXML(req.responseXML,"addedList",imagePath,"Consumer Products");
                    }
                    prdType = req.responseText;
                    delete req;
                    req = null;
                } else {
       				 alert("Problem with server response:\n " + req.statusText);
     			 }
              }
        };
	
	req.open("post",url,true);
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.send(null);
}
}



function getData(url,imagePath,productType) {
    var req = initRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                if(productType == 'Prescription Medicines'){
					document.getElementById("bodyDiv").innerHTML = parseXML(req.responseXML,"selectionList",imagePath,productType);
					removeProduct("","/a2w/images/","Prescription Medicines");
                }else{
                if(openDiv < 1){
                openDiv++;
                document.getElementById("bodyDiv").innerHTML = parseConsumerXML(req.responseXML,"selectionList",imagePath,productType);
                removeProduct("","/a2w/images/","Consumer Products");
                }else{
                  openConsumerDiv();
                }
                selectHighlited('consprod', 'presmed');
                }
                    delete req;
                    req = null;
                } else {
       				 alert("Problem with server response:\n " + req.statusText);
     			 }
              }
        };
		
        req.open("post",url,true);
        req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		req.send(null);
        
}

function parseXML(responseXML,selectValue,imagePath,productType){
	var products = responseXML.getElementsByTagName("products")[0];
	
	var resultHTML ="";
	resultHTML = '';
    if(selectValue != 'selectionList')
    resultHTML = "<table bgcolor=\"#FFFF99\" width=\"250\" height=\"200\"> ";
	 var previousProductName = "-1";

     var selectLinkHtml = "";
     
     var isTab1Set = false;
     var isTab2Set = false;
     var isTab3Set = false;
     var isTab4Set = false;
     var isTab5Set = false;
     
	if(products)
		for (loop = 0; loop < products.childNodes.length; loop++) {
			
			var product = products.getElementsByTagName("product")[loop];

		
			if(!product)  continue;
   			if(product.getElementsByTagName("name1")[0].childNodes[0])
			var productName1 = product.getElementsByTagName("name1")[0].childNodes[0].nodeValue;
			else
			var productName1 = "";

			if(product.getElementsByTagName("standard")[0].childNodes[0])
			var stand = product.getElementsByTagName("standard")[0].childNodes[0].nodeValue.trim();
			else
			var stand = "";

			if(product.getElementsByTagName("name2")[0].childNodes[0])
			var productName2 = product.getElementsByTagName("name2")[0].childNodes[0].nodeValue.trim();
			else
			var productName2 = "";

			if(product.getElementsByTagName("description")[0].childNodes[0])
	        var description = product.getElementsByTagName("description")[0].childNodes[0].nodeValue.trim();
			else
			var description = "";

	        if(product.getElementsByTagName("category")[0].childNodes[0])
			var category = product.getElementsByTagName("category")[0].childNodes[0].nodeValue.trim();
			else
			var category = "";


			if(product.getElementsByTagName("id")[0].childNodes[0])
			var productId = product.getElementsByTagName("id")[0].childNodes[0].nodeValue.trim();
			else
			var productId="";

			            

	        if(selectValue == "selectionList"){
			if(product.getElementsByTagName("type")[0] == null || product.getElementsByTagName("type")[0].childNodes[0].nodeValue=='Prescription Medicines'){	
				
									
				resultHTML = '';
				
                
		         resultHTML=resultHTML + "<p class=\"prodStyle\"><input type=\"checkbox\" name=\"ministat\" class=\"checkStyle\" id=\""+productId+"\" value=\""+productName1+"\" onclick=\"addProduct('"+productId+"','"+productName1+"','" +stand+"','"+productName2+"','"+description+"','"+category+"','"+imagePath+"','"+productType+"',this)\"/>";
		         resultHTML=resultHTML + '<label class="prodStyle">'+productName1+'</label>';
		         	//Added for JC00017087
		        	if(stand == "reg"){
		        	    //Ticket# 17117 start - removed product condition
		        	    resultHTML=resultHTML +"<b>&reg; &nbsp;"+splitProductName(productName2)+"</b>"; 
		        	    //Ticket# 17117 end
		        	    								
					}else if(stand == "tm"){
						resultHTML=resultHTML +"<b>&trade;</b>"; 
					}
					//End of addition
		        				
		        	resultHTML=resultHTML + '<div class="space_tab"><label class="medDescription"> ' + description + "</label></div></p>";
				/*resultHTML=resultHTML + " <tr onmouseover=\"changeColor(this,'#FFFF99')\" " 
		        			+ " onmouseout=\"changeColor(this,'white')\" > <td valign='top'> "
		        			+ " <div style='cursor:hand;'><img src=\""+imagePath+"plus.gif\" onclick=\"addProduct('"+productId+"','"+productName1+"','" +stand+"','"+productName2+"','"+description+"','"+category+"','"+imagePath+"')\"> </img></div></td> <td valign='top'> ";
		        */

					if(previousProductName.charAt(0) != productId.charAt(0) && productId.charAt(0)!="^") {

							if(previousProductName!="-1" && 
								(previousProductName.charCodeAt(0)-productId.charCodeAt(0))!=-1){

								var start = previousProductName.charCodeAt(0) + 1;
								var end  = productId.charCodeAt(0);

								for (loop1 = start; loop1 < end; loop1++)
									selectLinkHtml = selectLinkHtml + "<font class='btext_ch_space_a_disable'>"+ String.fromCharCode(loop1) + "</font>";
								
							}

							selectLinkHtml = selectLinkHtml + "<a class='btext_ch_space_a' href='#" + productId.charAt(0) +"'>" + productId.charAt(0) +"</a>";

							//resultHTML = resultHTML	+ "<a name=\""+productId.charAt(0)+"\"></a>";
							previousProductName = productId;
							
						}


		        	//resultHTML=resultHTML + "<b>"+productName1+"</b>";
		        	
		        	

					/*if(stand == "reg"){
					if(productName2 == "-K" || productName2 == "-K Crystals"){
    					resultHTML=resultHTML +"<b>?"+splitProductName(productName2)+"</b>"; 
					}
					else{
						resultHTML=resultHTML +"<b>? &nbsp;"+splitProductName(productName2)+"</b>"; 
						}
					}else if(stand == "tm"){
						resultHTML=resultHTML +"<b>&trade;&nbsp;"+splitProductName(productName2)+"</b>"; 
					}
					*/
					
				
					
				var af = "abcdef";
				var gl = "ghijkl";
				var mr = "mnopqr";
				var sw = "stuvw";
				var xz = "xyz";
				
				
				
				if( af.indexOf(productName1.charAt(0).toLowerCase()) >= 0){
					
					document.getElementById("tab1Content").innerHTML = document.getElementById("tab1Content").innerHTML + resultHTML;
					document.getElementById("country1").style.display = 'block';
					
				}
				
				if( gl.indexOf(productName1.charAt(0).toLowerCase()) >= 0){
				
					document.getElementById("tab2Content").innerHTML = document.getElementById("tab2Content").innerHTML + resultHTML;

				}
				if( mr.indexOf(productName1.charAt(0).toLowerCase()) >= 0){
				
					document.getElementById("tab3Content").innerHTML = document.getElementById("tab3Content").innerHTML + resultHTML;

				}
				if( sw.indexOf(productName1.charAt(0).toLowerCase()) >= 0){
				
					document.getElementById("tab4Content").innerHTML = document.getElementById("tab4Content").innerHTML + resultHTML;

				}
				if( xz.indexOf(productName1.charAt(0).toLowerCase()) >= 0){
				
					document.getElementById("tab5Content").innerHTML = document.getElementById("tab5Content").innerHTML + resultHTML;

				}
			}

	
		
			
					
			}
		     else{
		      
				var checkArray = document.getElementsByName("ministat");
		        
		        if(null != checkArray && checkArray.length > 0){
		         checkProducts(checkArray, productId);
		       }
				count = count+1;
				//Start JC00017500
		        if( products.childNodes.length-1 == loop)
		        {
		        	resultHTML=resultHTML + " <tr " 
			        			+ " > <td valign='top'> "
			        			+ " <div style='cursor:hand;'> <img src=\""+imagePath+"minus.gif\" onclick=\"removeProduct('"+productId+"','"+imagePath+"','"+productType+"')\"> </img></div></td> <td valign='top' align='left'> <b>"
			        			+ unescape(productName1)+"</b>";
		        }
		        else
		        {
					resultHTML=resultHTML + " <tr " 
		        			+ " > <td valign='top'> "
		        			+ " <div style='cursor:hand;'> <img src=\""+imagePath+"minus.gif\" onclick=\"removeProduct('"+productId+"','"+imagePath+"','"+productType+"')\"> </img></div></td> <td valign='top' align='left' height='40px'> <b>"
		        			+ unescape(productName1)+"</b>";		        	
		        	
		        }
				//End JC00017500		        			
				if(stand == "reg"){
						resultHTML=resultHTML +"<b>&reg; &nbsp;"+splitProductName(productName2)+"</b>"; 
						

					}else if(stand == "tm"){
						resultHTML=resultHTML +"<b>&trade;&nbsp;"+splitProductName(productName2)+"</b>"; 
					}
					resultHTML=resultHTML + "<br> " +"&nbsp;&nbsp;" + description + "  </td> </tr> ";

			 }
			 
	       
		}
	else
	    resultHTML = resultHTML + "<tr><td valign='top'> No Products selected</td></tr>";

		resultHTML = resultHTML + " </table> ";
	if(selectValue == "selectionList") {
			productName1 = "Z";
		if((previousProductName.charCodeAt(0)-productName1.charCodeAt(0))!=-1){

			var start = previousProductName.charCodeAt(0) + 1;
			var end  = productName1.charCodeAt(0);

			for (loop1 = start; loop1 <= end; loop1++)
				selectLinkHtml = selectLinkHtml + "<font class='btext_ch_space_a_disable'>" +String.fromCharCode(loop1) + "</font>";
		}
								
			//document.getElementById("selectLink").innerHTML = selectLinkHtml;
	}else {
	     
        
		resultHTML = resultHTML +"<span style='display:none' id=\"productCount\">"+ count + "</span>";
		return resultHTML;
		
	}
   
	

	
}

function parseConsumerXML(responseXML,selectValue,imagePath,productType){
	var products = responseXML.getElementsByTagName("products")[0];
	
	var resultHTML ="";
	resultHTML = '';
    if(selectValue != 'selectionList')
    resultHTML = "<table bgcolor=\"#FFFF99\" width=\"250\" height=\"200\"> ";
	 var previousProductName = "-1";

     var selectLinkHtml = "";
   

 
	if(products)
		for (loop = 0; loop < products.childNodes.length; loop++) {
			
			var product = products.getElementsByTagName("product")[loop];
         
		
			if(!product)  continue;
            if(product.getElementsByTagName("type")[0] != null){
           
           
             
          
   			if(product.getElementsByTagName("name1")[0].childNodes[0]){
			var productName1 = product.getElementsByTagName("name1")[0].childNodes[0].nodeValue;
			
			}
			else
			var productName1 = "";

			if(product.getElementsByTagName("standard")[0].childNodes[0])
			var stand = product.getElementsByTagName("standard")[0].childNodes[0].nodeValue.trim();
			else
			var stand = "";

			if(product.getElementsByTagName("name2")[0].childNodes[0])
			var productName2 = product.getElementsByTagName("name2")[0].childNodes[0].nodeValue.trim();
			else
			var productName2 = "";

			if(product.getElementsByTagName("description")[0].childNodes[0])
	        var description = product.getElementsByTagName("description")[0].childNodes[0].nodeValue.trim();
			else
			var description = "";

	        if(product.getElementsByTagName("category")[0].childNodes[0])
			var category = product.getElementsByTagName("category")[0].childNodes[0].nodeValue.trim();
			else
			var category = "";


			if(product.getElementsByTagName("id")[0].childNodes[0])
			var productId = product.getElementsByTagName("id")[0].childNodes[0].nodeValue.trim();
			else
			var productId="";

			
	        if(selectValue == "selectionList"){
				
				if(product.getElementsByTagName("type")[0].childNodes[0].nodeValue == productType){
					document.getElementById("consumerId").style.display = 'block';				
				resultHTML = '';
				var encProdName1 = productName1;
                encProdName1 = escape(encProdName1);
                     resultHTML=resultHTML + "<p class=\"consProdStyle\"><input type=\"checkbox\" name=\"ministatcon\" value=\""+encProdName1+"\" class=\"checkStyle\" id=\""+productId+"\" onclick=\"addProduct('"+productId+"','"+encProdName1+"','" +stand+"','"+productName2+"','"+description+"','"+category+"','"+imagePath+"','"+productType+"',this)\"/>";
		         resultHTML=resultHTML + '<label class="consProdStyle">'+productName1+'</label>';
		         	//Added for JC00017087
		        	if(stand == "reg"){
		        	    //Ticket# 17117 start - removed product condition
		        	    resultHTML=resultHTML +"<b>&reg; &nbsp;"+splitProductName(productName2)+"</b>"; 
		        	    //Ticket# 17117 end
		        	    								
					}else if(stand == "tm"){
						resultHTML=resultHTML +"<b>&trade;</b>"; 
					}
					//End of addition
		        				
		        	resultHTML=resultHTML + '<div class="space_tab"><label class="medDescription"> ' + description + "</label></div></p>";
				/*resultHTML=resultHTML + " <tr " 
		        			+ "  > <td valign='top'> "
		        			+ " <div style='cursor:hand;'><img src=\""+imagePath+"plus.gif\" onclick=\"addProduct('"+productId+"','"+productName1+"','" +stand+"','"+productName2+"','"+description+"','"+category+"','"+imagePath+"')\"> </img></div></td> <td valign='top'> ";
		        */

					if(previousProductName.charAt(0) != productId.charAt(0) && productId.charAt(0)!="^") {

							if(previousProductName!="-1" && 
								(previousProductName.charCodeAt(0)-productId.charCodeAt(0))!=-1){

								var start = previousProductName.charCodeAt(0) + 1;
								var end  = productId.charCodeAt(0);

								for (loop1 = start; loop1 < end; loop1++)
									selectLinkHtml = selectLinkHtml + "<font class='btext_ch_space_a_disable'>"+ String.fromCharCode(loop1) + "</font>";
								
							}

							selectLinkHtml = selectLinkHtml + "<a class='btext_ch_space_a' href='#" + productId.charAt(0) +"'>" + productId.charAt(0) +"</a>";

							//resultHTML = resultHTML	+ "<a name=\""+productId.charAt(0)+"\"></a>";
							previousProductName = productId;
							
						}
						document.getElementById("tabButtons").style.display = 'none';
						document.getElementById("prescriptionDiv").style.display = 'none';
                	   document.getElementById("consumerId").innerHTML = document.getElementById("consumerId").innerHTML + resultHTML;
					//document.getElementById("country1").style.display = 'block';
			}
			}
		     else{
		        var checkArray = document.getElementsByName("ministatcon");
		       
		        if(null != checkArray && checkArray.length > 0){
		         checkProducts(checkArray, productId);
		       }
		      	count = count+1;
		      	//Start JC00017500
		        if( products.childNodes.length-1 == loop)	
		        {
		        	resultHTML=resultHTML + " <tr onmouseover=\"changeColor(this,'white')\" " 
			        			+ " onmouseout=\"changeColor(this,'#FFFF99')\"> <td valign='top'> "
			        			+ " <div style='cursor:hand;'> <img src=\""+imagePath+"minus.gif\" onclick=\"removeProduct('"+productId+"','"+imagePath+"','"+productType+"')\"> </img></div></td> <td valign='top' align='left' > <b>"
			        			+ unescape(productName1)+"</b>";
		        }
		        else
		        {
		        	resultHTML=resultHTML + " <tr onmouseover=\"changeColor(this,'white')\" " 
			        			+ " onmouseout=\"changeColor(this,'#FFFF99')\"> <td valign='top'> "
			        			+ " <div style='cursor:hand;'> <img src=\""+imagePath+"minus.gif\" onclick=\"removeProduct('"+productId+"','"+imagePath+"','"+productType+"')\"> </img></div></td> <td valign='top' align='left' height='40px'> <b>"
			        			+ unescape(productName1)+"</b>";
		        	
		        }
            //End JC00017500			
		       			
							
					if(stand == "reg"){
						resultHTML=resultHTML +"<b>&reg; &nbsp;"+splitProductName(productName2)+"</b>"; 
						

					}else if(stand == "tm"){
						resultHTML=resultHTML +"<b>&trade;&nbsp;"+splitProductName(productName2)+"</b>"; 
					}
					resultHTML=resultHTML + "<br> " +"&nbsp;&nbsp;" + description + "  </td> </tr> ";
                
			 }
			 
			 }
	        
		}
	else
	    resultHTML = resultHTML + "<tr><td valign='top'> No Products selected</td></tr>";

		resultHTML = resultHTML + " </table> ";

	if(selectValue == "selectionList") {
			productName1 = "Z";
		if((previousProductName.charCodeAt(0)-productName1.charCodeAt(0))!=-1){

			var start = previousProductName.charCodeAt(0) + 1;
			var end  = productName1.charCodeAt(0);

			for (loop1 = start; loop1 <= end; loop1++)
				selectLinkHtml = selectLinkHtml + "<font class='btext_ch_space_a_disable'>" +String.fromCharCode(loop1) + "</font>";
		}
								
			//document.getElementById("selectLink").innerHTML = selectLinkHtml;
	}else {

		resultHTML = resultHTML +"<span style='display:none' id=\"productCount\">"+ count + "</span>";
		return resultHTML;
		
	}

	

	
}

function splitProductName(productName){

	if(productName == null || productName =="") return "";
	
	var prodArray = productName.split(";");

	var prodHTML = "";

	for(prodLoop=0; prodLoop<prodArray.length; prodLoop++){
		//Ticket# 17117 start
		if(prodArray[prodLoop].trim()=="reg") prodHTML=prodHTML+"&reg; &nbsp;";
		//Ticket# 17117 end
		else if(prodArray[prodLoop].trim()=="tm") prodHTML=prodHTML+"&trade; &nbsp;";
		else prodHTML=prodHTML + prodArray[prodLoop].trim();

	}
	
	return prodHTML+"&nbsp;";

}
function selectedProducts(){

	var url="/a2w/productAction.do?action=removeProduct&id="+" ";
	var req = initRequest();
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
					
					document.getElementById("SelectedValue").innerHTML = parseSelectedProductsXML(req.responseXML);
                    
                    delete req;
                    req = null;
                } else {
       				 alert("Problem with server response:\n " + req.statusText);
     			 }
              }
        };
	
	req.open("post",url,true);
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.send(null);
}



function parseSelectedProductsXML(responseXML){
	
	var products = responseXML.getElementsByTagName("products")[0];
	
	var resultHTML ="<table class='ttable_wide_full' border='0'>";
	
	if(products)
		for (loop = 0; loop < products.childNodes.length; loop++) {
			
			var product = products.childNodes[loop];

			if(!product)  continue;

	        var productName1 = product.getElementsByTagName("name1")[0].childNodes[0].nodeValue;
			
			
			if(product.getElementsByTagName("standard")[0].childNodes[0])
			var stand = product.getElementsByTagName("standard")[0].childNodes[0].nodeValue;
			else
			var stand = "";

			if(product.getElementsByTagName("name2")[0].childNodes[0])
			var productName2 = product.getElementsByTagName("name2")[0].childNodes[0].nodeValue;
			else
			var productName2 = "";

			if(product.getElementsByTagName("description")[0].childNodes[0])
	        var description = product.getElementsByTagName("description")[0].childNodes[0].nodeValue;
			else
			var description = "";

	        if(product.getElementsByTagName("category")[0].childNodes[0])
			var category = product.getElementsByTagName("category")[0].childNodes[0].nodeValue;
			else
			var category = "";


				resultHTML = resultHTML + "<tr> <td valign='top'>";

				resultHTML=resultHTML + "&bull; &nbsp; </td> <td valign='top' class='btext' >" + productName1;
					if(stand == "reg"){
						resultHTML=resultHTML +"? &nbsp;"+splitProductName(productName2); 
					}else if(stand == "tm"){
						resultHTML=resultHTML +"&trade;&nbsp;"+splitProductName(productName2); 
					}

					resultHTML=resultHTML + "&nbsp;" + description + " </td></tr>";
				
		 
	}
			
	resultHTML =  resultHTML + "</table>";

	
	return resultHTML;
}

function changeColor(tableId,cValue){
tableId.setAttribute('bgcolor', cValue, 0);
}


String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function textSize(size,pageName,url){

	var currentSize = document.getElementById("textSize").innerHTML.trim();
    
	if(size == currentSize)  return false;
 
	if(pageName == "tellafriend.html")
 	location.href='textSize.do?textsize='+size+'&pageName=tellafriend.form?url='+url;
 	else
	location.href='textSize.do?textsize='+size+'&pageName='+pageName;
	

	
}

function selectHighlited(id1, id2){
 //Start JC00017500
 if(id1 == 'presmed'){
	  document.getElementById(id1).className="active_blue";
	  document.getElementById(id2).className="";
	 document.getElementById(id1).getElementsByTagName("img")[0].src=GlobalVarCtx+"/images/pm_on.gif";
	 document.getElementById(id2).getElementsByTagName("img")[0].src=GlobalVarCtx+"/images/cp_off.gif";
  }else{
    document.getElementById(id1).className="active_red";
	document.getElementById(id2).className="";
	 document.getElementById(id1).getElementsByTagName("img")[0].src=GlobalVarCtx+"/images/cp_on.gif";
	 document.getElementById(id2).getElementsByTagName("img")[0].src=GlobalVarCtx+"/images/pm_off.gif";

  }
 //End JC00017500
}
function checkProducts(checkArray, productId){
  for(i=0; i<checkArray.length; i++ ){
   var prod1 = checkArray[i];
   var prodId=prod1.id;
    if(unescape(productId) == unescape(prodId)){
       prod1.checked=true;
    }
 
   
  }

}
//Start JC00017500
try {
	document.execCommand("BackgroundImageCache", false, true);
}
catch (err) {
}
//End JC00017500


//-->
