function s_code_params() {
	this.events="";
	this.products="";
	this.purchaseID="";
	this.prop14="";
	this.eVar10="";
}
var exp_s = new s_code_params();



function setNameFields(obj) {
 document.getElementById('notSignedInlinks').style.display="none"; 
 document.getElementById('signedLinks').style.display="block";
 document.getElementById('nameId').innerHTML="<strong>Welcome " + obj.user+"</strong>";
 document.getElementById('cartCountId').innerHTML="View My Cart( " + obj.cartItemCount +" Items)";
}

function applyCSS(properties) {
	if(properties!=null && properties!="") {
	 	properties = properties.substring(1,properties.length-1);
	 	var propertiesArray = properties.split(",");
	 	for(var i = 0; i < propertiesArray.length; i++) {
	 		var property = propertiesArray[i].trim();
	 		var label = dojo.byId(property+"_label");
	 		if(label!=null) {
	 			label.style.color = "red"
	 		}
	 		var input = dojo.byId(property+"_input");
	 		if(input !=null){
				input.style.border = "1px solid #ff0000"
	 		}
		}
	}
 }
function closediv(id)
{
dojo.byId(id).style.display="none";
}

function showdiv(id)
{
	dojo.byId(id).style.display="block";
	dojo.byId(id).style.position="fixed";
	dojo.byId(id).style.left="40%";
	dojo.byId(id).style.top="40%";
}

function setMoveable(id) {
	new dojo.dnd.Moveable(dojo.byId(id));
	return true;
}


function openModal(divId) {		
	$('#'+divId).modal({onOpen: modalOpen});
}

function closeModal() {			
	$.modal.close();
}

function upgradeItem (radioName)
{
    if (!isRadioButtonChecked(document.getElementsByName(radioName))) {
    	alert("Please select the product");
    	return;
    }
    document.formUpgrade.submit();
    
}

function editItem (radioName, editFromSKU)
{
    if (get_radio_value(document.getElementsByName(radioName))== editFromSKU) {
    	closeModal();
    	return;
    } else {
        document.formUpgrade.submit();
      }
}

function populateUpgradeItem (catalogRefIds, removalCommerceIds, productId, removalCatalogRefIds, sbsItemId)
{
    document.getElementById('catalogRefIds').value=catalogRefIds;
    document.getElementById('removalCommerceIds').value=removalCommerceIds;
    document.getElementById('productId').value=productId;
    document.getElementById('removalCatalogRefIds').value=removalCatalogRefIds;
    document.getElementById('quantity').value='1';
    document.getElementById('sbsItemId').value=sbsItemId;
}


function deleteItemFromCart (removalCommerceIds, removalSbsItems)
{
   // alert ("Delete the commerce Id : '" + removalCommerceIds + "'");
    document.getElementById('removalCommerceIdsForDelete').value=removalCommerceIds;
    document.getElementById('removalSbsItems').value=removalSbsItems;
    document.formDelete.submit();
}

function saveForLater (itemId, wishListId, sbsItemId)
{	
   document.getElementById('itemId').value=itemId;
    document.getElementById('wishListId').value=wishListId;
    document.getElementById('saveSbsItemId').value=sbsItemId;             
    document.forms.formSaveForLater.submit();
}

function deleteItemFromWishList (wishListId,wishListItemId)
{
    //alert ("Remove WishList : '" + wishListId + "', wishListItemId:" + wishListItemId);
    document.getElementById('giftlistId').value=wishListId;
    document.getElementById('removeGiftitemIds').value=wishListItemId;       
    document.forms.formDeleteWishList.submit();
}


function termsAndConditions()
{  
      if(!document.frmOrderReview.tandc.checked)
    {
    	alert('Please agree to the Terms & Conditions before placing your order.');
    	return false;
    }                 
    document.forms.frmOrderReview.submit();    
}


function moveToLogin ()
{
    //alert ("Move to login");       
    document.forms.formLogin.submit();
}

function moveToCart (skuId,wishListId,wishListItemId,productId,sbsItemId)
{
    //alert ("move To Cart: skuId::" + skuId + ",wishListId::" + wishListId + ",wishListItemId::" + wishListItemId +",productId::" + productId +",sbsItemId" + sbsItemId);   
    
    document.getElementById('mcskuId').value=skuId;
    document.getElementById('mcwishListId').value=wishListId;       
    document.getElementById('mcwishListItemId').value=wishListItemId;
    document.getElementById('mcproductId').value=productId;
    document.getElementById('mcsbsItemId').value=sbsItemId;    
    document.forms.formMoveToCart.submit();
}

function editBusinessList (sbsItemId)
{	
    document.getElementById('editBLSbsItemId').value=sbsItemId;  
    document.getElementById('rerunType').value="true";           
    document.forms.formEditBusinessList.submit();
}

function editConsumerList (sbsItemId,prodType,listType)
{	
	//alert('prodType:' + prodType);
    document.getElementById('editCLSbsItemId').value=sbsItemId; 
    document.getElementById('editCLSbsProdType').value=prodType; 
    setConsumerListAction(prodType,listType);      //This function is available in Cart.jsp      
    document.forms.formEditConsumerList.submit();
}

function businessreportinfo ()
{   
   document.getElementById('businessreportinfoname').value=document.getElementById('dojobrname').value;
   document.getElementById('businessreportinfocity').value=document.getElementById('dojobrcity').value;;
   document.getElementById('businessreportinfostate').value=document.getElementById('dojobrstate').value;
   document.getElementById('businessreportinfozip').value=document.getElementById('dojobrzip').value;            
   document.forms.formbusinessreportinfo.submit();
}

function closeDialog ()
{
 alert("testing");
}
          
function selectBusiness(productsAvailable, address1, businessName, city, state, zip, tradelines, fnumber,maxProductAvailable)
{ 
  if(address1!=null){
	  dojo.byId("productsAvailable").value = productsAvailable;
	  dojo.byId("address1").value = address1;
	  dojo.byId("businessName").value = businessName;
	  dojo.byId("city").value = city;
	  dojo.byId("state").value = state;
	  dojo.byId("zip").value = zip;
	  dojo.byId("tradelines").value = tradelines;
	  dojo.byId("fnumber").value = fnumber;
	  dojo.byId("maxProductAvailable").value = maxProductAvailable;
	  if(dojo.byId("report_results").style!=null){
	  	dojo.byId("report_results").style.display="block";
	  }
  
	/*if (prodListVariant == 'style1') {
		
				dojo.byId("nav").style.display = "none";
				dojo.byId("businessCreditSearchBoxTop").style.display = "block";
				dojo.byId("report_results").style.display = "none";
				dojo.byId("businessCreditSearchMain").style.display = "none";
				dojo.byId("businessCreditSearchAlt").style.display = "block";
				dojo.byId("reports_availableAlt").innerHTML = response;
				dojo.byId("reports_availableAlt").style.display = "block";
							
			
		
	}
	
	else {
		
				dojo.byId("reports_available").innerHTML = response;
				dojo.byId("reports_available").style.display = "block";
				dojo.byId("report_results").style.display = "none";
				
			
	}*/
	
  	document.selectBusinessForm.submit();
  }
} 


function displayAnnualModal(){
	//$("radioButton").show();
	//alert('test1'+document.getElementById('annualDiv').style.visibility);
	document.getElementById("annualDiv").style.display="block";
	//if(document.getElementById('annualDiv').style.visibility == 'visible'){
		
		
		
		
		
	//}	
}

     


function addBusinessReportToCart (productId, skuId, address1, businessName, city, state, zip, tradelines, fNumber,maxProductAvailable)
{
	//alert('skuid::' + dojo.byId(skuId).value);
	if(dojo.byId(skuId).value == null || dojo.byId(skuId).value.length == 0)
	{
		alert('Please select a product');
		return false;
	}
	dojo.byId('addtocartproductid').value=productId;
	dojo.byId('addtocartskuid').value=dojo.byId(skuId).value;
	dojo.byId('addtocartaddress1').value=address1;
	dojo.byId('addtocartbusinessName').value=businessName;
	dojo.byId('addtocartcity').value=city;
	dojo.byId('addtocartstate').value=state;
	dojo.byId('addtocartzip').value=zip;
	dojo.byId('addtocarttradelines').value=tradelines;
	dojo.byId('addtocartexpFileNumber').value=fNumber;
	dojo.byId('addtocartmaxProductAvailable').value=maxProductAvailable;	
	 
	document.forms.formaddtocart.submit();
}

function isRadioButtonChecked(radio)
{
	// set var radio_choice to false
	var radio_choice = false;
	
		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < radio.length; counter++)
		{
		// If a radio button has been selected it will return true
		// (If not it will return false)
			if (radio[counter].checked) {
				return true;
			}
		}
	return radio_choice;

}
         
/********************************** My Account Start *********************************************/

function getCookie(c_name)
{
	if (document.cookie.length>0){		
		  c_start=document.cookie.indexOf(c_name + "=");
	  	  if (c_start!=-1){ 
	    		c_start=c_start + c_name.length+1; 
	    		c_end=document.cookie.indexOf(";",c_start);
	    		if (c_end==-1) c_end=document.cookie.length;
	    		return unescape(document.cookie.substring(c_start,c_end));
	    	} 
 			}
	return "";
}

function setCookie()
{		

	//alert('cookie checked? ' + document.getElementById('rememberEmail').checked);
	if(dojo.byId('rememberEmail').checked) 
	{
		var exdate=new Date();
		var c_name ="emailAddress";
		var value = dojo.byId('loginEmail_input').value;			
		var expiredays = dojo.byId('cookieDays').value;
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}		
}

function checkCookie()
{
	emailAddress=getCookie('emailAddress');			  			
	if (emailAddress !=null && emailAddress != '') {
				dojo.byId('loginEmail_input').value = emailAddress;
				dojo.byId('rememberEmail').checked = true;    			
			}
  		  		
}       
         
/********************************** My Account End*********************************************/            
      
         
function setBRSkuValue(crskuid,crskuidval)
{ 
 dojo.byId(crskuid).value = crskuidval; 
}   
 
function backtoBRSearchResultsAlt()
{ 
  dojo.byId("businessCreditSearchBoxTop").style.display="none";
  dojo.byId("reports_availableAlt").style.display="none";
  dojo.byId("nav").style.display="block";
  dojo.byId("businessCreditSearchMain").style.display="block";		
  dojo.byId("report_results").style.display="block";
}  

function backtoBRSearchResults()
{ 		
  dojo.byId("reports_available").style.display="none";
  dojo.byId("report_results").style.display="block";
} 

String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
}

function StatusMsg( LinkDesc) {
    if (LinkDesc == "") {
       status = " "
    } else {
       status = ("Updating list count. ")
    }
    return true
}


// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function get_radio_value(radio)
{
for (var i=0; i < radio.length; i++)
   {
   if (radio[i].checked)
      {
       return radio[i].value;
      }
   }
}

	
function getSCEvents(name)
{
	var urlEvents = getURLParam('events');
	if (urlEvents != null && urlEvents != "")
	{	
		if (exp_s.events != "")
		{
			exp_s.events = exp_s.events + "," + urlEvents;
		}
		else
		{
			exp_s.events = urlEvents;
		}
	}
	return exp_s.events;
}

function getURLParam(name)
{

  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];

}

function openIframeModal(divId, width, height, title, url)
{
	$("#modalHolder").empty();
	$("#modalHolder").append("<div id='"+divId+"' style='display:none;width:"+width+"px;'><div class='modalTitleBar'><h6>"+title+"</h6></div><div id='"+divId+"Inner' style='width:"+width+"px;'><iframe width='"+width+"px' height='"+height+"px' src='"+url+"'></iframe></div></div>");	
	openModal(divId);
	
}


function downloadSample(listType) {
	if(listType =='EBD')
	{
		window.open('/small-business/marketinglist/assets/Business_List_Sample.csv','mywindow','location=0  ,resizable=yes,status=0,scrollbars=1,width=800,height=600');
	} else {
		window.open('/small-business/marketinglist/assets/Consumer_List_Sample.csv','mywindow','location=0  ,resizable=yes,status=0,scrollbars=1,width=800,height=600');
	}
}

function showAddress(address) {
	var map = null;
	var geocoder = null;
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		geocoder = new GClientGeocoder();
	}
	if (geocoder) {
						      
		geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
							              
			} else {
				map.setCenter(point, 13);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(address);
			}
		}
		);
	}
}

function buildEZList(categoryId,geoState,geoLocation,cityId)				
{	
			document.getElementById("ezcompanyState_input").value= geoState;	
			document.getElementById("cityList").value=geoLocation; 
			document.getElementById("cityValue").value=cityId; 
			//alert(cityId);    
    		document.forms.categoryForm.submit();    	
}


function adjustDivHeight(obj) { 
	e = document.getElementById( 'ezFlexBox' ); 
	//alert('height'+obj.height);
	//alert('height before'+e.style.height);
	e.style.height = obj.exHeight + 'px'; 
	e.style.width = obj.exWidth + 'px'; 
	
	f = document.getElementById( 'ezSBS' ); 
	//alert('height'+obj.height);
	//alert('height before'+e.style.height);
	f.style.height = obj.height + 'px'; 
	f.style.width = obj.width + 'px';
	//alert('height after'+e.style.height);
	
} 

function adjustUrl(){
	//alert('');
	//window.location('/small-business/marketinglist/ezList.jsp?step=test');
}

 
